blob: 7e9ff9dbc6590e65840831ec619a42b4851e9548 [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 Ohmichi4e83b5e2015-02-13 04:07:34 +000020from tempest.services.data_processing.v1_1 import data_processing_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000021from tempest.services.database.json import flavors_client as db_flavor_client
22from tempest.services.database.json import versions_client as db_version_client
Jamie Lennoxc429e6a2015-02-24 10:42:42 +110023from tempest.services.identity.v2.json import identity_client as \
ghanshyamd26b5cd2015-02-09 14:48:58 +090024 identity_v2_identity_client
25from tempest.services.identity.v3.json import credentials_client
26from tempest.services.identity.v3.json import endpoints_client
27from tempest.services.identity.v3.json import identity_client as \
28 identity_v3_identity_client
Yaroslav Lobankoved4d15c2015-12-18 11:30:10 +030029from tempest.services.identity.v3.json import policies_client
Yaroslav Lobankov757d1a22015-12-18 11:43:02 +030030from tempest.services.identity.v3.json import regions_client
Yaroslav Lobankov69d90562015-12-18 12:06:40 +030031from tempest.services.identity.v3.json import services_client
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +000032from tempest.services.image.v1.json import images_client
33from tempest.services.image.v2.json import images_client as images_v2_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000034from tempest.services.network.json import network_client
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000035from tempest.services.object_storage import account_client
36from tempest.services.object_storage import container_client
37from tempest.services.object_storage import object_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000038from tempest.services.orchestration.json import orchestration_client
liu-sheng67b730e2015-07-16 15:19:33 +080039from tempest.services.telemetry.json import alarming_client
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000040from tempest.services.telemetry.json import telemetry_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030041from tempest.services.volume.v1.json.admin import hosts_client \
42 as volume_hosts_client
43from tempest.services.volume.v1.json.admin import quotas_client \
44 as volume_quotas_client
45from tempest.services.volume.v1.json.admin import services_client \
46 as volume_services_client
47from tempest.services.volume.v1.json.admin import types_client \
48 as volume_types_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030049from tempest.services.volume.v1.json import availability_zone_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000050 as volume_az_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030051from tempest.services.volume.v1.json import backups_client
52from tempest.services.volume.v1.json import extensions_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000053 as volume_extensions_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030054from tempest.services.volume.v1.json import qos_client
55from tempest.services.volume.v1.json import snapshots_client
56from tempest.services.volume.v1.json import volumes_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030057from tempest.services.volume.v2.json.admin import hosts_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000058 as volume_v2_hosts_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030059from tempest.services.volume.v2.json.admin import quotas_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000060 as volume_v2_quotas_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030061from tempest.services.volume.v2.json.admin import services_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000062 as volume_v2_services_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030063from tempest.services.volume.v2.json.admin import types_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000064 as volume_v2_types_client
65from tempest.services.volume.v2.json import availability_zone_client \
66 as volume_v2_az_client
67from tempest.services.volume.v2.json import backups_client \
68 as volume_v2_backups_client
69from tempest.services.volume.v2.json import extensions_client \
70 as volume_v2_extensions_client
71from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client
72from tempest.services.volume.v2.json import snapshots_client \
73 as volume_v2_snapshots_client
74from tempest.services.volume.v2.json import volumes_client as \
75 volume_v2_volumes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000076from tempest.tests import base
77
78
79class TestServiceClient(base.TestCase):
80
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050081 @mock.patch('tempest.lib.common.rest_client.RestClient.__init__')
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000082 def test_service_client_creations_with_specified_args(self, mock_init):
83 test_clients = [
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000084 baremetal_client.BaremetalClient,
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000085 data_processing_client.DataProcessingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000086 db_flavor_client.DatabaseFlavorsClient,
87 db_version_client.DatabaseVersionsClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000088 network_client.NetworkClient,
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000089 account_client.AccountClient,
90 container_client.ContainerClient,
91 object_client.ObjectClient,
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000092 orchestration_client.OrchestrationClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000093 telemetry_client.TelemetryClient,
liu-sheng67b730e2015-07-16 15:19:33 +080094 alarming_client.AlarmingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000095 qos_client.QosSpecsClient,
Yaroslav Lobankov4c237792015-12-02 18:43:48 +030096 volume_hosts_client.HostsClient,
97 volume_quotas_client.QuotasClient,
98 volume_services_client.ServicesClient,
99 volume_types_client.TypesClient,
100 volume_az_client.AvailabilityZoneClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000101 backups_client.BackupsClient,
102 volume_extensions_client.ExtensionsClient,
103 snapshots_client.SnapshotsClient,
104 volumes_client.VolumesClient,
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300105 volume_v2_hosts_client.HostsClient,
106 volume_v2_quotas_client.QuotasClient,
107 volume_v2_services_client.ServicesClient,
108 volume_v2_types_client.TypesClient,
109 volume_v2_az_client.AvailabilityZoneClient,
110 volume_v2_backups_client.BackupsClient,
111 volume_v2_extensions_client.ExtensionsClient,
112 volume_v2_qos_client.QosSpecsClient,
113 volume_v2_snapshots_client.SnapshotsClient,
114 volume_v2_volumes_client.VolumesClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000115 identity_v2_identity_client.IdentityClient,
116 credentials_client.CredentialsClient,
117 endpoints_client.EndPointClient,
118 identity_v3_identity_client.IdentityV3Client,
Yaroslav Lobankoved4d15c2015-12-18 11:30:10 +0300119 policies_client.PoliciesClient,
Yaroslav Lobankov757d1a22015-12-18 11:43:02 +0300120 regions_client.RegionsClient,
Yaroslav Lobankov69d90562015-12-18 12:06:40 +0300121 services_client.ServicesClient,
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +0000122 images_client.ImagesClient,
123 images_v2_client.ImagesClientV2
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000124 ]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000125
126 for client in test_clients:
127 fake_string = six.text_type(random.randint(1, 0x7fffffff))
128 auth = 'auth' + fake_string
129 service = 'service' + fake_string
130 region = 'region' + fake_string
131 params = {
132 'endpoint_type': 'URL' + fake_string,
133 'build_interval': random.randint(1, 100),
134 'build_timeout': random.randint(1, 100),
135 'disable_ssl_certificate_validation':
136 True if random.randint(0, 1) else False,
137 'ca_certs': None,
138 'trace_requests': 'foo' + fake_string
139 }
140 client(auth, service, region, **params)
141 mock_init.assert_called_once_with(auth, service, region, **params)
142 mock_init.reset_mock()