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 agents_client |
| 21 | from tempest.services.compute.json import aggregates_client |
| 22 | from tempest.services.compute.json import availability_zone_client |
| 23 | from tempest.services.compute.json import certificates_client |
| 24 | from tempest.services.compute.json import extensions_client |
| 25 | from tempest.services.compute.json import fixed_ips_client |
| 26 | from tempest.services.compute.json import flavors_client |
| 27 | from tempest.services.compute.json import floating_ips_client |
| 28 | from tempest.services.compute.json import hosts_client |
| 29 | from tempest.services.compute.json import hypervisor_client |
| 30 | from tempest.services.compute.json import images_client |
| 31 | from tempest.services.compute.json import instance_usage_audit_log_client |
| 32 | from tempest.services.compute.json import interfaces_client |
| 33 | from tempest.services.compute.json import keypairs_client |
| 34 | from tempest.services.compute.json import limits_client |
| 35 | from tempest.services.compute.json import migrations_client |
| 36 | from tempest.services.compute.json import networks_client as nova_net_client |
| 37 | from tempest.services.compute.json import quotas_client |
| 38 | from tempest.services.compute.json import security_group_default_rules_client \ |
| 39 | as nova_secgrop_default_client |
| 40 | from tempest.services.compute.json import security_groups_client |
| 41 | from tempest.services.compute.json import servers_client |
| 42 | from tempest.services.compute.json import services_client |
| 43 | from tempest.services.compute.json import tenant_usages_client |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 44 | from tempest.services.compute.json import volumes_extensions_client \ |
| 45 | as compute_volumes_extensions_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 46 | from tempest.services.database.json import flavors_client as db_flavor_client |
| 47 | from tempest.services.database.json import versions_client as db_version_client |
Ken'ichi Ohmichi | 2183a65 | 2015-01-22 05:00:20 +0000 | [diff] [blame] | 48 | from tempest.services.messaging.json import messaging_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 49 | from tempest.services.network.json import network_client |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 50 | from tempest.services.object_storage import account_client |
| 51 | from tempest.services.object_storage import container_client |
| 52 | from tempest.services.object_storage import object_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 53 | from tempest.services.orchestration.json import orchestration_client |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 54 | from tempest.services.telemetry.json import telemetry_client |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 55 | from tempest.services.volume.json.admin import volume_hosts_client |
| 56 | from tempest.services.volume.json.admin import volume_quotas_client |
| 57 | from tempest.services.volume.json.admin import volume_services_client |
| 58 | from tempest.services.volume.json.admin import volume_types_client |
| 59 | from tempest.services.volume.json import availability_zone_client \ |
| 60 | as volume_az_client |
| 61 | from tempest.services.volume.json import backups_client |
| 62 | from tempest.services.volume.json import extensions_client \ |
| 63 | as volume_extensions_client |
| 64 | from tempest.services.volume.json import qos_client |
| 65 | from tempest.services.volume.json import snapshots_client |
| 66 | from tempest.services.volume.json import volumes_client |
| 67 | from tempest.services.volume.v2.json.admin import volume_hosts_client \ |
| 68 | as volume_v2_hosts_client |
| 69 | from tempest.services.volume.v2.json.admin import volume_quotas_client \ |
| 70 | as volume_v2_quotas_client |
| 71 | from tempest.services.volume.v2.json.admin import volume_services_client \ |
| 72 | as volume_v2_services_client |
| 73 | from tempest.services.volume.v2.json.admin import volume_types_client \ |
| 74 | as volume_v2_types_client |
| 75 | from tempest.services.volume.v2.json import availability_zone_client \ |
| 76 | as volume_v2_az_client |
| 77 | from tempest.services.volume.v2.json import backups_client \ |
| 78 | as volume_v2_backups_client |
| 79 | from tempest.services.volume.v2.json import extensions_client \ |
| 80 | as volume_v2_extensions_client |
| 81 | from tempest.services.volume.v2.json import qos_client as volume_v2_qos_client |
| 82 | from tempest.services.volume.v2.json import snapshots_client \ |
| 83 | as volume_v2_snapshots_client |
| 84 | from tempest.services.volume.v2.json import volumes_client as \ |
| 85 | volume_v2_volumes_client |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 86 | from tempest.tests import base |
| 87 | |
| 88 | |
| 89 | class TestServiceClient(base.TestCase): |
| 90 | |
| 91 | @mock.patch('tempest_lib.common.rest_client.RestClient.__init__') |
| 92 | def test_service_client_creations_with_specified_args(self, mock_init): |
| 93 | test_clients = [ |
Ken'ichi Ohmichi | 1f88ece | 2015-01-23 03:33:11 +0000 | [diff] [blame] | 94 | baremetal_client.BaremetalClientJSON, |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 95 | agents_client.AgentsClientJSON, |
| 96 | aggregates_client.AggregatesClientJSON, |
| 97 | availability_zone_client.AvailabilityZoneClientJSON, |
| 98 | certificates_client.CertificatesClientJSON, |
| 99 | extensions_client.ExtensionsClientJSON, |
| 100 | fixed_ips_client.FixedIPsClientJSON, |
| 101 | flavors_client.FlavorsClientJSON, |
| 102 | floating_ips_client.FloatingIPsClientJSON, |
| 103 | hosts_client.HostsClientJSON, |
| 104 | hypervisor_client.HypervisorClientJSON, |
| 105 | images_client.ImagesClientJSON, |
| 106 | instance_usage_audit_log_client.InstanceUsagesAuditLogClientJSON, |
| 107 | interfaces_client.InterfacesClientJSON, |
| 108 | keypairs_client.KeyPairsClientJSON, |
| 109 | limits_client.LimitsClientJSON, |
| 110 | migrations_client.MigrationsClientJSON, |
| 111 | nova_net_client.NetworksClientJSON, |
| 112 | quotas_client.QuotasClientJSON, |
| 113 | quotas_client.QuotaClassesClientJSON, |
| 114 | nova_secgrop_default_client.SecurityGroupDefaultRulesClientJSON, |
| 115 | security_groups_client.SecurityGroupsClientJSON, |
| 116 | servers_client.ServersClientJSON, |
| 117 | services_client.ServicesClientJSON, |
| 118 | tenant_usages_client.TenantUsagesClientJSON, |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 119 | compute_volumes_extensions_client.VolumesExtensionsClientJSON, |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 120 | db_flavor_client.DatabaseFlavorsClientJSON, |
| 121 | db_version_client.DatabaseVersionsClientJSON, |
Ken'ichi Ohmichi | 2183a65 | 2015-01-22 05:00:20 +0000 | [diff] [blame] | 122 | messaging_client.MessagingClientJSON, |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 123 | network_client.NetworkClientJSON, |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 124 | account_client.AccountClient, |
| 125 | container_client.ContainerClient, |
| 126 | object_client.ObjectClient, |
Ken'ichi Ohmichi | d5dba1c | 2015-01-23 02:23:22 +0000 | [diff] [blame] | 127 | orchestration_client.OrchestrationClient, |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 128 | telemetry_client.TelemetryClientJSON, |
| 129 | qos_client.QosSpecsClientJSON, |
| 130 | volume_hosts_client.VolumeHostsClientJSON, |
| 131 | volume_quotas_client.VolumeQuotasClientJSON, |
| 132 | volume_services_client.VolumesServicesClientJSON, |
| 133 | volume_types_client.VolumeTypesClientJSON, |
| 134 | volume_az_client.VolumeAvailabilityZoneClientJSON, |
| 135 | backups_client.BackupsClientJSON, |
| 136 | volume_extensions_client.ExtensionsClientJSON, |
| 137 | snapshots_client.SnapshotsClientJSON, |
| 138 | volumes_client.VolumesClientJSON, |
| 139 | volume_v2_hosts_client.VolumeHostsV2ClientJSON, |
| 140 | volume_v2_quotas_client.VolumeQuotasV2Client, |
| 141 | volume_v2_services_client.VolumesServicesV2ClientJSON, |
| 142 | volume_v2_types_client.VolumeTypesV2ClientJSON, |
| 143 | volume_v2_az_client.VolumeV2AvailabilityZoneClientJSON, |
| 144 | volume_v2_backups_client.BackupsClientV2JSON, |
| 145 | volume_v2_extensions_client.ExtensionsV2ClientJSON, |
| 146 | volume_v2_qos_client.QosSpecsV2ClientJSON, |
| 147 | volume_v2_snapshots_client.SnapshotsV2ClientJSON, |
| 148 | volume_v2_volumes_client.VolumesV2ClientJSON, |
| 149 | ] |
Ken'ichi Ohmichi | d7df383 | 2015-01-22 02:56:54 +0000 | [diff] [blame] | 150 | |
| 151 | for client in test_clients: |
| 152 | fake_string = six.text_type(random.randint(1, 0x7fffffff)) |
| 153 | auth = 'auth' + fake_string |
| 154 | service = 'service' + fake_string |
| 155 | region = 'region' + fake_string |
| 156 | params = { |
| 157 | 'endpoint_type': 'URL' + fake_string, |
| 158 | 'build_interval': random.randint(1, 100), |
| 159 | 'build_timeout': random.randint(1, 100), |
| 160 | 'disable_ssl_certificate_validation': |
| 161 | True if random.randint(0, 1) else False, |
| 162 | 'ca_certs': None, |
| 163 | 'trace_requests': 'foo' + fake_string |
| 164 | } |
| 165 | client(auth, service, region, **params) |
| 166 | mock_init.assert_called_once_with(auth, service, region, **params) |
| 167 | mock_init.reset_mock() |