blob: 3de7aba5b43db556073a44dc6ee428c2343e8568 [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
27from tempest.services.compute.json import floating_ips_client
28from tempest.services.compute.json import hosts_client
29from tempest.services.compute.json import hypervisor_client
30from tempest.services.compute.json import images_client
31from tempest.services.compute.json import instance_usage_audit_log_client
32from tempest.services.compute.json import interfaces_client
33from tempest.services.compute.json import keypairs_client
34from tempest.services.compute.json import limits_client
35from tempest.services.compute.json import migrations_client
36from tempest.services.compute.json import networks_client as nova_net_client
Ken'ichi Ohmichia89dd6b2015-06-15 05:25:14 +000037from tempest.services.compute.json import quota_classes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000038from tempest.services.compute.json import quotas_client
39from tempest.services.compute.json import security_group_default_rules_client \
40 as nova_secgrop_default_client
41from tempest.services.compute.json import security_groups_client
42from tempest.services.compute.json import servers_client
43from tempest.services.compute.json import services_client
44from tempest.services.compute.json import tenant_usages_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000045from tempest.services.compute.json import volumes_extensions_client \
46 as compute_volumes_extensions_client
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000047from tempest.services.data_processing.v1_1 import data_processing_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000048from tempest.services.database.json import flavors_client as db_flavor_client
49from tempest.services.database.json import versions_client as db_version_client
Jamie Lennoxc429e6a2015-02-24 10:42:42 +110050from tempest.services.identity.v2.json import identity_client as \
ghanshyamd26b5cd2015-02-09 14:48:58 +090051 identity_v2_identity_client
52from tempest.services.identity.v3.json import credentials_client
53from tempest.services.identity.v3.json import endpoints_client
54from tempest.services.identity.v3.json import identity_client as \
55 identity_v3_identity_client
56from tempest.services.identity.v3.json import policy_client
57from tempest.services.identity.v3.json import region_client
58from tempest.services.identity.v3.json import service_client
Masayuki Igawabc7e1892015-03-03 11:46:48 +090059from tempest.services.image.v1.json import image_client
60from tempest.services.image.v2.json import image_client as image_v2_client
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +000061from tempest.services.messaging.json import messaging_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000062from tempest.services.network.json import network_client
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000063from tempest.services.object_storage import account_client
64from tempest.services.object_storage import container_client
65from tempest.services.object_storage import object_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000066from tempest.services.orchestration.json import orchestration_client
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000067from tempest.services.telemetry.json import telemetry_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000068from tempest.services.volume.json.admin import volume_hosts_client
69from tempest.services.volume.json.admin import volume_quotas_client
70from tempest.services.volume.json.admin import volume_services_client
71from tempest.services.volume.json.admin import volume_types_client
72from tempest.services.volume.json import availability_zone_client \
73 as volume_az_client
74from tempest.services.volume.json import backups_client
75from tempest.services.volume.json import extensions_client \
76 as volume_extensions_client
77from tempest.services.volume.json import qos_client
78from tempest.services.volume.json import snapshots_client
79from tempest.services.volume.json import volumes_client
80from tempest.services.volume.v2.json.admin import volume_hosts_client \
81 as volume_v2_hosts_client
82from tempest.services.volume.v2.json.admin import volume_quotas_client \
83 as volume_v2_quotas_client
84from tempest.services.volume.v2.json.admin import volume_services_client \
85 as volume_v2_services_client
86from tempest.services.volume.v2.json.admin import volume_types_client \
87 as volume_v2_types_client
88from tempest.services.volume.v2.json import availability_zone_client \
89 as volume_v2_az_client
90from tempest.services.volume.v2.json import backups_client \
91 as volume_v2_backups_client
92from tempest.services.volume.v2.json import extensions_client \
93 as volume_v2_extensions_client
94from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client
95from tempest.services.volume.v2.json import snapshots_client \
96 as volume_v2_snapshots_client
97from tempest.services.volume.v2.json import volumes_client as \
98 volume_v2_volumes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000099from tempest.tests import base
100
101
102class 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 Ohmichia6287072015-07-02 02:43:15 +0000107 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 Ohmichi4e83b5e2015-02-13 04:07:34 +0000133 data_processing_client.DataProcessingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000134 db_flavor_client.DatabaseFlavorsClient,
135 db_version_client.DatabaseVersionsClient,
136 messaging_client.MessagingClient,
137 network_client.NetworkClient,
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +0000138 account_client.AccountClient,
139 container_client.ContainerClient,
140 object_client.ObjectClient,
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +0000141 orchestration_client.OrchestrationClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000142 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 Ohmichif85e9bd2015-01-27 12:51:47 +0000154 volume_v2_quotas_client.VolumeQuotasV2Client,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000155 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 Ohmichif85e9bd2015-01-27 12:51:47 +0000172 ]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000173
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()