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 | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 20 | from tempest.services.compute.json import floating_ips_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 21 | from tempest.services.compute.json import interfaces_client |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 22 | from tempest.services.compute.json import security_group_rules_client |
Ken'ichi Ohmichi | 7ca54b8 | 2015-07-07 01:10:26 +0000 | [diff] [blame] | 23 | from tempest.services.compute.json import server_groups_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 24 | from tempest.services.compute.json import servers_client |
Ken'ichi Ohmichi | ea3f26a | 2015-09-29 00:18:39 +0000 | [diff] [blame] | 25 | from tempest.services.compute.json import volumes_client \ |
| 26 | as compute_volumes_client |
Ken'ichi Ohmichi | 4e83b5e | 2015-02-13 04:07:34 +0000 | [diff] [blame] | 27 | from tempest.services.data_processing.v1_1 import data_processing_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 28 | from tempest.services.database.json import flavors_client as db_flavor_client |
| 29 | from tempest.services.database.json import versions_client as db_version_client |
Jamie Lennox | c429e6a | 2015-02-24 10:42:42 +1100 | [diff] [blame] | 30 | from tempest.services.identity.v2.json import identity_client as \ |
ghanshyam | d26b5cd | 2015-02-09 14:48:58 +0900 | [diff] [blame] | 31 | identity_v2_identity_client |
| 32 | from tempest.services.identity.v3.json import credentials_client |
| 33 | from tempest.services.identity.v3.json import endpoints_client |
| 34 | from tempest.services.identity.v3.json import identity_client as \ |
| 35 | identity_v3_identity_client |
| 36 | from tempest.services.identity.v3.json import policy_client |
| 37 | from tempest.services.identity.v3.json import region_client |
| 38 | from tempest.services.identity.v3.json import service_client |
Ken'ichi Ohmichi | 69dcf44 | 2015-11-30 11:48:01 +0000 | [diff] [blame^] | 39 | from tempest.services.image.v1.json import images_client |
| 40 | 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] | 41 | from tempest.services.messaging.json import messaging_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 42 | from tempest.services.network.json import network_client |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 43 | from tempest.services.object_storage import account_client |
| 44 | from tempest.services.object_storage import container_client |
| 45 | from tempest.services.object_storage import object_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 46 | from tempest.services.orchestration.json import orchestration_client |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 47 | from tempest.services.telemetry.json import alarming_client |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 48 | from tempest.services.telemetry.json import telemetry_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 49 | from tempest.services.volume.v1.json.admin import volume_hosts_client |
| 50 | from tempest.services.volume.v1.json.admin import volume_quotas_client |
| 51 | from tempest.services.volume.v1.json.admin import volume_services_client |
| 52 | from tempest.services.volume.v1.json.admin import volume_types_client |
| 53 | from tempest.services.volume.v1.json import availability_zone_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 54 | as volume_az_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 55 | from tempest.services.volume.v1.json import backups_client |
| 56 | from tempest.services.volume.v1.json import extensions_client \ |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 57 | as volume_extensions_client |
Yaroslav Lobankov | db4a2e1 | 2015-11-28 20:04:54 +0300 | [diff] [blame] | 58 | from tempest.services.volume.v1.json import qos_client |
| 59 | from tempest.services.volume.v1.json import snapshots_client |
| 60 | from tempest.services.volume.v1.json import volumes_client |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 61 | from tempest.services.volume.v2.json.admin import volume_hosts_client \ |
| 62 | as volume_v2_hosts_client |
| 63 | from tempest.services.volume.v2.json.admin import volume_quotas_client \ |
| 64 | as volume_v2_quotas_client |
| 65 | from tempest.services.volume.v2.json.admin import volume_services_client \ |
| 66 | as volume_v2_services_client |
| 67 | from tempest.services.volume.v2.json.admin import volume_types_client \ |
| 68 | as volume_v2_types_client |
| 69 | from tempest.services.volume.v2.json import availability_zone_client \ |
| 70 | as volume_v2_az_client |
| 71 | from tempest.services.volume.v2.json import backups_client \ |
| 72 | as volume_v2_backups_client |
| 73 | from tempest.services.volume.v2.json import extensions_client \ |
| 74 | as volume_v2_extensions_client |
| 75 | from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client |
| 76 | from tempest.services.volume.v2.json import snapshots_client \ |
| 77 | as volume_v2_snapshots_client |
| 78 | from tempest.services.volume.v2.json import volumes_client as \ |
| 79 | volume_v2_volumes_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 80 | from tempest.tests import base |
| 81 | |
| 82 | |
| 83 | class 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 Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 88 | baremetal_client.BaremetalClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 89 | floating_ips_client.FloatingIPsClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 90 | interfaces_client.InterfacesClient, |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 91 | security_group_rules_client.SecurityGroupRulesClient, |
Ken'ichi Ohmichi | 7ca54b8 | 2015-07-07 01:10:26 +0000 | [diff] [blame] | 92 | server_groups_client.ServerGroupsClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 93 | servers_client.ServersClient, |
Ken'ichi Ohmichi | ea3f26a | 2015-09-29 00:18:39 +0000 | [diff] [blame] | 94 | compute_volumes_client.VolumesClient, |
Ken'ichi Ohmichi | 4e83b5e | 2015-02-13 04:07:34 +0000 | [diff] [blame] | 95 | data_processing_client.DataProcessingClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 96 | db_flavor_client.DatabaseFlavorsClient, |
| 97 | db_version_client.DatabaseVersionsClient, |
| 98 | messaging_client.MessagingClient, |
| 99 | network_client.NetworkClient, |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 100 | account_client.AccountClient, |
| 101 | container_client.ContainerClient, |
| 102 | object_client.ObjectClient, |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 103 | orchestration_client.OrchestrationClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 104 | telemetry_client.TelemetryClient, |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 105 | alarming_client.AlarmingClient, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 106 | 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 Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 117 | volume_v2_quotas_client.VolumeQuotasV2Client, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 118 | 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 Ohmichi | 69dcf44 | 2015-11-30 11:48:01 +0000 | [diff] [blame^] | 133 | images_client.ImagesClient, |
| 134 | images_v2_client.ImagesClientV2 |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 135 | ] |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 136 | |
| 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() |