blob: 443b67e5049dfc63b8e1aca5614bee2790da49a9 [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
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +000049from tempest.services.messaging.json import messaging_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000050from tempest.services.network.json import network_client
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000051from tempest.services.object_storage import account_client
52from tempest.services.object_storage import container_client
53from tempest.services.object_storage import object_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000054from tempest.services.orchestration.json import orchestration_client
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000055from tempest.services.telemetry.json import telemetry_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000056from tempest.services.volume.json.admin import volume_hosts_client
57from tempest.services.volume.json.admin import volume_quotas_client
58from tempest.services.volume.json.admin import volume_services_client
59from tempest.services.volume.json.admin import volume_types_client
60from tempest.services.volume.json import availability_zone_client \
61 as volume_az_client
62from tempest.services.volume.json import backups_client
63from tempest.services.volume.json import extensions_client \
64 as volume_extensions_client
65from tempest.services.volume.json import qos_client
66from tempest.services.volume.json import snapshots_client
67from tempest.services.volume.json import volumes_client
68from tempest.services.volume.v2.json.admin import volume_hosts_client \
69 as volume_v2_hosts_client
70from tempest.services.volume.v2.json.admin import volume_quotas_client \
71 as volume_v2_quotas_client
72from tempest.services.volume.v2.json.admin import volume_services_client \
73 as volume_v2_services_client
74from tempest.services.volume.v2.json.admin import volume_types_client \
75 as volume_v2_types_client
76from tempest.services.volume.v2.json import availability_zone_client \
77 as volume_v2_az_client
78from tempest.services.volume.v2.json import backups_client \
79 as volume_v2_backups_client
80from tempest.services.volume.v2.json import extensions_client \
81 as volume_v2_extensions_client
82from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client
83from tempest.services.volume.v2.json import snapshots_client \
84 as volume_v2_snapshots_client
85from tempest.services.volume.v2.json import volumes_client as \
86 volume_v2_volumes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000087from tempest.tests import base
88
89
90class TestServiceClient(base.TestCase):
91
92 @mock.patch('tempest_lib.common.rest_client.RestClient.__init__')
93 def test_service_client_creations_with_specified_args(self, mock_init):
94 test_clients = [
Ken'ichi Ohmichi1f88ece2015-01-23 03:33:11 +000095 baremetal_client.BaremetalClientJSON,
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000096 agents_client.AgentsClientJSON,
97 aggregates_client.AggregatesClientJSON,
98 availability_zone_client.AvailabilityZoneClientJSON,
99 certificates_client.CertificatesClientJSON,
100 extensions_client.ExtensionsClientJSON,
101 fixed_ips_client.FixedIPsClientJSON,
102 flavors_client.FlavorsClientJSON,
103 floating_ips_client.FloatingIPsClientJSON,
104 hosts_client.HostsClientJSON,
105 hypervisor_client.HypervisorClientJSON,
106 images_client.ImagesClientJSON,
107 instance_usage_audit_log_client.InstanceUsagesAuditLogClientJSON,
108 interfaces_client.InterfacesClientJSON,
109 keypairs_client.KeyPairsClientJSON,
110 limits_client.LimitsClientJSON,
111 migrations_client.MigrationsClientJSON,
112 nova_net_client.NetworksClientJSON,
113 quotas_client.QuotasClientJSON,
114 quotas_client.QuotaClassesClientJSON,
115 nova_secgrop_default_client.SecurityGroupDefaultRulesClientJSON,
116 security_groups_client.SecurityGroupsClientJSON,
117 servers_client.ServersClientJSON,
118 services_client.ServicesClientJSON,
119 tenant_usages_client.TenantUsagesClientJSON,
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000120 compute_volumes_extensions_client.VolumesExtensionsClientJSON,
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +0000121 data_processing_client.DataProcessingClient,
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000122 db_flavor_client.DatabaseFlavorsClientJSON,
123 db_version_client.DatabaseVersionsClientJSON,
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +0000124 messaging_client.MessagingClientJSON,
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000125 network_client.NetworkClientJSON,
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +0000126 account_client.AccountClient,
127 container_client.ContainerClient,
128 object_client.ObjectClient,
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +0000129 orchestration_client.OrchestrationClient,
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000130 telemetry_client.TelemetryClientJSON,
131 qos_client.QosSpecsClientJSON,
132 volume_hosts_client.VolumeHostsClientJSON,
133 volume_quotas_client.VolumeQuotasClientJSON,
134 volume_services_client.VolumesServicesClientJSON,
135 volume_types_client.VolumeTypesClientJSON,
136 volume_az_client.VolumeAvailabilityZoneClientJSON,
137 backups_client.BackupsClientJSON,
138 volume_extensions_client.ExtensionsClientJSON,
139 snapshots_client.SnapshotsClientJSON,
140 volumes_client.VolumesClientJSON,
141 volume_v2_hosts_client.VolumeHostsV2ClientJSON,
142 volume_v2_quotas_client.VolumeQuotasV2Client,
143 volume_v2_services_client.VolumesServicesV2ClientJSON,
144 volume_v2_types_client.VolumeTypesV2ClientJSON,
145 volume_v2_az_client.VolumeV2AvailabilityZoneClientJSON,
146 volume_v2_backups_client.BackupsClientV2JSON,
147 volume_v2_extensions_client.ExtensionsV2ClientJSON,
148 volume_v2_qos_client.QosSpecsV2ClientJSON,
149 volume_v2_snapshots_client.SnapshotsV2ClientJSON,
150 volume_v2_volumes_client.VolumesV2ClientJSON,
151 ]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000152
153 for client in test_clients:
154 fake_string = six.text_type(random.randint(1, 0x7fffffff))
155 auth = 'auth' + fake_string
156 service = 'service' + fake_string
157 region = 'region' + fake_string
158 params = {
159 'endpoint_type': 'URL' + fake_string,
160 'build_interval': random.randint(1, 100),
161 'build_timeout': random.randint(1, 100),
162 'disable_ssl_certificate_validation':
163 True if random.randint(0, 1) else False,
164 'ca_certs': None,
165 'trace_requests': 'foo' + fake_string
166 }
167 client(auth, service, region, **params)
168 mock_init.assert_called_once_with(auth, service, region, **params)
169 mock_init.reset_mock()