blob: 8de014f6dd13c0f316f4e50a201c641d7327e384 [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 Ohmichi685cd172015-07-13 01:29:57 +000022from tempest.services.compute.json import security_group_rules_client
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +000023from tempest.services.compute.json import server_groups_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000024from tempest.services.compute.json import servers_client
Ken'ichi Ohmichiea3f26a2015-09-29 00:18:39 +000025from tempest.services.compute.json import volumes_client \
26 as compute_volumes_client
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000027from tempest.services.data_processing.v1_1 import data_processing_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000028from tempest.services.database.json import flavors_client as db_flavor_client
29from tempest.services.database.json import versions_client as db_version_client
Jamie Lennoxc429e6a2015-02-24 10:42:42 +110030from tempest.services.identity.v2.json import identity_client as \
ghanshyamd26b5cd2015-02-09 14:48:58 +090031 identity_v2_identity_client
32from tempest.services.identity.v3.json import credentials_client
33from tempest.services.identity.v3.json import endpoints_client
34from tempest.services.identity.v3.json import identity_client as \
35 identity_v3_identity_client
36from tempest.services.identity.v3.json import policy_client
37from tempest.services.identity.v3.json import region_client
38from tempest.services.identity.v3.json import service_client
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +000039from tempest.services.image.v1.json import images_client
40from tempest.services.image.v2.json import images_client as images_v2_client
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +000041from tempest.services.messaging.json import messaging_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000042from tempest.services.network.json import network_client
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000043from tempest.services.object_storage import account_client
44from tempest.services.object_storage import container_client
45from tempest.services.object_storage import object_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000046from tempest.services.orchestration.json import orchestration_client
liu-sheng67b730e2015-07-16 15:19:33 +080047from tempest.services.telemetry.json import alarming_client
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000048from tempest.services.telemetry.json import telemetry_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030049from tempest.services.volume.v1.json.admin import volume_hosts_client
50from tempest.services.volume.v1.json.admin import volume_quotas_client
51from tempest.services.volume.v1.json.admin import volume_services_client
52from tempest.services.volume.v1.json.admin import volume_types_client
53from tempest.services.volume.v1.json import availability_zone_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000054 as volume_az_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030055from tempest.services.volume.v1.json import backups_client
56from tempest.services.volume.v1.json import extensions_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000057 as volume_extensions_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030058from tempest.services.volume.v1.json import qos_client
59from tempest.services.volume.v1.json import snapshots_client
60from tempest.services.volume.v1.json import volumes_client
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000061from tempest.services.volume.v2.json.admin import volume_hosts_client \
62 as volume_v2_hosts_client
63from tempest.services.volume.v2.json.admin import volume_quotas_client \
64 as volume_v2_quotas_client
65from tempest.services.volume.v2.json.admin import volume_services_client \
66 as volume_v2_services_client
67from tempest.services.volume.v2.json.admin import volume_types_client \
68 as volume_v2_types_client
69from tempest.services.volume.v2.json import availability_zone_client \
70 as volume_v2_az_client
71from tempest.services.volume.v2.json import backups_client \
72 as volume_v2_backups_client
73from tempest.services.volume.v2.json import extensions_client \
74 as volume_v2_extensions_client
75from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client
76from tempest.services.volume.v2.json import snapshots_client \
77 as volume_v2_snapshots_client
78from tempest.services.volume.v2.json import volumes_client as \
79 volume_v2_volumes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000080from tempest.tests import base
81
82
83class TestServiceClient(base.TestCase):
84
85 @mock.patch('tempest_lib.common.rest_client.RestClient.__init__')
86 def test_service_client_creations_with_specified_args(self, mock_init):
87 test_clients = [
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000088 baremetal_client.BaremetalClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000089 floating_ips_client.FloatingIPsClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000090 interfaces_client.InterfacesClient,
Ken'ichi Ohmichi685cd172015-07-13 01:29:57 +000091 security_group_rules_client.SecurityGroupRulesClient,
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +000092 server_groups_client.ServerGroupsClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000093 servers_client.ServersClient,
Ken'ichi Ohmichiea3f26a2015-09-29 00:18:39 +000094 compute_volumes_client.VolumesClient,
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000095 data_processing_client.DataProcessingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000096 db_flavor_client.DatabaseFlavorsClient,
97 db_version_client.DatabaseVersionsClient,
98 messaging_client.MessagingClient,
99 network_client.NetworkClient,
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +0000100 account_client.AccountClient,
101 container_client.ContainerClient,
102 object_client.ObjectClient,
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +0000103 orchestration_client.OrchestrationClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000104 telemetry_client.TelemetryClient,
liu-sheng67b730e2015-07-16 15:19:33 +0800105 alarming_client.AlarmingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000106 qos_client.QosSpecsClient,
107 volume_hosts_client.VolumeHostsClient,
108 volume_quotas_client.VolumeQuotasClient,
109 volume_services_client.VolumesServicesClient,
110 volume_types_client.VolumeTypesClient,
111 volume_az_client.VolumeAvailabilityZoneClient,
112 backups_client.BackupsClient,
113 volume_extensions_client.ExtensionsClient,
114 snapshots_client.SnapshotsClient,
115 volumes_client.VolumesClient,
116 volume_v2_hosts_client.VolumeHostsV2Client,
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000117 volume_v2_quotas_client.VolumeQuotasV2Client,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000118 volume_v2_services_client.VolumesServicesV2Client,
119 volume_v2_types_client.VolumeTypesV2Client,
120 volume_v2_az_client.VolumeV2AvailabilityZoneClient,
121 volume_v2_backups_client.BackupsClientV2,
122 volume_v2_extensions_client.ExtensionsV2Client,
123 volume_v2_qos_client.QosSpecsV2Client,
124 volume_v2_snapshots_client.SnapshotsV2Client,
125 volume_v2_volumes_client.VolumesV2Client,
126 identity_v2_identity_client.IdentityClient,
127 credentials_client.CredentialsClient,
128 endpoints_client.EndPointClient,
129 identity_v3_identity_client.IdentityV3Client,
130 policy_client.PolicyClient,
131 region_client.RegionClient,
132 service_client.ServiceClient,
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +0000133 images_client.ImagesClient,
134 images_v2_client.ImagesClientV2
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000135 ]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000136
137 for client in test_clients:
138 fake_string = six.text_type(random.randint(1, 0x7fffffff))
139 auth = 'auth' + fake_string
140 service = 'service' + fake_string
141 region = 'region' + fake_string
142 params = {
143 'endpoint_type': 'URL' + fake_string,
144 'build_interval': random.randint(1, 100),
145 'build_timeout': random.randint(1, 100),
146 'disable_ssl_certificate_validation':
147 True if random.randint(0, 1) else False,
148 'ca_certs': None,
149 'trace_requests': 'foo' + fake_string
150 }
151 client(auth, service, region, **params)
152 mock_init.assert_called_once_with(auth, service, region, **params)
153 mock_init.reset_mock()