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