Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 1 | # 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 | |
| 15 | import mock |
| 16 | import random |
| 17 | import six |
| 18 | |
Ken'ichi Ohmichi | 1f88ece | 2015-01-23 03:33:11 +0000 | [diff] [blame] | 19 | from tempest.services.baremetal.v1.json import baremetal_client |
Ken'ichi Ohmichi | 4e83b5e | 2015-02-13 04:07:34 +0000 | [diff] [blame] | 20 | from tempest.services.data_processing.v1_1 import data_processing_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 21 | from tempest.services.database.json import flavors_client as db_flavor_client |
| 22 | from tempest.services.database.json import versions_client as db_version_client |
Jamie Lennox | c429e6a | 2015-02-24 10:42:42 +1100 | [diff] [blame] | 23 | from tempest.services.identity.v2.json import identity_client as \ |
ghanshyam | d26b5cd | 2015-02-09 14:48:58 +0900 | [diff] [blame] | 24 | identity_v2_identity_client |
| 25 | from tempest.services.identity.v3.json import credentials_client |
| 26 | from tempest.services.identity.v3.json import endpoints_client |
| 27 | from tempest.services.identity.v3.json import identity_client as \ |
| 28 | identity_v3_identity_client |
Yaroslav Lobankov | ed4d15c | 2015-12-18 11:30:10 +0300 | [diff] [blame] | 29 | from tempest.services.identity.v3.json import policies_client |
Yaroslav Lobankov | 757d1a2 | 2015-12-18 11:43:02 +0300 | [diff] [blame] | 30 | from tempest.services.identity.v3.json import regions_client |
Yaroslav Lobankov | 69d9056 | 2015-12-18 12:06:40 +0300 | [diff] [blame] | 31 | from tempest.services.identity.v3.json import services_client |
Ken'ichi Ohmichi | 69dcf44 | 2015-11-30 11:48:01 +0000 | [diff] [blame] | 32 | from tempest.services.image.v1.json import images_client |
| 33 | from tempest.services.image.v2.json import images_client as images_v2_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 34 | from tempest.services.network.json import network_client |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 35 | from tempest.services.object_storage import account_client |
| 36 | from tempest.services.object_storage import container_client |
| 37 | from tempest.services.object_storage import object_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 38 | from tempest.services.orchestration.json import orchestration_client |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 39 | from tempest.services.telemetry.json import alarming_client |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 40 | from tempest.services.telemetry.json import telemetry_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 41 | from tempest.services.volume.v1.json.admin import hosts_client \ |
| 42 | as volume_hosts_client |
| 43 | from tempest.services.volume.v1.json.admin import quotas_client \ |
| 44 | as volume_quotas_client |
| 45 | from tempest.services.volume.v1.json.admin import services_client \ |
| 46 | as volume_services_client |
| 47 | from tempest.services.volume.v1.json.admin import types_client \ |
| 48 | as volume_types_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 49 | from tempest.services.volume.v1.json import availability_zone_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 50 | as volume_az_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 51 | from tempest.services.volume.v1.json import backups_client |
| 52 | from tempest.services.volume.v1.json import extensions_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 53 | as volume_extensions_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 54 | from tempest.services.volume.v1.json import qos_client |
| 55 | from tempest.services.volume.v1.json import snapshots_client |
| 56 | from tempest.services.volume.v1.json import volumes_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 57 | from tempest.services.volume.v2.json.admin import hosts_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 58 | as volume_v2_hosts_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 59 | from tempest.services.volume.v2.json.admin import quotas_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 60 | as volume_v2_quotas_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 61 | from tempest.services.volume.v2.json.admin import services_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 62 | as volume_v2_services_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 63 | from tempest.services.volume.v2.json.admin import types_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 64 | as volume_v2_types_client |
| 65 | from tempest.services.volume.v2.json import availability_zone_client \ |
| 66 | as volume_v2_az_client |
| 67 | from tempest.services.volume.v2.json import backups_client \ |
| 68 | as volume_v2_backups_client |
| 69 | from tempest.services.volume.v2.json import extensions_client \ |
| 70 | as volume_v2_extensions_client |
| 71 | from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client |
| 72 | from tempest.services.volume.v2.json import snapshots_client \ |
| 73 | as volume_v2_snapshots_client |
| 74 | from tempest.services.volume.v2.json import volumes_client as \ |
| 75 | volume_v2_volumes_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 76 | from tempest.tests import base |
| 77 | |
| 78 | |
| 79 | class TestServiceClient(base.TestCase): |
| 80 | |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 81 | @mock.patch('tempest.lib.common.rest_client.RestClient.__init__') |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 82 | def test_service_client_creations_with_specified_args(self, mock_init): |
| 83 | test_clients = [ |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 84 | baremetal_client.BaremetalClient, |
Ken'ichi Ohmichi | 4e83b5e | 2015-02-13 04:07:34 +0000 | [diff] [blame] | 85 | data_processing_client.DataProcessingClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 86 | db_flavor_client.DatabaseFlavorsClient, |
| 87 | db_version_client.DatabaseVersionsClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 88 | network_client.NetworkClient, |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 89 | account_client.AccountClient, |
| 90 | container_client.ContainerClient, |
| 91 | object_client.ObjectClient, |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 92 | orchestration_client.OrchestrationClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 93 | telemetry_client.TelemetryClient, |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 94 | alarming_client.AlarmingClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 95 | qos_client.QosSpecsClient, |
Yaroslav Lobankov | 4c23779 | 2015-12-02 18:43:48 +0300 | [diff] [blame] | 96 | 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 Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 101 | backups_client.BackupsClient, |
| 102 | volume_extensions_client.ExtensionsClient, |
| 103 | snapshots_client.SnapshotsClient, |
| 104 | volumes_client.VolumesClient, |
Yaroslav Lobankov | 4c23779 | 2015-12-02 18:43:48 +0300 | [diff] [blame] | 105 | 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 Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 115 | identity_v2_identity_client.IdentityClient, |
| 116 | credentials_client.CredentialsClient, |
| 117 | endpoints_client.EndPointClient, |
| 118 | identity_v3_identity_client.IdentityV3Client, |
Yaroslav Lobankov | ed4d15c | 2015-12-18 11:30:10 +0300 | [diff] [blame] | 119 | policies_client.PoliciesClient, |
Yaroslav Lobankov | 757d1a2 | 2015-12-18 11:43:02 +0300 | [diff] [blame] | 120 | regions_client.RegionsClient, |
Yaroslav Lobankov | 69d9056 | 2015-12-18 12:06:40 +0300 | [diff] [blame] | 121 | services_client.ServicesClient, |
Ken'ichi Ohmichi | 69dcf44 | 2015-11-30 11:48:01 +0000 | [diff] [blame] | 122 | images_client.ImagesClient, |
| 123 | images_v2_client.ImagesClientV2 |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 124 | ] |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 125 | |
| 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() |