blob: 3a0873c02e84fef1502fd48b1528c9ee198d65c1 [file] [log] [blame]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +00001# 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
15import mock
16import random
17import six
18
Ken'ichi Ohmichi1f88ece2015-01-23 03:33:11 +000019from tempest.services.baremetal.v1.json import baremetal_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000020from tempest.services.compute.json import agents_client
21from tempest.services.compute.json import aggregates_client
22from tempest.services.compute.json import availability_zone_client
23from tempest.services.compute.json import certificates_client
24from tempest.services.compute.json import extensions_client
25from tempest.services.compute.json import fixed_ips_client
26from tempest.services.compute.json import flavors_client
Ken'ichi Ohmichi03af1c52015-07-13 00:28:05 +000027from tempest.services.compute.json import floating_ip_pools_client
Ken'ichi Ohmichi2b26e752015-07-13 00:44:36 +000028from tempest.services.compute.json import floating_ips_bulk_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000029from tempest.services.compute.json import floating_ips_client
30from tempest.services.compute.json import hosts_client
31from tempest.services.compute.json import hypervisor_client
32from tempest.services.compute.json import images_client
33from tempest.services.compute.json import instance_usage_audit_log_client
34from tempest.services.compute.json import interfaces_client
35from tempest.services.compute.json import keypairs_client
36from tempest.services.compute.json import limits_client
37from tempest.services.compute.json import migrations_client
38from tempest.services.compute.json import networks_client as nova_net_client
Ken'ichi Ohmichia89dd6b2015-06-15 05:25:14 +000039from tempest.services.compute.json import quota_classes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000040from tempest.services.compute.json import quotas_client
41from tempest.services.compute.json import security_group_default_rules_client \
42 as nova_secgrop_default_client
Ken'ichi Ohmichi685cd172015-07-13 01:29:57 +000043from tempest.services.compute.json import security_group_rules_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000044from tempest.services.compute.json import security_groups_client
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +000045from tempest.services.compute.json import server_groups_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000046from tempest.services.compute.json import servers_client
47from tempest.services.compute.json import services_client
48from tempest.services.compute.json import tenant_usages_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000049from tempest.services.compute.json import volumes_extensions_client \
50 as compute_volumes_extensions_client
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000051from tempest.services.data_processing.v1_1 import data_processing_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000052from tempest.services.database.json import flavors_client as db_flavor_client
53from tempest.services.database.json import versions_client as db_version_client
Jamie Lennoxc429e6a2015-02-24 10:42:42 +110054from tempest.services.identity.v2.json import identity_client as \
ghanshyamd26b5cd2015-02-09 14:48:58 +090055 identity_v2_identity_client
56from tempest.services.identity.v3.json import credentials_client
57from tempest.services.identity.v3.json import endpoints_client
58from tempest.services.identity.v3.json import identity_client as \
59 identity_v3_identity_client
60from tempest.services.identity.v3.json import policy_client
61from tempest.services.identity.v3.json import region_client
62from tempest.services.identity.v3.json import service_client
Masayuki Igawabc7e1892015-03-03 11:46:48 +090063from tempest.services.image.v1.json import image_client
64from tempest.services.image.v2.json import image_client as image_v2_client
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +000065from tempest.services.messaging.json import messaging_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000066from tempest.services.network.json import network_client
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000067from tempest.services.object_storage import account_client
68from tempest.services.object_storage import container_client
69from tempest.services.object_storage import object_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000070from tempest.services.orchestration.json import orchestration_client
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000071from tempest.services.telemetry.json import telemetry_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000072from tempest.services.volume.json.admin import volume_hosts_client
73from tempest.services.volume.json.admin import volume_quotas_client
74from tempest.services.volume.json.admin import volume_services_client
75from tempest.services.volume.json.admin import volume_types_client
76from tempest.services.volume.json import availability_zone_client \
77 as volume_az_client
78from tempest.services.volume.json import backups_client
79from tempest.services.volume.json import extensions_client \
80 as volume_extensions_client
81from tempest.services.volume.json import qos_client
82from tempest.services.volume.json import snapshots_client
83from tempest.services.volume.json import volumes_client
84from tempest.services.volume.v2.json.admin import volume_hosts_client \
85 as volume_v2_hosts_client
86from tempest.services.volume.v2.json.admin import volume_quotas_client \
87 as volume_v2_quotas_client
88from tempest.services.volume.v2.json.admin import volume_services_client \
89 as volume_v2_services_client
90from tempest.services.volume.v2.json.admin import volume_types_client \
91 as volume_v2_types_client
92from tempest.services.volume.v2.json import availability_zone_client \
93 as volume_v2_az_client
94from tempest.services.volume.v2.json import backups_client \
95 as volume_v2_backups_client
96from tempest.services.volume.v2.json import extensions_client \
97 as volume_v2_extensions_client
98from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client
99from tempest.services.volume.v2.json import snapshots_client \
100 as volume_v2_snapshots_client
101from tempest.services.volume.v2.json import volumes_client as \
102 volume_v2_volumes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000103from tempest.tests import base
104
105
106class TestServiceClient(base.TestCase):
107
108 @mock.patch('tempest_lib.common.rest_client.RestClient.__init__')
109 def test_service_client_creations_with_specified_args(self, mock_init):
110 test_clients = [
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000111 baremetal_client.BaremetalClient,
112 agents_client.AgentsClient,
113 aggregates_client.AggregatesClient,
114 availability_zone_client.AvailabilityZoneClient,
115 certificates_client.CertificatesClient,
116 extensions_client.ExtensionsClient,
117 fixed_ips_client.FixedIPsClient,
118 flavors_client.FlavorsClient,
Ken'ichi Ohmichi03af1c52015-07-13 00:28:05 +0000119 floating_ip_pools_client.FloatingIpPoolsClient,
Ken'ichi Ohmichi2b26e752015-07-13 00:44:36 +0000120 floating_ips_bulk_client.FloatingIpsBulkClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000121 floating_ips_client.FloatingIPsClient,
122 hosts_client.HostsClient,
123 hypervisor_client.HypervisorClient,
124 images_client.ImagesClient,
125 instance_usage_audit_log_client.InstanceUsagesAuditLogClient,
126 interfaces_client.InterfacesClient,
127 keypairs_client.KeyPairsClient,
128 limits_client.LimitsClient,
129 migrations_client.MigrationsClient,
130 nova_net_client.NetworksClient,
131 quotas_client.QuotasClient,
132 quota_classes_client.QuotaClassesClient,
133 nova_secgrop_default_client.SecurityGroupDefaultRulesClient,
Ken'ichi Ohmichi685cd172015-07-13 01:29:57 +0000134 security_group_rules_client.SecurityGroupRulesClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000135 security_groups_client.SecurityGroupsClient,
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +0000136 server_groups_client.ServerGroupsClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000137 servers_client.ServersClient,
138 services_client.ServicesClient,
139 tenant_usages_client.TenantUsagesClient,
140 compute_volumes_extensions_client.VolumesExtensionsClient,
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +0000141 data_processing_client.DataProcessingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000142 db_flavor_client.DatabaseFlavorsClient,
143 db_version_client.DatabaseVersionsClient,
144 messaging_client.MessagingClient,
145 network_client.NetworkClient,
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +0000146 account_client.AccountClient,
147 container_client.ContainerClient,
148 object_client.ObjectClient,
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +0000149 orchestration_client.OrchestrationClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000150 telemetry_client.TelemetryClient,
151 qos_client.QosSpecsClient,
152 volume_hosts_client.VolumeHostsClient,
153 volume_quotas_client.VolumeQuotasClient,
154 volume_services_client.VolumesServicesClient,
155 volume_types_client.VolumeTypesClient,
156 volume_az_client.VolumeAvailabilityZoneClient,
157 backups_client.BackupsClient,
158 volume_extensions_client.ExtensionsClient,
159 snapshots_client.SnapshotsClient,
160 volumes_client.VolumesClient,
161 volume_v2_hosts_client.VolumeHostsV2Client,
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000162 volume_v2_quotas_client.VolumeQuotasV2Client,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000163 volume_v2_services_client.VolumesServicesV2Client,
164 volume_v2_types_client.VolumeTypesV2Client,
165 volume_v2_az_client.VolumeV2AvailabilityZoneClient,
166 volume_v2_backups_client.BackupsClientV2,
167 volume_v2_extensions_client.ExtensionsV2Client,
168 volume_v2_qos_client.QosSpecsV2Client,
169 volume_v2_snapshots_client.SnapshotsV2Client,
170 volume_v2_volumes_client.VolumesV2Client,
171 identity_v2_identity_client.IdentityClient,
172 credentials_client.CredentialsClient,
173 endpoints_client.EndPointClient,
174 identity_v3_identity_client.IdentityV3Client,
175 policy_client.PolicyClient,
176 region_client.RegionClient,
177 service_client.ServiceClient,
178 image_client.ImageClient,
179 image_v2_client.ImageClientV2
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000180 ]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000181
182 for client in test_clients:
183 fake_string = six.text_type(random.randint(1, 0x7fffffff))
184 auth = 'auth' + fake_string
185 service = 'service' + fake_string
186 region = 'region' + fake_string
187 params = {
188 'endpoint_type': 'URL' + fake_string,
189 'build_interval': random.randint(1, 100),
190 'build_timeout': random.randint(1, 100),
191 'disable_ssl_certificate_validation':
192 True if random.randint(0, 1) else False,
193 'ca_certs': None,
194 'trace_requests': 'foo' + fake_string
195 }
196 client(auth, service, region, **params)
197 mock_init.assert_called_once_with(auth, service, region, **params)
198 mock_init.reset_mock()