blob: f248957a375715c7681a4295ca66a47a10ee7ea3 [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 Ohmichi2183a652015-01-22 05:00:20 +000034from tempest.services.messaging.json import messaging_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000035from tempest.services.network.json import network_client
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000036from tempest.services.object_storage import account_client
37from tempest.services.object_storage import container_client
38from tempest.services.object_storage import object_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000039from tempest.services.orchestration.json import orchestration_client
liu-sheng67b730e2015-07-16 15:19:33 +080040from tempest.services.telemetry.json import alarming_client
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000041from tempest.services.telemetry.json import telemetry_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030042from tempest.services.volume.v1.json.admin import hosts_client \
43 as volume_hosts_client
44from tempest.services.volume.v1.json.admin import quotas_client \
45 as volume_quotas_client
46from tempest.services.volume.v1.json.admin import services_client \
47 as volume_services_client
48from tempest.services.volume.v1.json.admin import types_client \
49 as volume_types_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030050from tempest.services.volume.v1.json import availability_zone_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000051 as volume_az_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030052from tempest.services.volume.v1.json import backups_client
53from tempest.services.volume.v1.json import extensions_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000054 as volume_extensions_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030055from tempest.services.volume.v1.json import qos_client
56from tempest.services.volume.v1.json import snapshots_client
57from tempest.services.volume.v1.json import volumes_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030058from tempest.services.volume.v2.json.admin import hosts_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000059 as volume_v2_hosts_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030060from tempest.services.volume.v2.json.admin import quotas_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000061 as volume_v2_quotas_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030062from tempest.services.volume.v2.json.admin import services_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000063 as volume_v2_services_client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +030064from tempest.services.volume.v2.json.admin import types_client \
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +000065 as volume_v2_types_client
66from tempest.services.volume.v2.json import availability_zone_client \
67 as volume_v2_az_client
68from tempest.services.volume.v2.json import backups_client \
69 as volume_v2_backups_client
70from tempest.services.volume.v2.json import extensions_client \
71 as volume_v2_extensions_client
72from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client
73from tempest.services.volume.v2.json import snapshots_client \
74 as volume_v2_snapshots_client
75from tempest.services.volume.v2.json import volumes_client as \
76 volume_v2_volumes_client
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +000077from tempest.tests import base
78
79
80class TestServiceClient(base.TestCase):
81
82 @mock.patch('tempest_lib.common.rest_client.RestClient.__init__')
83 def test_service_client_creations_with_specified_args(self, mock_init):
84 test_clients = [
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000085 baremetal_client.BaremetalClient,
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +000086 data_processing_client.DataProcessingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000087 db_flavor_client.DatabaseFlavorsClient,
88 db_version_client.DatabaseVersionsClient,
89 messaging_client.MessagingClient,
90 network_client.NetworkClient,
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +000091 account_client.AccountClient,
92 container_client.ContainerClient,
93 object_client.ObjectClient,
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +000094 orchestration_client.OrchestrationClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000095 telemetry_client.TelemetryClient,
liu-sheng67b730e2015-07-16 15:19:33 +080096 alarming_client.AlarmingClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000097 qos_client.QosSpecsClient,
Yaroslav Lobankov4c237792015-12-02 18:43:48 +030098 volume_hosts_client.HostsClient,
99 volume_quotas_client.QuotasClient,
100 volume_services_client.ServicesClient,
101 volume_types_client.TypesClient,
102 volume_az_client.AvailabilityZoneClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000103 backups_client.BackupsClient,
104 volume_extensions_client.ExtensionsClient,
105 snapshots_client.SnapshotsClient,
106 volumes_client.VolumesClient,
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300107 volume_v2_hosts_client.HostsClient,
108 volume_v2_quotas_client.QuotasClient,
109 volume_v2_services_client.ServicesClient,
110 volume_v2_types_client.TypesClient,
111 volume_v2_az_client.AvailabilityZoneClient,
112 volume_v2_backups_client.BackupsClient,
113 volume_v2_extensions_client.ExtensionsClient,
114 volume_v2_qos_client.QosSpecsClient,
115 volume_v2_snapshots_client.SnapshotsClient,
116 volume_v2_volumes_client.VolumesClient,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000117 identity_v2_identity_client.IdentityClient,
118 credentials_client.CredentialsClient,
119 endpoints_client.EndPointClient,
120 identity_v3_identity_client.IdentityV3Client,
Yaroslav Lobankoved4d15c2015-12-18 11:30:10 +0300121 policies_client.PoliciesClient,
Yaroslav Lobankov757d1a22015-12-18 11:43:02 +0300122 regions_client.RegionsClient,
Yaroslav Lobankov69d90562015-12-18 12:06:40 +0300123 services_client.ServicesClient,
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +0000124 images_client.ImagesClient,
125 images_v2_client.ImagesClientV2
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000126 ]
Ken'ichi Ohmichid7df3832015-01-22 02:56:54 +0000127
128 for client in test_clients:
129 fake_string = six.text_type(random.randint(1, 0x7fffffff))
130 auth = 'auth' + fake_string
131 service = 'service' + fake_string
132 region = 'region' + fake_string
133 params = {
134 'endpoint_type': 'URL' + fake_string,
135 'build_interval': random.randint(1, 100),
136 'build_timeout': random.randint(1, 100),
137 'disable_ssl_certificate_validation':
138 True if random.randint(0, 1) else False,
139 'ca_certs': None,
140 'trace_requests': 'foo' + fake_string
141 }
142 client(auth, service, region, **params)
143 mock_init.assert_called_once_with(auth, service, region, **params)
144 mock_init.reset_mock()