blob: afe4abc49843e9eaa3de60ae5b235651fc6c5f9e [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
37from tempest.services.compute.json import quotas_client
38from tempest.services.compute.json import security_group_default_rules_client \
39 as nova_secgrop_default_client
40from tempest.services.compute.json import security_groups_client
41from tempest.services.compute.json import servers_client
42from tempest.services.compute.json import services_client
43from tempest.services.compute.json import tenant_usages_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000044from tempest.services.compute.json import volumes_extensions_client \
45 as compute_volumes_extensions_client
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000046from tempest.services.data_processing.v1_1 import data_processing_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000047from tempest.services.database.json import flavors_client as db_flavor_client
48from tempest.services.database.json import versions_client as db_version_client
ghanshyamd26b5cd2015-02-09 14:48:58 +090049from tempest.services.identity.json import identity_client as \
50 identity_v2_identity_client
51from tempest.services.identity.v3.json import credentials_client
52from tempest.services.identity.v3.json import endpoints_client
53from tempest.services.identity.v3.json import identity_client as \
54 identity_v3_identity_client
55from tempest.services.identity.v3.json import policy_client
56from tempest.services.identity.v3.json import region_client
57from tempest.services.identity.v3.json import service_client
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +000058from tempest.services.messaging.json import messaging_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000059from tempest.services.network.json import network_client
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000060from tempest.services.object_storage import account_client
61from tempest.services.object_storage import container_client
62from tempest.services.object_storage import object_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000063from tempest.services.orchestration.json import orchestration_client
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000064from tempest.services.telemetry.json import telemetry_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000065from tempest.services.volume.json.admin import volume_hosts_client
66from tempest.services.volume.json.admin import volume_quotas_client
67from tempest.services.volume.json.admin import volume_services_client
68from tempest.services.volume.json.admin import volume_types_client
69from tempest.services.volume.json import availability_zone_client \
70 as volume_az_client
71from tempest.services.volume.json import backups_client
72from tempest.services.volume.json import extensions_client \
73 as volume_extensions_client
74from tempest.services.volume.json import qos_client
75from tempest.services.volume.json import snapshots_client
76from tempest.services.volume.json import volumes_client
77from tempest.services.volume.v2.json.admin import volume_hosts_client \
78 as volume_v2_hosts_client
79from tempest.services.volume.v2.json.admin import volume_quotas_client \
80 as volume_v2_quotas_client
81from tempest.services.volume.v2.json.admin import volume_services_client \
82 as volume_v2_services_client
83from tempest.services.volume.v2.json.admin import volume_types_client \
84 as volume_v2_types_client
85from tempest.services.volume.v2.json import availability_zone_client \
86 as volume_v2_az_client
87from tempest.services.volume.v2.json import backups_client \
88 as volume_v2_backups_client
89from tempest.services.volume.v2.json import extensions_client \
90 as volume_v2_extensions_client
91from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client
92from tempest.services.volume.v2.json import snapshots_client \
93 as volume_v2_snapshots_client
94from tempest.services.volume.v2.json import volumes_client as \
95 volume_v2_volumes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000096from tempest.tests import base
97
98
99class TestServiceClient(base.TestCase):
100
101 @mock.patch('tempest_lib.common.rest_client.RestClient.__init__')
102 def test_service_client_creations_with_specified_args(self, mock_init):
103 test_clients = [
Ken'ichi Ohmichi1f88ece2015-01-23 03:33:11 +0000104 baremetal_client.BaremetalClientJSON,
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000105 agents_client.AgentsClientJSON,
106 aggregates_client.AggregatesClientJSON,
107 availability_zone_client.AvailabilityZoneClientJSON,
108 certificates_client.CertificatesClientJSON,
109 extensions_client.ExtensionsClientJSON,
110 fixed_ips_client.FixedIPsClientJSON,
111 flavors_client.FlavorsClientJSON,
112 floating_ips_client.FloatingIPsClientJSON,
113 hosts_client.HostsClientJSON,
114 hypervisor_client.HypervisorClientJSON,
115 images_client.ImagesClientJSON,
116 instance_usage_audit_log_client.InstanceUsagesAuditLogClientJSON,
117 interfaces_client.InterfacesClientJSON,
118 keypairs_client.KeyPairsClientJSON,
119 limits_client.LimitsClientJSON,
120 migrations_client.MigrationsClientJSON,
121 nova_net_client.NetworksClientJSON,
122 quotas_client.QuotasClientJSON,
123 quotas_client.QuotaClassesClientJSON,
124 nova_secgrop_default_client.SecurityGroupDefaultRulesClientJSON,
125 security_groups_client.SecurityGroupsClientJSON,
126 servers_client.ServersClientJSON,
127 services_client.ServicesClientJSON,
128 tenant_usages_client.TenantUsagesClientJSON,
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000129 compute_volumes_extensions_client.VolumesExtensionsClientJSON,
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +0000130 data_processing_client.DataProcessingClient,
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000131 db_flavor_client.DatabaseFlavorsClientJSON,
132 db_version_client.DatabaseVersionsClientJSON,
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +0000133 messaging_client.MessagingClientJSON,
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000134 network_client.NetworkClientJSON,
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +0000135 account_client.AccountClient,
136 container_client.ContainerClient,
137 object_client.ObjectClient,
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +0000138 orchestration_client.OrchestrationClient,
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000139 telemetry_client.TelemetryClientJSON,
140 qos_client.QosSpecsClientJSON,
141 volume_hosts_client.VolumeHostsClientJSON,
142 volume_quotas_client.VolumeQuotasClientJSON,
143 volume_services_client.VolumesServicesClientJSON,
144 volume_types_client.VolumeTypesClientJSON,
145 volume_az_client.VolumeAvailabilityZoneClientJSON,
146 backups_client.BackupsClientJSON,
147 volume_extensions_client.ExtensionsClientJSON,
148 snapshots_client.SnapshotsClientJSON,
149 volumes_client.VolumesClientJSON,
150 volume_v2_hosts_client.VolumeHostsV2ClientJSON,
151 volume_v2_quotas_client.VolumeQuotasV2Client,
152 volume_v2_services_client.VolumesServicesV2ClientJSON,
153 volume_v2_types_client.VolumeTypesV2ClientJSON,
154 volume_v2_az_client.VolumeV2AvailabilityZoneClientJSON,
155 volume_v2_backups_client.BackupsClientV2JSON,
156 volume_v2_extensions_client.ExtensionsV2ClientJSON,
157 volume_v2_qos_client.QosSpecsV2ClientJSON,
158 volume_v2_snapshots_client.SnapshotsV2ClientJSON,
159 volume_v2_volumes_client.VolumesV2ClientJSON,
ghanshyamd26b5cd2015-02-09 14:48:58 +0900160 identity_v2_identity_client.IdentityClientJSON,
161 credentials_client.CredentialsClientJSON,
162 endpoints_client.EndPointClientJSON,
163 identity_v3_identity_client.IdentityV3ClientJSON,
164 policy_client.PolicyClientJSON,
165 region_client.RegionClientJSON,
166 service_client.ServiceClientJSON
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000167 ]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000168
169 for client in test_clients:
170 fake_string = six.text_type(random.randint(1, 0x7fffffff))
171 auth = 'auth' + fake_string
172 service = 'service' + fake_string
173 region = 'region' + fake_string
174 params = {
175 'endpoint_type': 'URL' + fake_string,
176 'build_interval': random.randint(1, 100),
177 'build_timeout': random.randint(1, 100),
178 'disable_ssl_certificate_validation':
179 True if random.randint(0, 1) else False,
180 'ca_certs': None,
181 'trace_requests': 'foo' + fake_string
182 }
183 client(auth, service, region, **params)
184 mock_init.assert_called_once_with(auth, service, region, **params)
185 mock_init.reset_mock()