blob: 4225da84f58f91f0a3f26983912c28be38cec21d [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 floating_ips_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000021from tempest.services.compute.json import interfaces_client
Ken'ichi Ohmichia89dd6b2015-06-15 05:25:14 +000022from tempest.services.compute.json import quota_classes_client
Ken'ichi Ohmichi685cd172015-07-13 01:29:57 +000023from tempest.services.compute.json import security_group_rules_client
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +000024from tempest.services.compute.json import server_groups_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000025from tempest.services.compute.json import servers_client
26from tempest.services.compute.json import services_client
Ken'ichi Ohmichiea3f26a2015-09-29 00:18:39 +000027from tempest.services.compute.json import volumes_client \
28 as compute_volumes_client
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000029from tempest.services.data_processing.v1_1 import data_processing_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000030from tempest.services.database.json import flavors_client as db_flavor_client
31from tempest.services.database.json import versions_client as db_version_client
Jamie Lennoxc429e6a2015-02-24 10:42:42 +110032from tempest.services.identity.v2.json import identity_client as \
ghanshyamd26b5cd2015-02-09 14:48:58 +090033 identity_v2_identity_client
34from tempest.services.identity.v3.json import credentials_client
35from tempest.services.identity.v3.json import endpoints_client
36from tempest.services.identity.v3.json import identity_client as \
37 identity_v3_identity_client
38from tempest.services.identity.v3.json import policy_client
39from tempest.services.identity.v3.json import region_client
40from tempest.services.identity.v3.json import service_client
Masayuki Igawabc7e1892015-03-03 11:46:48 +090041from tempest.services.image.v1.json import image_client
42from tempest.services.image.v2.json import image_client as image_v2_client
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +000043from tempest.services.messaging.json import messaging_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000044from tempest.services.network.json import network_client
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000045from tempest.services.object_storage import account_client
46from tempest.services.object_storage import container_client
47from tempest.services.object_storage import object_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000048from tempest.services.orchestration.json import orchestration_client
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000049from tempest.services.telemetry.json import telemetry_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000050from tempest.services.volume.json.admin import volume_hosts_client
51from tempest.services.volume.json.admin import volume_quotas_client
52from tempest.services.volume.json.admin import volume_services_client
53from tempest.services.volume.json.admin import volume_types_client
54from tempest.services.volume.json import availability_zone_client \
55 as volume_az_client
56from tempest.services.volume.json import backups_client
57from tempest.services.volume.json import extensions_client \
58 as volume_extensions_client
59from tempest.services.volume.json import qos_client
60from tempest.services.volume.json import snapshots_client
61from tempest.services.volume.json import volumes_client
62from tempest.services.volume.v2.json.admin import volume_hosts_client \
63 as volume_v2_hosts_client
64from tempest.services.volume.v2.json.admin import volume_quotas_client \
65 as volume_v2_quotas_client
66from tempest.services.volume.v2.json.admin import volume_services_client \
67 as volume_v2_services_client
68from tempest.services.volume.v2.json.admin import volume_types_client \
69 as volume_v2_types_client
70from tempest.services.volume.v2.json import availability_zone_client \
71 as volume_v2_az_client
72from tempest.services.volume.v2.json import backups_client \
73 as volume_v2_backups_client
74from tempest.services.volume.v2.json import extensions_client \
75 as volume_v2_extensions_client
76from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client
77from tempest.services.volume.v2.json import snapshots_client \
78 as volume_v2_snapshots_client
79from tempest.services.volume.v2.json import volumes_client as \
80 volume_v2_volumes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000081from tempest.tests import base
82
83
84class TestServiceClient(base.TestCase):
85
86 @mock.patch('tempest_lib.common.rest_client.RestClient.__init__')
87 def test_service_client_creations_with_specified_args(self, mock_init):
88 test_clients = [
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000089 baremetal_client.BaremetalClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000090 floating_ips_client.FloatingIPsClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000091 interfaces_client.InterfacesClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000092 quota_classes_client.QuotaClassesClient,
Ken'ichi Ohmichi685cd172015-07-13 01:29:57 +000093 security_group_rules_client.SecurityGroupRulesClient,
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +000094 server_groups_client.ServerGroupsClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000095 servers_client.ServersClient,
96 services_client.ServicesClient,
Ken'ichi Ohmichiea3f26a2015-09-29 00:18:39 +000097 compute_volumes_client.VolumesClient,
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000098 data_processing_client.DataProcessingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000099 db_flavor_client.DatabaseFlavorsClient,
100 db_version_client.DatabaseVersionsClient,
101 messaging_client.MessagingClient,
102 network_client.NetworkClient,
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +0000103 account_client.AccountClient,
104 container_client.ContainerClient,
105 object_client.ObjectClient,
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +0000106 orchestration_client.OrchestrationClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000107 telemetry_client.TelemetryClient,
108 qos_client.QosSpecsClient,
109 volume_hosts_client.VolumeHostsClient,
110 volume_quotas_client.VolumeQuotasClient,
111 volume_services_client.VolumesServicesClient,
112 volume_types_client.VolumeTypesClient,
113 volume_az_client.VolumeAvailabilityZoneClient,
114 backups_client.BackupsClient,
115 volume_extensions_client.ExtensionsClient,
116 snapshots_client.SnapshotsClient,
117 volumes_client.VolumesClient,
118 volume_v2_hosts_client.VolumeHostsV2Client,
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000119 volume_v2_quotas_client.VolumeQuotasV2Client,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000120 volume_v2_services_client.VolumesServicesV2Client,
121 volume_v2_types_client.VolumeTypesV2Client,
122 volume_v2_az_client.VolumeV2AvailabilityZoneClient,
123 volume_v2_backups_client.BackupsClientV2,
124 volume_v2_extensions_client.ExtensionsV2Client,
125 volume_v2_qos_client.QosSpecsV2Client,
126 volume_v2_snapshots_client.SnapshotsV2Client,
127 volume_v2_volumes_client.VolumesV2Client,
128 identity_v2_identity_client.IdentityClient,
129 credentials_client.CredentialsClient,
130 endpoints_client.EndPointClient,
131 identity_v3_identity_client.IdentityV3Client,
132 policy_client.PolicyClient,
133 region_client.RegionClient,
134 service_client.ServiceClient,
135 image_client.ImageClient,
136 image_v2_client.ImageClientV2
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000137 ]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000138
139 for client in test_clients:
140 fake_string = six.text_type(random.randint(1, 0x7fffffff))
141 auth = 'auth' + fake_string
142 service = 'service' + fake_string
143 region = 'region' + fake_string
144 params = {
145 'endpoint_type': 'URL' + fake_string,
146 'build_interval': random.randint(1, 100),
147 'build_timeout': random.randint(1, 100),
148 'disable_ssl_certificate_validation':
149 True if random.randint(0, 1) else False,
150 'ca_certs': None,
151 'trace_requests': 'foo' + fake_string
152 }
153 client(auth, service, region, **params)
154 mock_init.assert_called_once_with(auth, service, region, **params)
155 mock_init.reset_mock()