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 | 2183a65 | 2015-01-22 05:00:20 +0000 | [diff] [blame] | 34 | from tempest.services.messaging.json import messaging_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 35 | from tempest.services.network.json import network_client |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 36 | from tempest.services.object_storage import account_client |
| 37 | from tempest.services.object_storage import container_client |
| 38 | from tempest.services.object_storage import object_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 39 | from tempest.services.orchestration.json import orchestration_client |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 40 | from tempest.services.telemetry.json import alarming_client |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 41 | from tempest.services.telemetry.json import telemetry_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 42 | from tempest.services.volume.v1.json.admin import hosts_client \ |
| 43 | as volume_hosts_client |
| 44 | from tempest.services.volume.v1.json.admin import quotas_client \ |
| 45 | as volume_quotas_client |
| 46 | from tempest.services.volume.v1.json.admin import services_client \ |
| 47 | as volume_services_client |
| 48 | from tempest.services.volume.v1.json.admin import types_client \ |
| 49 | as volume_types_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 50 | from tempest.services.volume.v1.json import availability_zone_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 51 | as volume_az_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 52 | from tempest.services.volume.v1.json import backups_client |
| 53 | from tempest.services.volume.v1.json import extensions_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 54 | as volume_extensions_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 55 | from tempest.services.volume.v1.json import qos_client |
| 56 | from tempest.services.volume.v1.json import snapshots_client |
| 57 | from tempest.services.volume.v1.json import volumes_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 58 | from tempest.services.volume.v2.json.admin import hosts_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 59 | as volume_v2_hosts_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 60 | from tempest.services.volume.v2.json.admin import quotas_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 61 | as volume_v2_quotas_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 62 | from tempest.services.volume.v2.json.admin import services_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 63 | as volume_v2_services_client |
Yaroslav Lobankov | aef0298 | 2015-12-02 17:42:32 +0300 | [diff] [blame] | 64 | from tempest.services.volume.v2.json.admin import types_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 65 | as volume_v2_types_client |
| 66 | from tempest.services.volume.v2.json import availability_zone_client \ |
| 67 | as volume_v2_az_client |
| 68 | from tempest.services.volume.v2.json import backups_client \ |
| 69 | as volume_v2_backups_client |
| 70 | from tempest.services.volume.v2.json import extensions_client \ |
| 71 | as volume_v2_extensions_client |
| 72 | from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client |
| 73 | from tempest.services.volume.v2.json import snapshots_client \ |
| 74 | as volume_v2_snapshots_client |
| 75 | from tempest.services.volume.v2.json import volumes_client as \ |
| 76 | volume_v2_volumes_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 77 | from tempest.tests import base |
| 78 | |
| 79 | |
| 80 | class 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 Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 85 | baremetal_client.BaremetalClient, |
Ken'ichi Ohmichi | 4e83b5e | 2015-02-13 04:07:34 +0000 | [diff] [blame] | 86 | data_processing_client.DataProcessingClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 87 | db_flavor_client.DatabaseFlavorsClient, |
| 88 | db_version_client.DatabaseVersionsClient, |
| 89 | messaging_client.MessagingClient, |
| 90 | network_client.NetworkClient, |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 91 | account_client.AccountClient, |
| 92 | container_client.ContainerClient, |
| 93 | object_client.ObjectClient, |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 94 | orchestration_client.OrchestrationClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 95 | telemetry_client.TelemetryClient, |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 96 | alarming_client.AlarmingClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 97 | qos_client.QosSpecsClient, |
Yaroslav Lobankov | 4c23779 | 2015-12-02 18:43:48 +0300 | [diff] [blame] | 98 | 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 Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 103 | backups_client.BackupsClient, |
| 104 | volume_extensions_client.ExtensionsClient, |
| 105 | snapshots_client.SnapshotsClient, |
| 106 | volumes_client.VolumesClient, |
Yaroslav Lobankov | 4c23779 | 2015-12-02 18:43:48 +0300 | [diff] [blame] | 107 | 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 Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 117 | identity_v2_identity_client.IdentityClient, |
| 118 | credentials_client.CredentialsClient, |
| 119 | endpoints_client.EndPointClient, |
| 120 | identity_v3_identity_client.IdentityV3Client, |
Yaroslav Lobankov | ed4d15c | 2015-12-18 11:30:10 +0300 | [diff] [blame] | 121 | policies_client.PoliciesClient, |
Yaroslav Lobankov | 757d1a2 | 2015-12-18 11:43:02 +0300 | [diff] [blame] | 122 | regions_client.RegionsClient, |
Yaroslav Lobankov | 69d9056 | 2015-12-18 12:06:40 +0300 | [diff] [blame] | 123 | services_client.ServicesClient, |
Ken'ichi Ohmichi | 69dcf44 | 2015-11-30 11:48:01 +0000 | [diff] [blame] | 124 | images_client.ImagesClient, |
| 125 | images_v2_client.ImagesClientV2 |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 126 | ] |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 127 | |
| 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() |