Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 1 | # Copyright 2015 NEC Corporation. All rights reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | import mock |
| 16 | import random |
| 17 | import six |
| 18 | |
Ken'ichi Ohmichi | 1f88ece | 2015-01-23 03:33:11 +0000 | [diff] [blame] | 19 | from tempest.services.baremetal.v1.json import baremetal_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 20 | from tempest.services.compute.json import agents_client |
| 21 | from tempest.services.compute.json import aggregates_client |
| 22 | from tempest.services.compute.json import availability_zone_client |
| 23 | from tempest.services.compute.json import certificates_client |
| 24 | from tempest.services.compute.json import extensions_client |
| 25 | from tempest.services.compute.json import fixed_ips_client |
| 26 | from tempest.services.compute.json import flavors_client |
| 27 | from tempest.services.compute.json import floating_ips_client |
| 28 | from tempest.services.compute.json import hosts_client |
| 29 | from tempest.services.compute.json import hypervisor_client |
| 30 | from tempest.services.compute.json import images_client |
| 31 | from tempest.services.compute.json import instance_usage_audit_log_client |
| 32 | from tempest.services.compute.json import interfaces_client |
| 33 | from tempest.services.compute.json import keypairs_client |
| 34 | from tempest.services.compute.json import limits_client |
| 35 | from tempest.services.compute.json import migrations_client |
| 36 | from tempest.services.compute.json import networks_client as nova_net_client |
Ken'ichi Ohmichi | a89dd6b | 2015-06-15 05:25:14 +0000 | [diff] [blame] | 37 | from tempest.services.compute.json import quota_classes_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 38 | from tempest.services.compute.json import quotas_client |
| 39 | from tempest.services.compute.json import security_group_default_rules_client \ |
| 40 | as nova_secgrop_default_client |
| 41 | from tempest.services.compute.json import security_groups_client |
| 42 | from tempest.services.compute.json import servers_client |
| 43 | from tempest.services.compute.json import services_client |
| 44 | from tempest.services.compute.json import tenant_usages_client |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 45 | from tempest.services.compute.json import volumes_extensions_client \ |
| 46 | as compute_volumes_extensions_client |
Ken'ichi Ohmichi | 4e83b5e | 2015-02-13 04:07:34 +0000 | [diff] [blame] | 47 | from tempest.services.data_processing.v1_1 import data_processing_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 48 | from tempest.services.database.json import flavors_client as db_flavor_client |
| 49 | from tempest.services.database.json import versions_client as db_version_client |
Jamie Lennox | c429e6a | 2015-02-24 10:42:42 +1100 | [diff] [blame] | 50 | from tempest.services.identity.v2.json import identity_client as \ |
ghanshyam | d26b5cd | 2015-02-09 14:48:58 +0900 | [diff] [blame] | 51 | identity_v2_identity_client |
| 52 | from tempest.services.identity.v3.json import credentials_client |
| 53 | from tempest.services.identity.v3.json import endpoints_client |
| 54 | from tempest.services.identity.v3.json import identity_client as \ |
| 55 | identity_v3_identity_client |
| 56 | from tempest.services.identity.v3.json import policy_client |
| 57 | from tempest.services.identity.v3.json import region_client |
| 58 | from tempest.services.identity.v3.json import service_client |
Masayuki Igawa | bc7e189 | 2015-03-03 11:46:48 +0900 | [diff] [blame] | 59 | from tempest.services.image.v1.json import image_client |
| 60 | from tempest.services.image.v2.json import image_client as image_v2_client |
Ken'ichi Ohmichi | 2183a65 | 2015-01-22 05:00:20 +0000 | [diff] [blame] | 61 | from tempest.services.messaging.json import messaging_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 62 | from tempest.services.network.json import network_client |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 63 | from tempest.services.object_storage import account_client |
| 64 | from tempest.services.object_storage import container_client |
| 65 | from tempest.services.object_storage import object_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 66 | from tempest.services.orchestration.json import orchestration_client |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 67 | from tempest.services.telemetry.json import telemetry_client |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 68 | from tempest.services.volume.json.admin import volume_hosts_client |
| 69 | from tempest.services.volume.json.admin import volume_quotas_client |
| 70 | from tempest.services.volume.json.admin import volume_services_client |
| 71 | from tempest.services.volume.json.admin import volume_types_client |
| 72 | from tempest.services.volume.json import availability_zone_client \ |
| 73 | as volume_az_client |
| 74 | from tempest.services.volume.json import backups_client |
| 75 | from tempest.services.volume.json import extensions_client \ |
| 76 | as volume_extensions_client |
| 77 | from tempest.services.volume.json import qos_client |
| 78 | from tempest.services.volume.json import snapshots_client |
| 79 | from tempest.services.volume.json import volumes_client |
| 80 | from tempest.services.volume.v2.json.admin import volume_hosts_client \ |
| 81 | as volume_v2_hosts_client |
| 82 | from tempest.services.volume.v2.json.admin import volume_quotas_client \ |
| 83 | as volume_v2_quotas_client |
| 84 | from tempest.services.volume.v2.json.admin import volume_services_client \ |
| 85 | as volume_v2_services_client |
| 86 | from tempest.services.volume.v2.json.admin import volume_types_client \ |
| 87 | as volume_v2_types_client |
| 88 | from tempest.services.volume.v2.json import availability_zone_client \ |
| 89 | as volume_v2_az_client |
| 90 | from tempest.services.volume.v2.json import backups_client \ |
| 91 | as volume_v2_backups_client |
| 92 | from tempest.services.volume.v2.json import extensions_client \ |
| 93 | as volume_v2_extensions_client |
| 94 | from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client |
| 95 | from tempest.services.volume.v2.json import snapshots_client \ |
| 96 | as volume_v2_snapshots_client |
| 97 | from tempest.services.volume.v2.json import volumes_client as \ |
| 98 | volume_v2_volumes_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 99 | from tempest.tests import base |
| 100 | |
| 101 | |
| 102 | class TestServiceClient(base.TestCase): |
| 103 | |
| 104 | @mock.patch('tempest_lib.common.rest_client.RestClient.__init__') |
| 105 | def test_service_client_creations_with_specified_args(self, mock_init): |
| 106 | test_clients = [ |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame^] | 107 | baremetal_client.BaremetalClient, |
| 108 | agents_client.AgentsClient, |
| 109 | aggregates_client.AggregatesClient, |
| 110 | availability_zone_client.AvailabilityZoneClient, |
| 111 | certificates_client.CertificatesClient, |
| 112 | extensions_client.ExtensionsClient, |
| 113 | fixed_ips_client.FixedIPsClient, |
| 114 | flavors_client.FlavorsClient, |
| 115 | floating_ips_client.FloatingIPsClient, |
| 116 | hosts_client.HostsClient, |
| 117 | hypervisor_client.HypervisorClient, |
| 118 | images_client.ImagesClient, |
| 119 | instance_usage_audit_log_client.InstanceUsagesAuditLogClient, |
| 120 | interfaces_client.InterfacesClient, |
| 121 | keypairs_client.KeyPairsClient, |
| 122 | limits_client.LimitsClient, |
| 123 | migrations_client.MigrationsClient, |
| 124 | nova_net_client.NetworksClient, |
| 125 | quotas_client.QuotasClient, |
| 126 | quota_classes_client.QuotaClassesClient, |
| 127 | nova_secgrop_default_client.SecurityGroupDefaultRulesClient, |
| 128 | security_groups_client.SecurityGroupsClient, |
| 129 | servers_client.ServersClient, |
| 130 | services_client.ServicesClient, |
| 131 | tenant_usages_client.TenantUsagesClient, |
| 132 | compute_volumes_extensions_client.VolumesExtensionsClient, |
Ken'ichi Ohmichi | 4e83b5e | 2015-02-13 04:07:34 +0000 | [diff] [blame] | 133 | data_processing_client.DataProcessingClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame^] | 134 | db_flavor_client.DatabaseFlavorsClient, |
| 135 | db_version_client.DatabaseVersionsClient, |
| 136 | messaging_client.MessagingClient, |
| 137 | network_client.NetworkClient, |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 138 | account_client.AccountClient, |
| 139 | container_client.ContainerClient, |
| 140 | object_client.ObjectClient, |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 141 | orchestration_client.OrchestrationClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame^] | 142 | telemetry_client.TelemetryClient, |
| 143 | qos_client.QosSpecsClient, |
| 144 | volume_hosts_client.VolumeHostsClient, |
| 145 | volume_quotas_client.VolumeQuotasClient, |
| 146 | volume_services_client.VolumesServicesClient, |
| 147 | volume_types_client.VolumeTypesClient, |
| 148 | volume_az_client.VolumeAvailabilityZoneClient, |
| 149 | backups_client.BackupsClient, |
| 150 | volume_extensions_client.ExtensionsClient, |
| 151 | snapshots_client.SnapshotsClient, |
| 152 | volumes_client.VolumesClient, |
| 153 | volume_v2_hosts_client.VolumeHostsV2Client, |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 154 | volume_v2_quotas_client.VolumeQuotasV2Client, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame^] | 155 | volume_v2_services_client.VolumesServicesV2Client, |
| 156 | volume_v2_types_client.VolumeTypesV2Client, |
| 157 | volume_v2_az_client.VolumeV2AvailabilityZoneClient, |
| 158 | volume_v2_backups_client.BackupsClientV2, |
| 159 | volume_v2_extensions_client.ExtensionsV2Client, |
| 160 | volume_v2_qos_client.QosSpecsV2Client, |
| 161 | volume_v2_snapshots_client.SnapshotsV2Client, |
| 162 | volume_v2_volumes_client.VolumesV2Client, |
| 163 | identity_v2_identity_client.IdentityClient, |
| 164 | credentials_client.CredentialsClient, |
| 165 | endpoints_client.EndPointClient, |
| 166 | identity_v3_identity_client.IdentityV3Client, |
| 167 | policy_client.PolicyClient, |
| 168 | region_client.RegionClient, |
| 169 | service_client.ServiceClient, |
| 170 | image_client.ImageClient, |
| 171 | image_v2_client.ImageClientV2 |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 172 | ] |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 173 | |
| 174 | for client in test_clients: |
| 175 | fake_string = six.text_type(random.randint(1, 0x7fffffff)) |
| 176 | auth = 'auth' + fake_string |
| 177 | service = 'service' + fake_string |
| 178 | region = 'region' + fake_string |
| 179 | params = { |
| 180 | 'endpoint_type': 'URL' + fake_string, |
| 181 | 'build_interval': random.randint(1, 100), |
| 182 | 'build_timeout': random.randint(1, 100), |
| 183 | 'disable_ssl_certificate_validation': |
| 184 | True if random.randint(0, 1) else False, |
| 185 | 'ca_certs': None, |
| 186 | 'trace_requests': 'foo' + fake_string |
| 187 | } |
| 188 | client(auth, service, region, **params) |
| 189 | mock_init.assert_called_once_with(auth, service, region, **params) |
| 190 | mock_init.reset_mock() |