diff options
Diffstat (limited to 'tempest_lib/tests/services')
41 files changed, 0 insertions, 4559 deletions
diff --git a/tempest_lib/tests/services/__init__.py b/tempest_lib/tests/services/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/tempest_lib/tests/services/__init__.py +++ /dev/null diff --git a/tempest_lib/tests/services/compute/__init__.py b/tempest_lib/tests/services/compute/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/tempest_lib/tests/services/compute/__init__.py +++ /dev/null diff --git a/tempest_lib/tests/services/compute/base.py b/tempest_lib/tests/services/compute/base.py deleted file mode 100644 index 3e4a200..0000000 --- a/tempest_lib/tests/services/compute/base.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2015 Deutsche Telekom AG. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import httplib2 -from oslo_serialization import jsonutils as json -from oslotest import mockpatch - -from tempest_lib.tests import base - - -class BaseComputeServiceTest(base.TestCase): - def create_response(self, body, to_utf=False, status=200, headers=None): - json_body = {} - if body: - json_body = json.dumps(body) - if to_utf: - json_body = json_body.encode('utf-8') - resp_dict = {'status': status} - if headers: - resp_dict.update(headers) - response = (httplib2.Response(resp_dict), json_body) - return response - - def check_service_client_function(self, function, function2mock, - body, to_utf=False, status=200, - headers=None, **kwargs): - mocked_response = self.create_response(body, to_utf, status, headers) - self.useFixture(mockpatch.Patch( - function2mock, return_value=mocked_response)) - if kwargs: - resp = function(**kwargs) - else: - resp = function() - self.assertEqual(body, resp) diff --git a/tempest_lib/tests/services/compute/test_agents_client.py b/tempest_lib/tests/services/compute/test_agents_client.py deleted file mode 100644 index 5a480c4..0000000 --- a/tempest_lib/tests/services/compute/test_agents_client.py +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import agents_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestAgentsClient(base.BaseComputeServiceTest): - FAKE_CREATE_AGENT = { - "agent": { - "url": "http://foo.com", - "hypervisor": "kvm", - "md5hash": "md5", - "version": "2", - "architecture": "x86_64", - "os": "linux", - "agent_id": 1 - } - } - - FAKE_UPDATE_AGENT = { - "agent": { - "url": "http://foo.com", - "md5hash": "md5", - "version": "2", - "agent_id": 1 - } - } - - def setUp(self): - super(TestAgentsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = agents_client.AgentsClient(fake_auth, - 'compute', 'regionOne') - - def _test_list_agents(self, bytes_body=False): - self.check_service_client_function( - self.client.list_agents, - 'tempest_lib.common.rest_client.RestClient.get', - {"agents": []}, - bytes_body) - self.check_service_client_function( - self.client.list_agents, - 'tempest_lib.common.rest_client.RestClient.get', - {"agents": []}, - bytes_body, - hypervisor="kvm") - - def _test_create_agent(self, bytes_body=False): - self.check_service_client_function( - self.client.create_agent, - 'tempest_lib.common.rest_client.RestClient.post', - self.FAKE_CREATE_AGENT, - bytes_body, - url="http://foo.com", hypervisor="kvm", md5hash="md5", - version="2", architecture="x86_64", os="linux") - - def _test_delete_agent(self): - self.check_service_client_function( - self.client.delete_agent, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, agent_id="1") - - def _test_update_agent(self, bytes_body=False): - self.check_service_client_function( - self.client.update_agent, - 'tempest_lib.common.rest_client.RestClient.put', - self.FAKE_UPDATE_AGENT, - bytes_body, - agent_id="1", url="http://foo.com", md5hash="md5", version="2") - - def test_list_agents_with_str_body(self): - self._test_list_agents() - - def test_list_agents_with_bytes_body(self): - self._test_list_agents(bytes_body=True) - - def test_create_agent_with_str_body(self): - self._test_create_agent() - - def test_create_agent_with_bytes_body(self): - self._test_create_agent(bytes_body=True) - - def test_delete_agent(self): - self._test_delete_agent() - - def test_update_agent_with_str_body(self): - self._test_update_agent() - - def test_update_agent_with_bytes_body(self): - self._test_update_agent(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_aggregates_client.py b/tempest_lib/tests/services/compute/test_aggregates_client.py deleted file mode 100644 index b63ed72..0000000 --- a/tempest_lib/tests/services/compute/test_aggregates_client.py +++ /dev/null @@ -1,192 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import aggregates_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestAggregatesClient(base.BaseComputeServiceTest): - FAKE_SHOW_AGGREGATE = { - "aggregate": - { - "name": "hoge", - "availability_zone": None, - "deleted": False, - "created_at": - "2015-07-16T03:07:32.000000", - "updated_at": None, - "hosts": [], - "deleted_at": None, - "id": 1, - "metadata": {} - } - } - - FAKE_CREATE_AGGREGATE = { - "aggregate": - { - "name": u'\xf4', - "availability_zone": None, - "deleted": False, - "created_at": "2015-07-21T04:11:18.000000", - "updated_at": None, - "deleted_at": None, - "id": 1 - } - } - - FAKE_UPDATE_AGGREGATE = { - "aggregate": - { - "name": u'\xe9', - "availability_zone": None, - "deleted": False, - "created_at": "2015-07-16T03:07:32.000000", - "updated_at": "2015-07-23T05:16:29.000000", - "hosts": [], - "deleted_at": None, - "id": 1, - "metadata": {} - } - } - - FAKE_AGGREGATE = { - "availability_zone": "nova", - "created_at": "2013-08-18T12:17:56.297823", - "deleted": False, - "deleted_at": None, - "hosts": [ - "21549b2f665945baaa7101926a00143c" - ], - "id": 1, - "metadata": { - "availability_zone": "nova" - }, - "name": u'\xe9', - "updated_at": None - } - - FAKE_ADD_HOST = {'aggregate': FAKE_AGGREGATE} - FAKE_REMOVE_HOST = {'aggregate': FAKE_AGGREGATE} - FAKE_SET_METADATA = {'aggregate': FAKE_AGGREGATE} - - def setUp(self): - super(TestAggregatesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = aggregates_client.AggregatesClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_aggregates(self, bytes_body=False): - self.check_service_client_function( - self.client.list_aggregates, - 'tempest_lib.common.rest_client.RestClient.get', - {"aggregates": []}, - bytes_body) - - def test_list_aggregates_with_str_body(self): - self._test_list_aggregates() - - def test_list_aggregates_with_bytes_body(self): - self._test_list_aggregates(bytes_body=True) - - def _test_show_aggregate(self, bytes_body=False): - self.check_service_client_function( - self.client.show_aggregate, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_SHOW_AGGREGATE, - bytes_body, - aggregate_id=1) - - def test_show_aggregate_with_str_body(self): - self._test_show_aggregate() - - def test_show_aggregate_with_bytes_body(self): - self._test_show_aggregate(bytes_body=True) - - def _test_create_aggregate(self, bytes_body=False): - self.check_service_client_function( - self.client.create_aggregate, - 'tempest_lib.common.rest_client.RestClient.post', - self.FAKE_CREATE_AGGREGATE, - bytes_body, - name='hoge') - - def test_create_aggregate_with_str_body(self): - self._test_create_aggregate() - - def test_create_aggregate_with_bytes_body(self): - self._test_create_aggregate(bytes_body=True) - - def test_delete_aggregate(self): - self.check_service_client_function( - self.client.delete_aggregate, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, aggregate_id="1") - - def _test_update_aggregate(self, bytes_body=False): - self.check_service_client_function( - self.client.update_aggregate, - 'tempest_lib.common.rest_client.RestClient.put', - self.FAKE_UPDATE_AGGREGATE, - bytes_body, - aggregate_id=1) - - def test_update_aggregate_with_str_body(self): - self._test_update_aggregate() - - def test_update_aggregate_with_bytes_body(self): - self._test_update_aggregate(bytes_body=True) - - def _test_add_host(self, bytes_body=False): - self.check_service_client_function( - self.client.add_host, - 'tempest_lib.common.rest_client.RestClient.post', - self.FAKE_ADD_HOST, - bytes_body, - aggregate_id=1) - - def test_add_host_with_str_body(self): - self._test_add_host() - - def test_add_host_with_bytes_body(self): - self._test_add_host(bytes_body=True) - - def _test_remove_host(self, bytes_body=False): - self.check_service_client_function( - self.client.remove_host, - 'tempest_lib.common.rest_client.RestClient.post', - self.FAKE_REMOVE_HOST, - bytes_body, - aggregate_id=1) - - def test_remove_host_with_str_body(self): - self._test_remove_host() - - def test_remove_host_with_bytes_body(self): - self._test_remove_host(bytes_body=True) - - def _test_set_metadata(self, bytes_body=False): - self.check_service_client_function( - self.client.set_metadata, - 'tempest_lib.common.rest_client.RestClient.post', - self.FAKE_SET_METADATA, - bytes_body, - aggregate_id=1) - - def test_set_metadata_with_str_body(self): - self._test_set_metadata() - - def test_set_metadata_with_bytes_body(self): - self._test_set_metadata(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_availability_zone_client.py b/tempest_lib/tests/services/compute/test_availability_zone_client.py deleted file mode 100644 index 0a97bbf..0000000 --- a/tempest_lib/tests/services/compute/test_availability_zone_client.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import availability_zone_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestAvailabilityZoneClient(base.BaseComputeServiceTest): - - FAKE_AVAILABIRITY_ZONE_INFO = { - "availabilityZoneInfo": - [ - { - "zoneState": { - "available": True - }, - "hosts": None, - "zoneName": u'\xf4' - } - ] - } - - def setUp(self): - super(TestAvailabilityZoneClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = availability_zone_client.AvailabilityZoneClient( - fake_auth, 'compute', 'regionOne') - - def test_list_availability_zones_with_str_body(self): - self.check_service_client_function( - self.client.list_availability_zones, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_AVAILABIRITY_ZONE_INFO) - - def test_list_availability_zones_with_bytes_body(self): - self.check_service_client_function( - self.client.list_availability_zones, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_AVAILABIRITY_ZONE_INFO, to_utf=True) diff --git a/tempest_lib/tests/services/compute/test_baremetal_nodes_client.py b/tempest_lib/tests/services/compute/test_baremetal_nodes_client.py deleted file mode 100644 index 0844fef..0000000 --- a/tempest_lib/tests/services/compute/test_baremetal_nodes_client.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from tempest_lib.services.compute import baremetal_nodes_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestBareMetalNodesClient(base.BaseComputeServiceTest): - - FAKE_NODE_INFO = {'cpus': '8', - 'disk_gb': '64', - 'host': '10.0.2.15', - 'id': 'Identifier', - 'instance_uuid': "null", - 'interfaces': [ - { - "address": "20::01", - "datapath_id": "null", - "id": 1, - "port_no": None - } - ], - 'memory_mb': '8192', - 'task_state': None} - - def setUp(self): - super(TestBareMetalNodesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.baremetal_nodes_client = (baremetal_nodes_client. - BaremetalNodesClient - (fake_auth, 'compute', - 'regionOne')) - - def _test_bareMetal_nodes(self, operation='list', bytes_body=False): - if operation != 'list': - expected = {"node": self.FAKE_NODE_INFO} - function = self.baremetal_nodes_client.show_baremetal_node - else: - node_info = copy.deepcopy(self.FAKE_NODE_INFO) - del node_info['instance_uuid'] - expected = {"nodes": [node_info]} - function = self.baremetal_nodes_client.list_baremetal_nodes - - self.check_service_client_function( - function, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body, 200, - baremetal_node_id='Identifier') - - def test_list_bareMetal_nodes_with_str_body(self): - self._test_bareMetal_nodes() - - def test_list_bareMetal_nodes_with_bytes_body(self): - self._test_bareMetal_nodes(bytes_body=True) - - def test_show_bareMetal_node_with_str_body(self): - self._test_bareMetal_nodes('show') - - def test_show_bareMetal_node_with_bytes_body(self): - self._test_bareMetal_nodes('show', True) diff --git a/tempest_lib/tests/services/compute/test_certificates_client.py b/tempest_lib/tests/services/compute/test_certificates_client.py deleted file mode 100644 index 9d5e50a..0000000 --- a/tempest_lib/tests/services/compute/test_certificates_client.py +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from tempest_lib.services.compute import certificates_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestCertificatesClient(base.BaseComputeServiceTest): - - FAKE_CERTIFICATE = { - "certificate": { - "data": "-----BEGIN----MIICyzCCAjSgAwI----END CERTIFICATE-----\n", - "private_key": None - } - } - - def setUp(self): - super(TestCertificatesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = certificates_client.CertificatesClient( - fake_auth, 'compute', 'regionOne') - - def _test_show_certificate(self, bytes_body=False): - self.check_service_client_function( - self.client.show_certificate, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_CERTIFICATE, - bytes_body, - certificate_id="fake-id") - - def test_show_certificate_with_str_body(self): - self._test_show_certificate() - - def test_show_certificate_with_bytes_body(self): - self._test_show_certificate(bytes_body=True) - - def _test_create_certificate(self, bytes_body=False): - cert = copy.deepcopy(self.FAKE_CERTIFICATE) - cert['certificate']['private_key'] = "my_private_key" - self.check_service_client_function( - self.client.create_certificate, - 'tempest_lib.common.rest_client.RestClient.post', - cert, - bytes_body) - - def test_create_certificate_with_str_body(self): - self._test_create_certificate() - - def test_create_certificate_with_bytes_body(self): - self._test_create_certificate(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_extensions_client.py b/tempest_lib/tests/services/compute/test_extensions_client.py deleted file mode 100644 index 084300f..0000000 --- a/tempest_lib/tests/services/compute/test_extensions_client.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import extensions_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestExtensionsClient(base.BaseComputeServiceTest): - - FAKE_SHOW_EXTENSION = { - "extension": { - "updated": "2011-06-09T00:00:00Z", - "name": "Multinic", - "links": [], - "namespace": - "http://docs.openstack.org/compute/ext/multinic/api/v1.1", - "alias": "NMN", - "description": u'\u2740(*\xb4\u25e1`*)\u2740' - } - } - - def setUp(self): - super(TestExtensionsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = extensions_client.ExtensionsClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_extensions(self, bytes_body=False): - self.check_service_client_function( - self.client.list_extensions, - 'tempest_lib.common.rest_client.RestClient.get', - {"extensions": []}, - bytes_body) - - def test_list_extensions_with_str_body(self): - self._test_list_extensions() - - def test_list_extensions_with_bytes_body(self): - self._test_list_extensions(bytes_body=True) - - def _test_show_extension(self, bytes_body=False): - self.check_service_client_function( - self.client.show_extension, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_SHOW_EXTENSION, - bytes_body, - extension_alias="NMN") - - def test_show_extension_with_str_body(self): - self._test_show_extension() - - def test_show_extension_with_bytes_body(self): - self._test_show_extension(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_fixedIPs_client.py b/tempest_lib/tests/services/compute/test_fixedIPs_client.py deleted file mode 100644 index efa4e22..0000000 --- a/tempest_lib/tests/services/compute/test_fixedIPs_client.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import fixed_ips_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestFixedIPsClient(base.BaseComputeServiceTest): - FIXED_IP_INFO = {"fixed_ip": {"address": "10.0.0.1", - "cidr": "10.11.12.0/24", - "host": "localhost", - "hostname": "OpenStack"}} - - def setUp(self): - super(TestFixedIPsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.fixedIPsClient = (fixed_ips_client. - FixedIPsClient - (fake_auth, 'compute', - 'regionOne')) - - def _test_show_fixed_ip(self, bytes_body=False): - self.check_service_client_function( - self.fixedIPsClient.show_fixed_ip, - 'tempest_lib.common.rest_client.RestClient.get', - self.FIXED_IP_INFO, bytes_body, - status=200, fixed_ip='Identifier') - - def test_show_fixed_ip_with_str_body(self): - self._test_show_fixed_ip() - - def test_show_fixed_ip_with_bytes_body(self): - self._test_show_fixed_ip(True) - - def _test_reserve_fixed_ip(self, bytes_body=False): - self.check_service_client_function( - self.fixedIPsClient.reserve_fixed_ip, - 'tempest_lib.common.rest_client.RestClient.post', - {}, bytes_body, - status=202, fixed_ip='Identifier') - - def test_reserve_fixed_ip_with_str_body(self): - self._test_reserve_fixed_ip() - - def test_reserve_fixed_ip_with_bytes_body(self): - self._test_reserve_fixed_ip(True) diff --git a/tempest_lib/tests/services/compute/test_flavors_client.py b/tempest_lib/tests/services/compute/test_flavors_client.py deleted file mode 100644 index a6cec39..0000000 --- a/tempest_lib/tests/services/compute/test_flavors_client.py +++ /dev/null @@ -1,255 +0,0 @@ -# Copyright 2015 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy -import httplib2 - -from oslo_serialization import jsonutils as json -from oslotest import mockpatch - -from tempest_lib.services.compute import flavors_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestFlavorsClient(base.BaseComputeServiceTest): - - FAKE_FLAVOR = { - "disk": 1, - "id": "1", - "links": [{ - "href": "http://openstack.example.com/v2/openstack/flavors/1", - "rel": "self"}, { - "href": "http://openstack.example.com/openstack/flavors/1", - "rel": "bookmark"}], - "name": "m1.tiny", - "ram": 512, - "swap": 1, - "vcpus": 1 - } - - EXTRA_SPECS = {"extra_specs": { - "key1": "value1", - "key2": "value2"} - } - - FAKE_FLAVOR_ACCESS = { - "flavor_id": "10", - "tenant_id": "1a951d988e264818afe520e78697dcbf" - } - - def setUp(self): - super(TestFlavorsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = flavors_client.FlavorsClient(fake_auth, - 'compute', 'regionOne') - - def _test_list_flavors(self, bytes_body=False): - flavor = copy.deepcopy(TestFlavorsClient.FAKE_FLAVOR) - # Remove extra attributes - for attribute in ('disk', 'vcpus', 'ram', 'swap'): - del flavor[attribute] - expected = {'flavors': [flavor]} - self.check_service_client_function( - self.client.list_flavors, - 'tempest_lib.common.rest_client.RestClient.get', - expected, - bytes_body) - - def test_list_flavors_str_body(self): - self._test_list_flavors(bytes_body=False) - - def test_list_flavors_byte_body(self): - self._test_list_flavors(bytes_body=True) - - def _test_show_flavor(self, bytes_body=False): - expected = {"flavor": TestFlavorsClient.FAKE_FLAVOR} - self.check_service_client_function( - self.client.show_flavor, - 'tempest_lib.common.rest_client.RestClient.get', - expected, - bytes_body, - flavor_id='fake-id') - - def test_show_flavor_str_body(self): - self._test_show_flavor(bytes_body=False) - - def test_show_flavor_byte_body(self): - self._test_show_flavor(bytes_body=True) - - def _test_create_flavor(self, bytes_body=False): - expected = {"flavor": TestFlavorsClient.FAKE_FLAVOR} - request = copy.deepcopy(TestFlavorsClient.FAKE_FLAVOR) - # The 'links' parameter should not be passed in - del request['links'] - self.check_service_client_function( - self.client.create_flavor, - 'tempest_lib.common.rest_client.RestClient.post', - expected, - bytes_body, - **request) - - def test_create_flavor_str_body(self): - self._test_create_flavor(bytes_body=False) - - def test_create_flavor__byte_body(self): - self._test_create_flavor(bytes_body=True) - - def test_delete_flavor(self): - self.check_service_client_function( - self.client.delete_flavor, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=202, flavor_id='c782b7a9-33cd-45f0-b795-7f87f456408b') - - def _test_is_resource_deleted(self, flavor_id, is_deleted=True, - bytes_body=False): - body = json.dumps({'flavors': [TestFlavorsClient.FAKE_FLAVOR]}) - if bytes_body: - body = body.encode('utf-8') - response = (httplib2.Response({'status': 200}), body) - self.useFixture(mockpatch.Patch( - 'tempest_lib.common.rest_client.RestClient.get', - return_value=response)) - self.assertEqual(is_deleted, - self.client.is_resource_deleted(flavor_id)) - - def test_is_resource_deleted_true_str_body(self): - self._test_is_resource_deleted('2', bytes_body=False) - - def test_is_resource_deleted_true_byte_body(self): - self._test_is_resource_deleted('2', bytes_body=True) - - def test_is_resource_deleted_false_str_body(self): - self._test_is_resource_deleted('1', is_deleted=False, bytes_body=False) - - def test_is_resource_deleted_false_byte_body(self): - self._test_is_resource_deleted('1', is_deleted=False, bytes_body=True) - - def _test_set_flavor_extra_spec(self, bytes_body=False): - self.check_service_client_function( - self.client.set_flavor_extra_spec, - 'tempest_lib.common.rest_client.RestClient.post', - TestFlavorsClient.EXTRA_SPECS, - bytes_body, - flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6', - **TestFlavorsClient.EXTRA_SPECS) - - def test_set_flavor_extra_spec_str_body(self): - self._test_set_flavor_extra_spec(bytes_body=False) - - def test_set_flavor_extra_spec_byte_body(self): - self._test_set_flavor_extra_spec(bytes_body=True) - - def _test_list_flavor_extra_specs(self, bytes_body=False): - self.check_service_client_function( - self.client.list_flavor_extra_specs, - 'tempest_lib.common.rest_client.RestClient.get', - TestFlavorsClient.EXTRA_SPECS, - bytes_body, - flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6') - - def test_list_flavor_extra_specs_str_body(self): - self._test_list_flavor_extra_specs(bytes_body=False) - - def test_list_flavor_extra_specs__byte_body(self): - self._test_list_flavor_extra_specs(bytes_body=True) - - def _test_show_flavor_extra_spec(self, bytes_body=False): - expected = {"key": "value"} - self.check_service_client_function( - self.client.show_flavor_extra_spec, - 'tempest_lib.common.rest_client.RestClient.get', - expected, - bytes_body, - flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6', - key='key') - - def test_show_flavor_extra_spec_str_body(self): - self._test_show_flavor_extra_spec(bytes_body=False) - - def test_show_flavor_extra_spec__byte_body(self): - self._test_show_flavor_extra_spec(bytes_body=True) - - def _test_update_flavor_extra_spec(self, bytes_body=False): - expected = {"key1": "value"} - self.check_service_client_function( - self.client.update_flavor_extra_spec, - 'tempest_lib.common.rest_client.RestClient.put', - expected, - bytes_body, - flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6', - key='key1', **expected) - - def test_update_flavor_extra_spec_str_body(self): - self._test_update_flavor_extra_spec(bytes_body=False) - - def test_update_flavor_extra_spec_byte_body(self): - self._test_update_flavor_extra_spec(bytes_body=True) - - def test_unset_flavor_extra_spec(self): - self.check_service_client_function( - self.client.unset_flavor_extra_spec, - 'tempest_lib.common.rest_client.RestClient.delete', {}, - flavor_id='c782b7a9-33cd-45f0-b795-7f87f456408b', key='key') - - def _test_list_flavor_access(self, bytes_body=False): - expected = {'flavor_access': [TestFlavorsClient.FAKE_FLAVOR_ACCESS]} - self.check_service_client_function( - self.client.list_flavor_access, - 'tempest_lib.common.rest_client.RestClient.get', - expected, - bytes_body, - flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6') - - def test_list_flavor_access_str_body(self): - self._test_list_flavor_access(bytes_body=False) - - def test_list_flavor_access_byte_body(self): - self._test_list_flavor_access(bytes_body=True) - - def _test_add_flavor_access(self, bytes_body=False): - expected = { - "flavor_access": [TestFlavorsClient.FAKE_FLAVOR_ACCESS] - } - self.check_service_client_function( - self.client.add_flavor_access, - 'tempest_lib.common.rest_client.RestClient.post', - expected, - bytes_body, - flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6', - tenant_id='1a951d988e264818afe520e78697dcbf') - - def test_add_flavor_access_str_body(self): - self._test_add_flavor_access(bytes_body=False) - - def test_add_flavor_access_byte_body(self): - self._test_add_flavor_access(bytes_body=True) - - def _test_remove_flavor_access(self, bytes_body=False): - expected = { - "flavor_access": [TestFlavorsClient.FAKE_FLAVOR_ACCESS] - } - self.check_service_client_function( - self.client.remove_flavor_access, - 'tempest_lib.common.rest_client.RestClient.post', - expected, - bytes_body, - flavor_id='10', - tenant_id='a6edd4d66ad04245b5d2d8716ecc91e3') - - def test_remove_flavor_access_str_body(self): - self._test_remove_flavor_access(bytes_body=False) - - def test_remove_flavor_access_byte_body(self): - self._test_remove_flavor_access(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_floating_ip_pools_client.py b/tempest_lib/tests/services/compute/test_floating_ip_pools_client.py deleted file mode 100644 index 21f9c46..0000000 --- a/tempest_lib/tests/services/compute/test_floating_ip_pools_client.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import floating_ip_pools_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestFloatingIPPoolsClient(base.BaseComputeServiceTest): - - FAKE_FLOATING_IP_POOLS = { - "floating_ip_pools": - [ - {"name": u'\u3042'}, - {"name": u'\u3044'} - ] - } - - def setUp(self): - super(TestFloatingIPPoolsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = floating_ip_pools_client.FloatingIPPoolsClient( - fake_auth, 'compute', 'regionOne') - - def test_list_floating_ip_pools_with_str_body(self): - self.check_service_client_function( - self.client.list_floating_ip_pools, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_FLOATING_IP_POOLS) - - def test_list_floating_ip_pools_with_bytes_body(self): - self.check_service_client_function( - self.client.list_floating_ip_pools, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_FLOATING_IP_POOLS, to_utf=True) diff --git a/tempest_lib/tests/services/compute/test_floating_ips_bulk_client.py b/tempest_lib/tests/services/compute/test_floating_ips_bulk_client.py deleted file mode 100644 index 6926c35..0000000 --- a/tempest_lib/tests/services/compute/test_floating_ips_bulk_client.py +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.tests import fake_auth_provider - -from tempest_lib.services.compute import floating_ips_bulk_client -from tempest_lib.tests.services.compute import base - - -class TestFloatingIPsBulkClient(base.BaseComputeServiceTest): - - FAKE_FIP_BULK_LIST = {"floating_ip_info": [{ - "address": "10.10.10.1", - "instance_uuid": None, - "fixed_ip": None, - "interface": "eth0", - "pool": "nova", - "project_id": None - }, - { - "address": "10.10.10.2", - "instance_uuid": None, - "fixed_ip": None, - "interface": "eth0", - "pool": "nova", - "project_id": None - }]} - - def setUp(self): - super(TestFloatingIPsBulkClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = floating_ips_bulk_client.FloatingIPsBulkClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_floating_ips_bulk(self, bytes_body=False): - self.check_service_client_function( - self.client.list_floating_ips_bulk, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_FIP_BULK_LIST, - to_utf=bytes_body) - - def _test_create_floating_ips_bulk(self, bytes_body=False): - fake_fip_create_data = {"floating_ips_bulk_create": { - "ip_range": "192.168.1.0/24", "pool": "nova", "interface": "eth0"}} - self.check_service_client_function( - self.client.create_floating_ips_bulk, - 'tempest_lib.common.rest_client.RestClient.post', - fake_fip_create_data, - to_utf=bytes_body, - ip_range="192.168.1.0/24", pool="nova", interface="eth0") - - def _test_delete_floating_ips_bulk(self, bytes_body=False): - fake_fip_delete_data = {"floating_ips_bulk_delete": "192.168.1.0/24"} - self.check_service_client_function( - self.client.delete_floating_ips_bulk, - 'tempest_lib.common.rest_client.RestClient.put', - fake_fip_delete_data, - to_utf=bytes_body, - ip_range="192.168.1.0/24") - - def test_list_floating_ips_bulk_with_str_body(self): - self._test_list_floating_ips_bulk() - - def test_list_floating_ips_bulk_with_bytes_body(self): - self._test_list_floating_ips_bulk(True) - - def test_create_floating_ips_bulk_with_str_body(self): - self._test_create_floating_ips_bulk() - - def test_create_floating_ips_bulk_with_bytes_body(self): - self._test_create_floating_ips_bulk(True) - - def test_delete_floating_ips_bulk_with_str_body(self): - self._test_delete_floating_ips_bulk() - - def test_delete_floating_ips_bulk_with_bytes_body(self): - self._test_delete_floating_ips_bulk(True) diff --git a/tempest_lib/tests/services/compute/test_floating_ips_client.py b/tempest_lib/tests/services/compute/test_floating_ips_client.py deleted file mode 100644 index 01796e5..0000000 --- a/tempest_lib/tests/services/compute/test_floating_ips_client.py +++ /dev/null @@ -1,113 +0,0 @@ -# Copyright 2015 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslotest import mockpatch - -from tempest_lib import exceptions as lib_exc -from tempest_lib.services.compute import floating_ips_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestFloatingIpsClient(base.BaseComputeServiceTest): - - floating_ip = {"fixed_ip": None, - "id": "46d61064-13ba-4bf0-9557-69de824c3d6f", - "instance_id": "a1daa443-a6bb-463e-aea2-104b7d912eb8", - "ip": "10.10.10.1", - "pool": "nova"} - - def setUp(self): - super(TestFloatingIpsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = floating_ips_client.FloatingIPsClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_floating_ips(self, bytes_body=False): - expected = {'floating_ips': [TestFloatingIpsClient.floating_ip]} - self.check_service_client_function( - self.client.list_floating_ips, - 'tempest_lib.common.rest_client.RestClient.get', - expected, - bytes_body) - - def test_list_floating_ips_str_body(self): - self._test_list_floating_ips(bytes_body=False) - - def test_list_floating_ips_byte_body(self): - self._test_list_floating_ips(bytes_body=True) - - def _test_show_floating_ip(self, bytes_body=False): - expected = {"floating_ip": TestFloatingIpsClient.floating_ip} - self.check_service_client_function( - self.client.show_floating_ip, - 'tempest_lib.common.rest_client.RestClient.get', - expected, - bytes_body, - floating_ip_id='a1daa443-a6bb-463e-aea2-104b7d912eb8') - - def test_show_floating_ip_str_body(self): - self._test_show_floating_ip(bytes_body=False) - - def test_show_floating_ip_byte_body(self): - self._test_show_floating_ip(bytes_body=True) - - def _test_create_floating_ip(self, bytes_body=False): - expected = {"floating_ip": TestFloatingIpsClient.floating_ip} - self.check_service_client_function( - self.client.create_floating_ip, - 'tempest_lib.common.rest_client.RestClient.post', - expected, - bytes_body, - pool_name='nova') - - def test_create_floating_ip_str_body(self): - self._test_create_floating_ip(bytes_body=False) - - def test_create_floating_ip_byte_body(self): - self._test_create_floating_ip(bytes_body=True) - - def test_delete_floating_ip(self): - self.check_service_client_function( - self.client.delete_floating_ip, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=202, floating_ip_id='fake-id') - - def test_associate_floating_ip_to_server(self): - self.check_service_client_function( - self.client.associate_floating_ip_to_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, status=202, floating_ip='10.10.10.1', - server_id='c782b7a9-33cd-45f0-b795-7f87f456408b') - - def test_disassociate_floating_ip_from_server(self): - self.check_service_client_function( - self.client.disassociate_floating_ip_from_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, status=202, floating_ip='10.10.10.1', - server_id='c782b7a9-33cd-45f0-b795-7f87f456408b') - - def test_is_resource_deleted_true(self): - self.useFixture(mockpatch.Patch( - 'tempest_lib.services.compute.floating_ips_client.' - 'FloatingIPsClient.show_floating_ip', - side_effect=lib_exc.NotFound())) - self.assertTrue(self.client.is_resource_deleted('fake-id')) - - def test_is_resource_deleted_false(self): - self.useFixture(mockpatch.Patch( - 'tempest_lib.services.compute.floating_ips_client.' - 'FloatingIPsClient.show_floating_ip', - return_value={"floating_ip": TestFloatingIpsClient.floating_ip})) - self.assertFalse(self.client.is_resource_deleted('fake-id')) diff --git a/tempest_lib/tests/services/compute/test_hosts_client.py b/tempest_lib/tests/services/compute/test_hosts_client.py deleted file mode 100644 index c1e053a..0000000 --- a/tempest_lib/tests/services/compute/test_hosts_client.py +++ /dev/null @@ -1,147 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import hosts_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestHostsClient(base.BaseComputeServiceTest): - FAKE_HOST_DATA = { - "host": { - "resource": { - "cpu": 1, - "disk_gb": 1028, - "host": "c1a7de0ac9d94e4baceae031d05caae3", - "memory_mb": 8192, - "project": "(total)" - } - }, - "hosts": { - "host_name": "c1a7de0ac9d94e4baceae031d05caae3", - "service": "conductor", - "zone": "internal" - }, - "enable_hosts": { - "host": "65c5d5b7e3bd44308e67fc50f362aee6", - "maintenance_mode": "off_maintenance", - "status": "enabled" - } - } - - FAKE_CONTROL_DATA = { - "shutdown": { - "host": "c1a7de0ac9d94e4baceae031d05caae3", - "power_action": "shutdown" - }, - "startup": { - "host": "c1a7de0ac9d94e4baceae031d05caae3", - "power_action": "startup" - }, - "reboot": { - "host": "c1a7de0ac9d94e4baceae031d05caae3", - "power_action": "reboot" - }} - - HOST_DATA = {'host': [FAKE_HOST_DATA['host']]} - HOSTS_DATA = {'hosts': [FAKE_HOST_DATA['hosts']]} - ENABLE_HOST_DATA = FAKE_HOST_DATA['enable_hosts'] - HOST_ID = "c1a7de0ac9d94e4baceae031d05caae3" - TEST_HOST_DATA = { - "status": "enable", - "maintenance_mode": "disable" - } - - def setUp(self): - super(TestHostsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = hosts_client.HostsClient(fake_auth, 'compute', - 'regionOne') - self.params = {'hostname': self.HOST_ID} - self.func2mock = { - 'get': 'tempest_lib.common.rest_client.RestClient.get', - 'put': 'tempest_lib.common.rest_client.RestClient.put'} - - def _test_host_data(self, test_type='list', bytes_body=False): - expected_resp = self.HOST_DATA - if test_type != 'list': - function_call = self.client.show_host - else: - expected_resp = self.HOSTS_DATA - function_call = self.client.list_hosts - self.params = {'host_name': self.HOST_ID} - - self.check_service_client_function( - function_call, self.func2mock['get'], - expected_resp, bytes_body, - 200, **self.params) - - def _test_update_hosts(self, bytes_body=False): - expected_resp = self.ENABLE_HOST_DATA - self.check_service_client_function( - self.client.update_host, self.func2mock['put'], - expected_resp, bytes_body, - 200, **self.params) - - def _test_control_host(self, control_op='reboot', bytes_body=False): - if control_op == 'start': - expected_resp = self.FAKE_CONTROL_DATA['startup'] - function_call = self.client.startup_host - elif control_op == 'stop': - expected_resp = self.FAKE_CONTROL_DATA['shutdown'] - function_call = self.client.shutdown_host - else: - expected_resp = self.FAKE_CONTROL_DATA['reboot'] - function_call = self.client.reboot_host - - self.check_service_client_function( - function_call, self.func2mock['get'], - expected_resp, bytes_body, - 200, **self.params) - - def test_show_host_with_str_body(self): - self._test_host_data('show') - - def test_show_host_with_bytes_body(self): - self._test_host_data('show', True) - - def test_list_host_with_str_body(self): - self._test_host_data() - - def test_list_host_with_bytes_body(self): - self._test_host_data(bytes_body=True) - - def test_start_host_with_str_body(self): - self._test_control_host('start') - - def test_start_host_with_bytes_body(self): - self._test_control_host('start', True) - - def test_stop_host_with_str_body(self): - self._test_control_host('stop') - - def test_stop_host_with_bytes_body(self): - self._test_control_host('stop', True) - - def test_reboot_host_with_str_body(self): - self._test_control_host('reboot') - - def test_reboot_host_with_bytes_body(self): - self._test_control_host('reboot', True) - - def test_update_host_with_str_body(self): - self._test_update_hosts() - - def test_update_host_with_bytes_body(self): - self._test_update_hosts(True) diff --git a/tempest_lib/tests/services/compute/test_hypervisor_client.py b/tempest_lib/tests/services/compute/test_hypervisor_client.py deleted file mode 100644 index 1cb85a9..0000000 --- a/tempest_lib/tests/services/compute/test_hypervisor_client.py +++ /dev/null @@ -1,167 +0,0 @@ -# Copyright 2015 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import hypervisor_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestHypervisorClient(base.BaseComputeServiceTest): - - hypervisor_id = "1" - hypervisor_name = "hyper.hostname.com" - - def setUp(self): - super(TestHypervisorClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = hypervisor_client.HypervisorClient( - fake_auth, 'compute', 'regionOne') - - def test_list_hypervisor_str_body(self): - self._test_list_hypervisor(bytes_body=False) - - def test_list_hypervisor_byte_body(self): - self._test_list_hypervisor(bytes_body=True) - - def _test_list_hypervisor(self, bytes_body=False): - expected = {"hypervisors": [{ - "id": 1, - "hypervisor_hostname": "hypervisor1.hostname.com"}, - { - "id": 2, - "hypervisor_hostname": "hypervisor2.hostname.com"}]} - self.check_service_client_function( - self.client.list_hypervisors, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body) - - def test_show_hypervisor_str_body(self): - self._test_show_hypervisor(bytes_body=False) - - def test_show_hypervisor_byte_body(self): - self._test_show_hypervisor(bytes_body=True) - - def _test_show_hypervisor(self, bytes_body=False): - expected = {"hypervisor": { - "cpu_info": "?", - "current_workload": 0, - "disk_available_least": 1, - "host_ip": "10.10.10.10", - "free_disk_gb": 1028, - "free_ram_mb": 7680, - "hypervisor_hostname": "fake-mini", - "hypervisor_type": "fake", - "hypervisor_version": 1, - "id": 1, - "local_gb": 1028, - "local_gb_used": 0, - "memory_mb": 8192, - "memory_mb_used": 512, - "running_vms": 0, - "service": { - "host": "fake_host", - "id": 2}, - "vcpus": 1, - "vcpus_used": 0}} - self.check_service_client_function( - self.client.show_hypervisor, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body, - hypervisor_id=self.hypervisor_id) - - def test_list_servers_on_hypervisor_str_body(self): - self._test_list_servers_on_hypervisor(bytes_body=False) - - def test_list_servers_on_hypervisor_byte_body(self): - self._test_list_servers_on_hypervisor(bytes_body=True) - - def _test_list_servers_on_hypervisor(self, bytes_body=False): - expected = {"hypervisors": [{ - "id": 1, - "hypervisor_hostname": "hyper.hostname.com", - "servers": [{ - "uuid": "e1ae8fc4-b72d-4c2f-a427-30dd420b6277", - "name": "instance-00000001"}, - { - "uuid": "e1ae8fc4-b72d-4c2f-a427-30dd42066666", - "name": "instance-00000002"} - ]} - ]} - self.check_service_client_function( - self.client.list_servers_on_hypervisor, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body, - hypervisor_name=self.hypervisor_name) - - def test_show_hypervisor_statistics_str_body(self): - self._test_show_hypervisor_statistics(bytes_body=False) - - def test_show_hypervisor_statistics_byte_body(self): - self._test_show_hypervisor_statistics(bytes_body=True) - - def _test_show_hypervisor_statistics(self, bytes_body=False): - expected = { - "hypervisor_statistics": { - "count": 1, - "current_workload": 0, - "disk_available_least": 0, - "free_disk_gb": 1028, - "free_ram_mb": 7680, - "local_gb": 1028, - "local_gb_used": 0, - "memory_mb": 8192, - "memory_mb_used": 512, - "running_vms": 0, - "vcpus": 1, - "vcpus_used": 0}} - self.check_service_client_function( - self.client.show_hypervisor_statistics, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body) - - def test_show_hypervisor_uptime_str_body(self): - self._test_show_hypervisor_uptime(bytes_body=False) - - def test_show_hypervisor_uptime_byte_body(self): - self._test_show_hypervisor_uptime(bytes_body=True) - - def _test_show_hypervisor_uptime(self, bytes_body=False): - expected = { - "hypervisor": { - "hypervisor_hostname": "fake-mini", - "id": 1, - "uptime": (" 08:32:11 up 93 days, 18:25, 12 users, " - " load average: 0.20, 0.12, 0.14") - }} - self.check_service_client_function( - self.client.show_hypervisor_uptime, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body, - hypervisor_id=self.hypervisor_id) - - def test_search_hypervisor_str_body(self): - self._test_search_hypervisor(bytes_body=False) - - def test_search_hypervisor_byte_body(self): - self._test_search_hypervisor(bytes_body=True) - - def _test_search_hypervisor(self, bytes_body=False): - expected = {"hypervisors": [{ - "id": 2, - "hypervisor_hostname": "hyper.hostname.com"}]} - self.check_service_client_function( - self.client.search_hypervisor, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body, - hypervisor_name=self.hypervisor_name) diff --git a/tempest_lib/tests/services/compute/test_images_client.py b/tempest_lib/tests/services/compute/test_images_client.py deleted file mode 100644 index f0079c0..0000000 --- a/tempest_lib/tests/services/compute/test_images_client.py +++ /dev/null @@ -1,265 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from oslotest import mockpatch - -from tempest_lib import exceptions as lib_exc -from tempest_lib.services.compute import images_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestImagesClient(base.BaseComputeServiceTest): - # Data Dictionaries used for testing # - FAKE_IMAGE_METADATA = { - "list": - {"metadata": { - "auto_disk_config": "True", - "Label": "Changed" - }}, - "set_item": - {"meta": { - "auto_disk_config": "True" - }}, - "show_item": - {"meta": { - "kernel_id": "nokernel", - }}, - "update": - {"metadata": { - "kernel_id": "False", - "Label": "UpdatedImage" - }}, - "set": - {"metadata": { - "Label": "Changed", - "auto_disk_config": "True" - }}, - "delete_item": {} - } - - FAKE_IMAGE_DATA = { - "list": - {"images": [ - {"id": "70a599e0-31e7-49b7-b260-868f441e862b", - "links": [ - {"href": "http://openstack.example.com/v2/openstack" + - "/images/70a599e0-31e7-49b7-b260-868f441e862b", - "rel": "self" - } - ], - "name": "fakeimage7" - }]}, - "show": {"image": { - "created": "2011-01-01T01:02:03Z", - "id": "70a599e0-31e7-49b7-b260-868f441e862b", - "links": [ - { - "href": "http://openstack.example.com/v2/openstack" + - "/images/70a599e0-31e7-49b7-b260-868f441e862b", - "rel": "self" - }, - ], - "metadata": { - "architecture": "x86_64", - "auto_disk_config": "True", - "kernel_id": "nokernel", - "ramdisk_id": "nokernel" - }, - "minDisk": 0, - "minRam": 0, - "name": "fakeimage7", - "progress": 100, - "status": "ACTIVE", - "updated": "2011-01-01T01:02:03Z"}}, - "create": {}, - "delete": {} - } - func2mock = { - 'get': 'tempest_lib.common.rest_client.RestClient.get', - 'post': 'tempest_lib.common.rest_client.RestClient.post', - 'put': 'tempest_lib.common.rest_client.RestClient.put', - 'delete': 'tempest_lib.common.rest_client.RestClient.delete'} - # Variable definition - FAKE_IMAGE_ID = FAKE_IMAGE_DATA['show']['image']['id'] - FAKE_SERVER_ID = "80a599e0-31e7-49b7-b260-868f441e343f" - FAKE_CREATE_INFO = {'location': 'None'} - FAKE_METADATA = FAKE_IMAGE_METADATA['show_item']['meta'] - - def setUp(self): - super(TestImagesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = images_client.ImagesClient(fake_auth, - "compute", "regionOne") - - def _test_image_operation(self, operation="delete", bytes_body=False): - response_code = 200 - mock_operation = self.func2mock['get'] - expected_op = self.FAKE_IMAGE_DATA[operation] - params = {"image_id": self.FAKE_IMAGE_ID} - headers = None - if operation == 'list': - function = self.client.list_images - elif operation == 'show': - function = self.client.show_image - elif operation == 'create': - function = self.client.create_image - mock_operation = self.func2mock['post'] - params = {"server_id": self.FAKE_SERVER_ID} - response_code = 202 - headers = { - 'connection': 'keep-alive', - 'content-length': '0', - 'content-type': 'application/json', - 'status': '202', - 'x-compute-request-id': 'req-fake', - 'vary': 'accept-encoding', - 'x-openstack-nova-api-version': 'v2.1', - 'date': '13 Oct 2015 05:55:36 GMT', - 'location': 'http://fake.com/images/fake' - } - else: - function = self.client.delete_image - mock_operation = self.func2mock['delete'] - response_code = 204 - - self.check_service_client_function( - function, mock_operation, expected_op, - bytes_body, response_code, headers, **params) - - def _test_image_metadata(self, operation="set_item", bytes_body=False): - response_code = 200 - expected_op = self.FAKE_IMAGE_METADATA[operation] - if operation == 'list': - function = self.client.list_image_metadata - mock_operation = self.func2mock['get'] - params = {"image_id": self.FAKE_IMAGE_ID} - - elif operation == 'set': - function = self.client.set_image_metadata - mock_operation = self.func2mock['put'] - params = {"image_id": "_dummy_data", - "meta": self.FAKE_METADATA} - - elif operation == 'update': - function = self.client.update_image_metadata - mock_operation = self.func2mock['post'] - params = {"image_id": self.FAKE_IMAGE_ID, - "meta": self.FAKE_METADATA} - - elif operation == 'show_item': - mock_operation = self.func2mock['get'] - function = self.client.show_image_metadata_item - params = {"image_id": self.FAKE_IMAGE_ID, - "key": "123"} - - elif operation == 'delete_item': - function = self.client.delete_image_metadata_item - mock_operation = self.func2mock['delete'] - response_code = 204 - params = {"image_id": self.FAKE_IMAGE_ID, - "key": "123"} - - else: - function = self.client.set_image_metadata_item - mock_operation = self.func2mock['put'] - params = {"image_id": self.FAKE_IMAGE_ID, - "key": "123", - "meta": self.FAKE_METADATA} - - self.check_service_client_function( - function, mock_operation, expected_op, - bytes_body, response_code, **params) - - def _test_resource_deleted(self, bytes_body=False): - params = {"id": self.FAKE_IMAGE_ID} - expected_op = self.FAKE_IMAGE_DATA['show']['image'] - self.useFixture(mockpatch.Patch('tempest_lib.services.compute' - '.images_client.ImagesClient.show_image', - side_effect=lib_exc.NotFound)) - self.assertEqual(True, self.client.is_resource_deleted(**params)) - tempdata = copy.deepcopy(self.FAKE_IMAGE_DATA['show']) - tempdata['image']['id'] = None - self.useFixture(mockpatch.Patch('tempest_lib.services.compute' - '.images_client.ImagesClient.show_image', - return_value=expected_op)) - self.assertEqual(False, self.client.is_resource_deleted(**params)) - - def test_list_images_with_str_body(self): - self._test_image_operation('list') - - def test_list_images_with_bytes_body(self): - self._test_image_operation('list', True) - - def test_show_image_with_str_body(self): - self._test_image_operation('show') - - def test_show_image_with_bytes_body(self): - self._test_image_operation('show', True) - - def test_create_image_with_str_body(self): - self._test_image_operation('create') - - def test_create_image_with_bytes_body(self): - self._test_image_operation('create', True) - - def test_delete_image_with_str_body(self): - self._test_image_operation('delete') - - def test_delete_image_with_bytes_body(self): - self._test_image_operation('delete', True) - - def test_list_image_metadata_with_str_body(self): - self._test_image_metadata('list') - - def test_list_image_metadata_with_bytes_body(self): - self._test_image_metadata('list', True) - - def test_set_image_metadata_with_str_body(self): - self._test_image_metadata('set') - - def test_set_image_metadata_with_bytes_body(self): - self._test_image_metadata('set', True) - - def test_update_image_metadata_with_str_body(self): - self._test_image_metadata('update') - - def test_update_image_metadata_with_bytes_body(self): - self._test_image_metadata('update', True) - - def test_set_image_metadata_item_with_str_body(self): - self._test_image_metadata() - - def test_set_image_metadata_item_with_bytes_body(self): - self._test_image_metadata(bytes_body=True) - - def test_show_image_metadata_item_with_str_body(self): - self._test_image_metadata('show_item') - - def test_show_image_metadata_item_with_bytes_body(self): - self._test_image_metadata('show_item', True) - - def test_delete_image_metadata_item_with_str_body(self): - self._test_image_metadata('delete_item') - - def test_delete_image_metadata_item_with_bytes_body(self): - self._test_image_metadata('delete_item', True) - - def test_resource_delete_with_str_body(self): - self._test_resource_deleted() - - def test_resource_delete_with_bytes_body(self): - self._test_resource_deleted(True) diff --git a/tempest_lib/tests/services/compute/test_instance_usage_audit_log_client.py b/tempest_lib/tests/services/compute/test_instance_usage_audit_log_client.py deleted file mode 100644 index 78ade47..0000000 --- a/tempest_lib/tests/services/compute/test_instance_usage_audit_log_client.py +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import datetime - -from tempest_lib.services.compute import instance_usage_audit_log_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestInstanceUsagesAuditLogClient(base.BaseComputeServiceTest): - - FAKE_AUDIT_LOG = { - "hosts_not_run": [ - "f4eb7cfd155f4574967f8b55a7faed75" - ], - "log": {}, - "num_hosts": 1, - "num_hosts_done": 0, - "num_hosts_not_run": 1, - "num_hosts_running": 0, - "overall_status": "0 of 1 hosts done. 0 errors.", - "period_beginning": "2012-12-01 00:00:00", - "period_ending": "2013-01-01 00:00:00", - "total_errors": 0, - "total_instances": 0 - } - - def setUp(self): - super(TestInstanceUsagesAuditLogClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = (instance_usage_audit_log_client. - InstanceUsagesAuditLogClient(fake_auth, 'compute', - 'regionOne')) - - def _test_list_instance_usage_audit_logs(self, bytes_body=False): - self.check_service_client_function( - self.client.list_instance_usage_audit_logs, - 'tempest_lib.common.rest_client.RestClient.get', - {"instance_usage_audit_logs": self.FAKE_AUDIT_LOG}, - bytes_body) - - def test_list_instance_usage_audit_logs_with_str_body(self): - self._test_list_instance_usage_audit_logs() - - def test_list_instance_usage_audit_logs_with_bytes_body(self): - self._test_list_instance_usage_audit_logs(bytes_body=True) - - def _test_show_instance_usage_audit_log(self, bytes_body=False): - before_time = datetime.datetime(2012, 12, 1, 0, 0) - self.check_service_client_function( - self.client.show_instance_usage_audit_log, - 'tempest_lib.common.rest_client.RestClient.get', - {"instance_usage_audit_log": self.FAKE_AUDIT_LOG}, - bytes_body, - time_before=before_time) - - def test_show_instance_usage_audit_log_with_str_body(self): - self._test_show_instance_usage_audit_log() - - def test_show_network_with_bytes_body_with_bytes_body(self): - self._test_show_instance_usage_audit_log(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_interfaces_client.py b/tempest_lib/tests/services/compute/test_interfaces_client.py deleted file mode 100644 index 4456ce7..0000000 --- a/tempest_lib/tests/services/compute/test_interfaces_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import interfaces_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestInterfacesClient(base.BaseComputeServiceTest): - # Data Values to be used for testing # - FAKE_INTERFACE_DATA = { - "fixed_ips": [{ - "ip_address": "192.168.1.1", - "subnet_id": "f8a6e8f8-c2ec-497c-9f23-da9616de54ef" - }], - "mac_addr": "fa:16:3e:4c:2c:30", - "net_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6", - "port_id": "ce531f90-199f-48c0-816c-13e38010b442", - "port_state": "ACTIVE"} - - FAKE_SHOW_DATA = { - "interfaceAttachment": FAKE_INTERFACE_DATA} - FAKE_LIST_DATA = { - "interfaceAttachments": [FAKE_INTERFACE_DATA]} - - FAKE_SERVER_ID = "ec14c864-096e-4e27-bb8a-2c2b4dc6f3f5" - FAKE_PORT_ID = FAKE_SHOW_DATA['interfaceAttachment']['port_id'] - func2mock = { - 'delete': 'tempest_lib.common.rest_client.RestClient.delete', - 'get': 'tempest_lib.common.rest_client.RestClient.get', - 'post': 'tempest_lib.common.rest_client.RestClient.post'} - - def setUp(self): - super(TestInterfacesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = interfaces_client.InterfacesClient(fake_auth, - "compute", - "regionOne") - - def _test_interface_operation(self, operation="create", bytes_body=False): - response_code = 200 - expected_op = self.FAKE_SHOW_DATA - mock_operation = self.func2mock['get'] - params = {'server_id': self.FAKE_SERVER_ID, - 'port_id': self.FAKE_PORT_ID} - if operation == 'list': - expected_op = self.FAKE_LIST_DATA - function = self.client.list_interfaces - params = {'server_id': self.FAKE_SERVER_ID} - elif operation == 'show': - function = self.client.show_interface - elif operation == 'delete': - expected_op = {} - mock_operation = self.func2mock['delete'] - function = self.client.delete_interface - response_code = 202 - else: - function = self.client.create_interface - mock_operation = self.func2mock['post'] - - self.check_service_client_function( - function, mock_operation, expected_op, - bytes_body, response_code, **params) - - def test_list_interfaces_with_str_body(self): - self._test_interface_operation('list') - - def test_list_interfaces_with_bytes_body(self): - self._test_interface_operation('list', True) - - def test_show_interface_with_str_body(self): - self._test_interface_operation('show') - - def test_show_interface_with_bytes_body(self): - self._test_interface_operation('show', True) - - def test_delete_interface_with_str_body(self): - self._test_interface_operation('delete') - - def test_delete_interface_with_bytes_body(self): - self._test_interface_operation('delete', True) - - def test_create_interface_with_str_body(self): - self._test_interface_operation() - - def test_create_interface_with_bytes_body(self): - self._test_interface_operation(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_keypairs_client.py b/tempest_lib/tests/services/compute/test_keypairs_client.py deleted file mode 100644 index 6458e67..0000000 --- a/tempest_lib/tests/services/compute/test_keypairs_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from tempest_lib.services.compute import keypairs_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestKeyPairsClient(base.BaseComputeServiceTest): - - FAKE_KEYPAIR = {"keypair": { - "public_key": "ssh-rsa foo Generated-by-Nova", - "name": u'\u2740(*\xb4\u25e1`*)\u2740', - "user_id": "525d55f98980415ba98e634972fa4a10", - "fingerprint": "76:24:66:49:d7:ca:6e:5c:77:ea:8e:bb:9c:15:5f:98" - }} - - def setUp(self): - super(TestKeyPairsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = keypairs_client.KeyPairsClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_keypairs(self, bytes_body=False): - self.check_service_client_function( - self.client.list_keypairs, - 'tempest_lib.common.rest_client.RestClient.get', - {"keypairs": []}, - bytes_body) - - def test_list_keypairs_with_str_body(self): - self._test_list_keypairs() - - def test_list_keypairs_with_bytes_body(self): - self._test_list_keypairs(bytes_body=True) - - def _test_show_keypair(self, bytes_body=False): - fake_keypair = copy.deepcopy(self.FAKE_KEYPAIR) - fake_keypair["keypair"].update({ - "deleted": False, - "created_at": "2015-07-22T04:53:52.000000", - "updated_at": None, - "deleted_at": None, - "id": 1 - }) - - self.check_service_client_function( - self.client.show_keypair, - 'tempest_lib.common.rest_client.RestClient.get', - fake_keypair, - bytes_body, - keypair_name="test") - - def test_show_keypair_with_str_body(self): - self._test_show_keypair() - - def test_show_keypair_with_bytes_body(self): - self._test_show_keypair(bytes_body=True) - - def _test_create_keypair(self, bytes_body=False): - fake_keypair = copy.deepcopy(self.FAKE_KEYPAIR) - fake_keypair["keypair"].update({"private_key": "foo"}) - - self.check_service_client_function( - self.client.create_keypair, - 'tempest_lib.common.rest_client.RestClient.post', - fake_keypair, - bytes_body, - name="test") - - def test_create_keypair_with_str_body(self): - self._test_create_keypair() - - def test_create_keypair_with_bytes_body(self): - self._test_create_keypair(bytes_body=True) - - def test_delete_keypair(self): - self.check_service_client_function( - self.client.delete_keypair, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=202, keypair_name='test') diff --git a/tempest_lib/tests/services/compute/test_limits_client.py b/tempest_lib/tests/services/compute/test_limits_client.py deleted file mode 100644 index c84b75e..0000000 --- a/tempest_lib/tests/services/compute/test_limits_client.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import limits_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestLimitsClient(base.BaseComputeServiceTest): - - def setUp(self): - super(TestLimitsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = limits_client.LimitsClient( - fake_auth, 'compute', 'regionOne') - - def _test_show_limits(self, bytes_body=False): - expected = { - "limits": { - "rate": [], - "absolute": { - "maxServerMeta": 128, - "maxPersonality": 5, - "totalServerGroupsUsed": 0, - "maxImageMeta": 128, - "maxPersonalitySize": 10240, - "maxServerGroups": 10, - "maxSecurityGroupRules": 20, - "maxTotalKeypairs": 100, - "totalCoresUsed": 0, - "totalRAMUsed": 0, - "totalInstancesUsed": 0, - "maxSecurityGroups": 10, - "totalFloatingIpsUsed": 0, - "maxTotalCores": 20, - "totalSecurityGroupsUsed": 0, - "maxTotalFloatingIps": 10, - "maxTotalInstances": 10, - "maxTotalRAMSize": 51200, - "maxServerGroupMembers": 10 - } - } - } - - self.check_service_client_function( - self.client.show_limits, - 'tempest_lib.common.rest_client.RestClient.get', - expected, - bytes_body) - - def test_show_limits_with_str_body(self): - self._test_show_limits() - - def test_show_limits_with_bytes_body(self): - self._test_show_limits(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_migrations_client.py b/tempest_lib/tests/services/compute/test_migrations_client.py deleted file mode 100644 index a949d67..0000000 --- a/tempest_lib/tests/services/compute/test_migrations_client.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import migrations_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestMigrationsClient(base.BaseComputeServiceTest): - FAKE_MIGRATION_INFO = {"migrations": [{ - "created_at": "2012-10-29T13:42:02", - "dest_compute": "compute2", - "dest_host": "1.2.3.4", - "dest_node": "node2", - "id": 1234, - "instance_uuid": "e9e4fdd7-f956-44ff-bfeb-d654a96ab3a2", - "new_instance_type_id": 2, - "old_instance_type_id": 1, - "source_compute": "compute1", - "source_node": "node1", - "status": "finished", - "updated_at": "2012-10-29T13:42:02"}]} - - def setUp(self): - super(TestMigrationsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.mg_client_obj = migrations_client.MigrationsClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_migrations(self, bytes_body=False): - self.check_service_client_function( - self.mg_client_obj.list_migrations, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_MIGRATION_INFO, - bytes_body) - - def test_list_migration_with_str_body(self): - self._test_list_migrations() - - def test_list_migration_with_bytes_body(self): - self._test_list_migrations(True) diff --git a/tempest_lib/tests/services/compute/test_networks_client.py b/tempest_lib/tests/services/compute/test_networks_client.py deleted file mode 100644 index c3b2a98..0000000 --- a/tempest_lib/tests/services/compute/test_networks_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import networks_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestNetworksClient(base.BaseComputeServiceTest): - - FAKE_NETWORK = { - "bridge": None, - "vpn_public_port": None, - "dhcp_start": None, - "bridge_interface": None, - "share_address": None, - "updated_at": None, - "id": "34d5ae1e-5659-49cf-af80-73bccd7d7ad3", - "cidr_v6": None, - "deleted_at": None, - "gateway": None, - "rxtx_base": None, - "label": u'30d7', - "priority": None, - "project_id": None, - "vpn_private_address": None, - "deleted": None, - "vlan": None, - "broadcast": None, - "netmask": None, - "injected": None, - "cidr": None, - "vpn_public_address": None, - "multi_host": None, - "enable_dhcp": None, - "dns2": None, - "created_at": None, - "host": None, - "mtu": None, - "gateway_v6": None, - "netmask_v6": None, - "dhcp_server": None, - "dns1": None - } - - network_id = "34d5ae1e-5659-49cf-af80-73bccd7d7ad3" - - FAKE_NETWORKS = [FAKE_NETWORK] - - def setUp(self): - super(TestNetworksClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = networks_client.NetworksClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_networks(self, bytes_body=False): - fake_list = {"networks": self.FAKE_NETWORKS} - self.check_service_client_function( - self.client.list_networks, - 'tempest_lib.common.rest_client.RestClient.get', - fake_list, - bytes_body) - - def test_list_networks_with_str_body(self): - self._test_list_networks() - - def test_list_networks_with_bytes_body(self): - self._test_list_networks(bytes_body=True) - - def _test_show_network(self, bytes_body=False): - self.check_service_client_function( - self.client.show_network, - 'tempest_lib.common.rest_client.RestClient.get', - {"network": self.FAKE_NETWORK}, - bytes_body, - network_id=self.network_id - ) - - def test_show_network_with_str_body(self): - self._test_show_network() - - def test_show_network_with_bytes_body(self): - self._test_show_network(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_quota_classes_client.py b/tempest_lib/tests/services/compute/test_quota_classes_client.py deleted file mode 100644 index 309e026..0000000 --- a/tempest_lib/tests/services/compute/test_quota_classes_client.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from tempest_lib.services.compute import quota_classes_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestQuotaClassesClient(base.BaseComputeServiceTest): - - FAKE_QUOTA_CLASS_SET = { - "injected_file_content_bytes": 10240, - "metadata_items": 128, - "server_group_members": 10, - "server_groups": 10, - "ram": 51200, - "floating_ips": 10, - "key_pairs": 100, - "id": u'\u2740(*\xb4\u25e1`*)\u2740', - "instances": 10, - "security_group_rules": 20, - "security_groups": 10, - "injected_files": 5, - "cores": 20, - "fixed_ips": -1, - "injected_file_path_bytes": 255, - } - - def setUp(self): - super(TestQuotaClassesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = quota_classes_client.QuotaClassesClient( - fake_auth, 'compute', 'regionOne') - - def _test_show_quota_class_set(self, bytes_body=False): - fake_body = {'quota_class_set': self.FAKE_QUOTA_CLASS_SET} - self.check_service_client_function( - self.client.show_quota_class_set, - 'tempest_lib.common.rest_client.RestClient.get', - fake_body, - bytes_body, - quota_class_id="test") - - def test_show_quota_class_set_with_str_body(self): - self._test_show_quota_class_set() - - def test_show_quota_class_set_with_bytes_body(self): - self._test_show_quota_class_set(bytes_body=True) - - def test_update_quota_class_set(self): - fake_quota_class_set = copy.deepcopy(self.FAKE_QUOTA_CLASS_SET) - fake_quota_class_set.pop("id") - fake_body = {'quota_class_set': fake_quota_class_set} - self.check_service_client_function( - self.client.update_quota_class_set, - 'tempest_lib.common.rest_client.RestClient.put', - fake_body, - quota_class_id="test") diff --git a/tempest_lib/tests/services/compute/test_quotas_client.py b/tempest_lib/tests/services/compute/test_quotas_client.py deleted file mode 100644 index 9c8fb49..0000000 --- a/tempest_lib/tests/services/compute/test_quotas_client.py +++ /dev/null @@ -1,130 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from tempest_lib.services.compute import quotas_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestQuotasClient(base.BaseComputeServiceTest): - - FAKE_QUOTA_SET = { - "quota_set": { - "injected_file_content_bytes": 10240, - "metadata_items": 128, - "server_group_members": 10, - "server_groups": 10, - "ram": 51200, - "floating_ips": 10, - "key_pairs": 100, - "id": "8421f7be61064f50b680465c07f334af", - "instances": 10, - "security_group_rules": 20, - "injected_files": 5, - "cores": 20, - "fixed_ips": -1, - "injected_file_path_bytes": 255, - "security_groups": 10} - } - - project_id = "8421f7be61064f50b680465c07f334af" - fake_user_id = "65f09168cbb04eb593f3138b63b67b67" - - def setUp(self): - super(TestQuotasClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = quotas_client.QuotasClient( - fake_auth, 'compute', 'regionOne') - - def _test_show_quota_set(self, bytes_body=False, user_id=None): - if user_id: - self.check_service_client_function( - self.client.show_quota_set, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_QUOTA_SET, - to_utf=bytes_body, - tenant_id=self.project_id, - user_id=user_id) - else: - self.check_service_client_function( - self.client.show_quota_set, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_QUOTA_SET, - to_utf=bytes_body, - tenant_id=self.project_id) - - def test_show_quota_set_with_str_body(self): - self._test_show_quota_set() - - def test_show_quota_set_with_bytes_body(self): - self._test_show_quota_set(bytes_body=True) - - def test_show_quota_set_for_user_with_str_body(self): - self._test_show_quota_set(user_id=self.fake_user_id) - - def test_show_quota_set_for_user_with_bytes_body(self): - self._test_show_quota_set(bytes_body=True, user_id=self.fake_user_id) - - def _test_show_default_quota_set(self, bytes_body=False): - self.check_service_client_function( - self.client.show_default_quota_set, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_QUOTA_SET, - to_utf=bytes_body, - tenant_id=self.project_id) - - def test_show_default_quota_set_with_str_body(self): - self._test_show_default_quota_set() - - def test_show_default_quota_set_with_bytes_body(self): - self._test_show_default_quota_set(bytes_body=True) - - def _test_update_quota_set(self, bytes_body=False, user_id=None): - fake_quota_set = copy.deepcopy(self.FAKE_QUOTA_SET) - fake_quota_set['quota_set'].pop("id") - if user_id: - self.check_service_client_function( - self.client.update_quota_set, - 'tempest_lib.common.rest_client.RestClient.put', - fake_quota_set, - to_utf=bytes_body, - tenant_id=self.project_id, - user_id=user_id) - else: - self.check_service_client_function( - self.client.update_quota_set, - 'tempest_lib.common.rest_client.RestClient.put', - fake_quota_set, - to_utf=bytes_body, - tenant_id=self.project_id) - - def test_update_quota_set_with_str_body(self): - self._test_update_quota_set() - - def test_update_quota_set_with_bytes_body(self): - self._test_update_quota_set(bytes_body=True) - - def test_update_quota_set_for_user_with_str_body(self): - self._test_update_quota_set(user_id=self.fake_user_id) - - def test_update_quota_set_for_user_with_bytes_body(self): - self._test_update_quota_set(bytes_body=True, user_id=self.fake_user_id) - - def test_delete_quota_set(self): - self.check_service_client_function( - self.client.delete_quota_set, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=202, tenant_id=self.project_id) diff --git a/tempest_lib/tests/services/compute/test_security_group_default_rules_client.py b/tempest_lib/tests/services/compute/test_security_group_default_rules_client.py deleted file mode 100644 index d8a5f64..0000000 --- a/tempest_lib/tests/services/compute/test_security_group_default_rules_client.py +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import security_group_default_rules_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestSecurityGroupDefaultRulesClient(base.BaseComputeServiceTest): - FAKE_RULE = { - "from_port": 80, - "id": 1, - "ip_protocol": "TCP", - "ip_range": { - "cidr": "10.10.10.0/24" - }, - "to_port": 80 - } - - def setUp(self): - super(TestSecurityGroupDefaultRulesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = (security_group_default_rules_client. - SecurityGroupDefaultRulesClient(fake_auth, 'compute', - 'regionOne')) - - def _test_list_security_group_default_rules(self, bytes_body=False): - self.check_service_client_function( - self.client.list_security_group_default_rules, - 'tempest_lib.common.rest_client.RestClient.get', - {"security_group_default_rules": [self.FAKE_RULE]}, - to_utf=bytes_body) - - def test_list_security_group_default_rules_with_str_body(self): - self._test_list_security_group_default_rules() - - def test_list_security_group_default_rules_with_bytes_body(self): - self._test_list_security_group_default_rules(bytes_body=True) - - def _test_show_security_group_default_rule(self, bytes_body=False): - self.check_service_client_function( - self.client.show_security_group_default_rule, - 'tempest_lib.common.rest_client.RestClient.get', - {"security_group_default_rule": self.FAKE_RULE}, - to_utf=bytes_body, - security_group_default_rule_id=1) - - def test_show_security_group_default_rule_with_str_body(self): - self._test_show_security_group_default_rule() - - def test_show_security_group_default_rule_with_bytes_body(self): - self._test_show_security_group_default_rule(bytes_body=True) - - def _test_create_security_default_group_rule(self, bytes_body=False): - request_body = { - "to_port": 80, - "from_port": 80, - "ip_protocol": "TCP", - "cidr": "10.10.10.0/24" - } - self.check_service_client_function( - self.client.create_security_default_group_rule, - 'tempest_lib.common.rest_client.RestClient.post', - {"security_group_default_rule": self.FAKE_RULE}, - to_utf=bytes_body, **request_body) - - def test_create_security_default_group_rule_with_str_body(self): - self._test_create_security_default_group_rule() - - def test_create_security_default_group_rule_with_bytes_body(self): - self._test_create_security_default_group_rule(bytes_body=True) - - def test_delete_security_group_default_rule(self): - self.check_service_client_function( - self.client.delete_security_group_default_rule, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=204, security_group_default_rule_id=1) diff --git a/tempest_lib/tests/services/compute/test_security_group_rules_client.py b/tempest_lib/tests/services/compute/test_security_group_rules_client.py deleted file mode 100644 index 2ff3229..0000000 --- a/tempest_lib/tests/services/compute/test_security_group_rules_client.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import security_group_rules_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestSecurityGroupRulesClient(base.BaseComputeServiceTest): - - FAKE_SECURITY_GROUP_RULE = { - "security_group_rule": { - "id": "2d021cf1-ce4b-4292-994f-7a785d62a144", - "ip_range": { - "cidr": "0.0.0.0/0" - }, - "parent_group_id": "48700ff3-30b8-4e63-845f-a79c9633e9fb", - "to_port": 443, - "ip_protocol": "tcp", - "group": {}, - "from_port": 443 - } - } - - def setUp(self): - super(TestSecurityGroupRulesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = security_group_rules_client.SecurityGroupRulesClient( - fake_auth, 'compute', 'regionOne') - - def _test_create_security_group_rule(self, bytes_body=False): - req_body = { - "from_port": "443", - "ip_protocol": "tcp", - "to_port": "443", - "cidr": "0.0.0.0/0", - "parent_group_id": "48700ff3-30b8-4e63-845f-a79c9633e9fb" - } - self.check_service_client_function( - self.client.create_security_group_rule, - 'tempest_lib.common.rest_client.RestClient.post', - self.FAKE_SECURITY_GROUP_RULE, - to_utf=bytes_body, **req_body) - - def test_create_security_group_rule_with_str_body(self): - self._test_create_security_group_rule() - - def test_create_security_group_rule_with_bytes_body(self): - self._test_create_security_group_rule(bytes_body=True) - - def test_delete_security_group_rule(self): - self.check_service_client_function( - self.client.delete_security_group_rule, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=202, group_rule_id='group-id') diff --git a/tempest_lib/tests/services/compute/test_security_groups_client.py b/tempest_lib/tests/services/compute/test_security_groups_client.py deleted file mode 100644 index 1d44b89..0000000 --- a/tempest_lib/tests/services/compute/test_security_groups_client.py +++ /dev/null @@ -1,113 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslotest import mockpatch - -from tempest_lib import exceptions as lib_exc -from tempest_lib.services.compute import security_groups_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestSecurityGroupsClient(base.BaseComputeServiceTest): - - FAKE_SECURITY_GROUP_INFO = [{ - "description": "default", - "id": "3fb26eb3-581b-4420-9963-b0879a026506", - "name": "default", - "rules": [], - "tenant_id": "openstack" - }] - - def setUp(self): - super(TestSecurityGroupsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = security_groups_client.SecurityGroupsClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_security_groups(self, bytes_body=False): - self.check_service_client_function( - self.client.list_security_groups, - 'tempest_lib.common.rest_client.RestClient.get', - {"security_groups": self.FAKE_SECURITY_GROUP_INFO}, - to_utf=bytes_body) - - def test_list_security_groups_with_str_body(self): - self._test_list_security_groups() - - def test_list_security_groups_with_bytes_body(self): - self._test_list_security_groups(bytes_body=True) - - def _test_show_security_group(self, bytes_body=False): - self.check_service_client_function( - self.client.show_security_group, - 'tempest_lib.common.rest_client.RestClient.get', - {"security_group": self.FAKE_SECURITY_GROUP_INFO[0]}, - to_utf=bytes_body, - security_group_id='fake-id') - - def test_show_security_group_with_str_body(self): - self._test_show_security_group() - - def test_show_security_group_with_bytes_body(self): - self._test_show_security_group(bytes_body=True) - - def _test_create_security_group(self, bytes_body=False): - post_body = {"name": "test", "description": "test_group"} - self.check_service_client_function( - self.client.create_security_group, - 'tempest_lib.common.rest_client.RestClient.post', - {"security_group": self.FAKE_SECURITY_GROUP_INFO[0]}, - to_utf=bytes_body, - kwargs=post_body) - - def test_create_security_group_with_str_body(self): - self._test_create_security_group() - - def test_create_security_group_with_bytes_body(self): - self._test_create_security_group(bytes_body=True) - - def _test_update_security_group(self, bytes_body=False): - req_body = {"name": "test", "description": "test_group"} - self.check_service_client_function( - self.client.update_security_group, - 'tempest_lib.common.rest_client.RestClient.put', - {"security_group": self.FAKE_SECURITY_GROUP_INFO[0]}, - to_utf=bytes_body, - security_group_id='fake-id', - kwargs=req_body) - - def test_update_security_group_with_str_body(self): - self._test_update_security_group() - - def test_update_security_group_with_bytes_body(self): - self._test_update_security_group(bytes_body=True) - - def test_delete_security_group(self): - self.check_service_client_function( - self.client.delete_security_group, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=202, security_group_id='fake-id') - - def test_is_resource_deleted_true(self): - mod = ('tempest_lib.services.compute.security_groups_client.' - 'SecurityGroupsClient.show_security_group') - self.useFixture(mockpatch.Patch(mod, side_effect=lib_exc.NotFound)) - self.assertTrue(self.client.is_resource_deleted('fake-id')) - - def test_is_resource_deleted_false(self): - mod = ('tempest_lib.services.compute.security_groups_client.' - 'SecurityGroupsClient.show_security_group') - self.useFixture(mockpatch.Patch(mod, return_value='success')) - self.assertFalse(self.client.is_resource_deleted('fake-id')) diff --git a/tempest_lib/tests/services/compute/test_server_groups_client.py b/tempest_lib/tests/services/compute/test_server_groups_client.py deleted file mode 100644 index 93e1bde..0000000 --- a/tempest_lib/tests/services/compute/test_server_groups_client.py +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright 2015 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import httplib2 - -from oslotest import mockpatch -from tempest_lib.tests import fake_auth_provider - -from tempest_lib.services.compute import server_groups_client -from tempest_lib.tests.services.compute import base - - -class TestServerGroupsClient(base.BaseComputeServiceTest): - - server_group = { - "id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9", - "name": "test", - "policies": ["anti-affinity"], - "members": [], - "metadata": {}} - - def setUp(self): - super(TestServerGroupsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = server_groups_client.ServerGroupsClient( - fake_auth, 'compute', 'regionOne') - - def _test_create_server_group(self, bytes_body=False): - expected = {"server_group": TestServerGroupsClient.server_group} - self.check_service_client_function( - self.client.create_server_group, - 'tempest_lib.common.rest_client.RestClient.post', expected, - bytes_body, name='fake-group', policies=['affinity']) - - def test_create_server_group_str_body(self): - self._test_create_server_group(bytes_body=False) - - def test_create_server_group_byte_body(self): - self._test_create_server_group(bytes_body=True) - - def test_delete_server_group(self): - response = (httplib2.Response({'status': 204}), None) - self.useFixture(mockpatch.Patch( - 'tempest_lib.common.rest_client.RestClient.delete', - return_value=response)) - self.client.delete_server_group('fake-group') - - def _test_list_server_groups(self, bytes_body=False): - expected = {"server_groups": [TestServerGroupsClient.server_group]} - self.check_service_client_function( - self.client.list_server_groups, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body) - - def test_list_server_groups_str_body(self): - self._test_list_server_groups(bytes_body=False) - - def test_list_server_groups_byte_body(self): - self._test_list_server_groups(bytes_body=True) - - def _test_show_server_group(self, bytes_body=False): - expected = {"server_group": TestServerGroupsClient.server_group} - self.check_service_client_function( - self.client.show_server_group, - 'tempest_lib.common.rest_client.RestClient.get', - expected, bytes_body, - server_group_id='5bbcc3c4-1da2-4437-a48a-66f15b1b13f9') - - def test_show_server_group_str_body(self): - self._test_show_server_group(bytes_body=False) - - def test_show_server_group_byte_body(self): - self._test_show_server_group(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_servers_client.py b/tempest_lib/tests/services/compute/test_servers_client.py deleted file mode 100644 index d3a4e83..0000000 --- a/tempest_lib/tests/services/compute/test_servers_client.py +++ /dev/null @@ -1,1011 +0,0 @@ -# Copyright 2015 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from tempest_lib.services.compute import servers_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestServersClient(base.BaseComputeServiceTest): - - FAKE_SERVERS = {'servers': [{ - "id": "616fb98f-46ca-475e-917e-2563e5a8cd19", - "links": [ - { - "href": "http://os.co/v2/616fb98f-46ca-475e-917e-2563e5a8cd19", - "rel": "self" - }, - { - "href": "http://os.co/616fb98f-46ca-475e-917e-2563e5a8cd19", - "rel": "bookmark" - } - ], - "name": u"new\u1234-server-test"}] - } - - FAKE_SERVER_DIAGNOSTICS = { - "cpu0_time": 17300000000, - "memory": 524288, - "vda_errors": -1, - "vda_read": 262144, - "vda_read_req": 112, - "vda_write": 5778432, - "vda_write_req": 488, - "vnet1_rx": 2070139, - "vnet1_rx_drop": 0, - "vnet1_rx_errors": 0, - "vnet1_rx_packets": 26701, - "vnet1_tx": 140208, - "vnet1_tx_drop": 0, - "vnet1_tx_errors": 0, - "vnet1_tx_packets": 662 - } - - FAKE_SERVER_GET = {'server': { - "accessIPv4": "", - "accessIPv6": "", - "addresses": { - "private": [ - { - "addr": "192.168.0.3", - "version": 4 - } - ] - }, - "created": "2012-08-20T21:11:09Z", - "flavor": { - "id": "1", - "links": [ - { - "href": "http://os.com/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "65201c14a29663e06d0748e561207d998b343e1d164bfa0aafa9c45d", - "id": "893c7791-f1df-4c3d-8383-3caae9656c62", - "image": { - "id": "70a599e0-31e7-49b7-b260-868f441e862b", - "links": [ - { - "href": "http://imgs/70a599e0-31e7-49b7-b260-868f441e862b", - "rel": "bookmark" - } - ] - }, - "links": [ - { - "href": "http://v2/srvs/893c7791-f1df-4c3d-8383-3caae9656c62", - "rel": "self" - }, - { - "href": "http://srvs/893c7791-f1df-4c3d-8383-3caae9656c62", - "rel": "bookmark" - } - ], - "metadata": { - u"My Server N\u1234me": u"Apa\u1234che1" - }, - "name": u"new\u1234-server-test", - "progress": 0, - "status": "ACTIVE", - "tenant_id": "openstack", - "updated": "2012-08-20T21:11:09Z", - "user_id": "fake"} - } - - FAKE_SERVER_POST = {"server": { - "id": "616fb98f-46ca-475e-917e-2563e5a8cd19", - "adminPass": "fake-admin-pass", - "security_groups": [ - 'fake-security-group-1', - 'fake-security-group-2' - ], - "links": [ - { - "href": "http://os.co/v2/616fb98f-46ca-475e-917e-2563e5a8cd19", - "rel": "self" - }, - { - "href": "http://os.co/616fb98f-46ca-475e-917e-2563e5a8cd19", - "rel": "bookmark" - } - ], - "OS-DCF:diskConfig": "fake-disk-config"} - } - - FAKE_ADDRESS = {"addresses": { - "private": [ - { - "addr": "192.168.0.3", - "version": 4 - } - ]} - } - - FAKE_COMMON_VOLUME = { - "id": "a6b0875b-6b5d-4a5a-81eb-0c3aa62e5fdb", - "device": "fake-device", - "volumeId": "a6b0875b-46ca-475e-917e-0c3aa62e5fdb", - "serverId": "616fb98f-46ca-475e-917e-2563e5a8cd19" - } - - FAKE_VIRTUAL_INTERFACES = { - "id": "a6b0875b-46ca-475e-917e-0c3aa62e5fdb", - "mac_address": "00:25:90:5b:f8:c3", - "OS-EXT-VIF-NET:net_id": "fake-os-net-id" - } - - FAKE_INSTANCE_ACTIONS = { - "action": "fake-action", - "request_id": "16fb98f-46ca-475e-917e-2563e5a8cd19", - "user_id": "16fb98f-46ca-475e-917e-2563e5a8cd12", - "project_id": "16fb98f-46ca-475e-917e-2563e5a8cd34", - "start_time": "09MAR2015 11:15", - "message": "fake-msg", - "instance_uuid": "16fb98f-46ca-475e-917e-2563e5a8cd12" - } - - FAKE_VNC_CONSOLE = { - "type": "fake-type", - "url": "http://os.co/v2/616fb98f-46ca-475e-917e-2563e5a8cd19" - } - - FAKE_INSTANCE_ACTION_EVENTS = { - "event": "fake-event", - "start_time": "09MAR2015 11:15", - "finish_time": "09MAR2015 11:15", - "result": "fake-result", - "traceback": "fake-trace-back" - } - - FAKE_INSTANCE_WITH_EVENTS = copy.deepcopy(FAKE_INSTANCE_ACTIONS) - FAKE_INSTANCE_WITH_EVENTS['events'] = [FAKE_INSTANCE_ACTION_EVENTS] - - FAKE_REBUILD_SERVER = copy.deepcopy(FAKE_SERVER_GET) - FAKE_REBUILD_SERVER['server']['adminPass'] = 'fake-admin-pass' - - server_id = FAKE_SERVER_GET['server']['id'] - network_id = 'a6b0875b-6b5d-4a5a-81eb-0c3aa62e5fdb' - - def setUp(self): - super(TestServersClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = servers_client.ServersClient( - fake_auth, 'compute', 'regionOne') - - def test_list_servers_with_str_body(self): - self._test_list_servers() - - def test_list_servers_with_bytes_body(self): - self._test_list_servers(bytes_body=True) - - def _test_list_servers(self, bytes_body=False): - self.check_service_client_function( - self.client.list_servers, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_SERVERS, - bytes_body) - - def test_show_server_with_str_body(self): - self._test_show_server() - - def test_show_server_with_bytes_body(self): - self._test_show_server(bytes_body=True) - - def _test_show_server(self, bytes_body=False): - self.check_service_client_function( - self.client.show_server, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_SERVER_GET, - bytes_body, - server_id=self.server_id - ) - - def test_delete_server(self, bytes_body=False): - self.check_service_client_function( - self.client.delete_server, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, - status=204, - server_id=self.server_id - ) - - def test_create_server_with_str_body(self): - self._test_create_server() - - def test_create_server_with_bytes_body(self): - self._test_create_server(True) - - def _test_create_server(self, bytes_body=False): - self.check_service_client_function( - self.client.create_server, - 'tempest_lib.common.rest_client.RestClient.post', - self.FAKE_SERVER_POST, - bytes_body, - status=202, - name='fake-name', - imageRef='fake-image-ref', - flavorRef='fake-flavor-ref' - ) - - def test_list_addresses_with_str_body(self): - self._test_list_addresses() - - def test_list_addresses_with_bytes_body(self): - self._test_list_addresses(True) - - def _test_list_addresses(self, bytes_body=False): - self.check_service_client_function( - self.client.list_addresses, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_ADDRESS, - bytes_body, - server_id=self.server_id - ) - - def test_list_addresses_by_network_with_str_body(self): - self._test_list_addresses_by_network() - - def test_list_addresses_by_network_with_bytes_body(self): - self._test_list_addresses_by_network(True) - - def _test_list_addresses_by_network(self, bytes_body=False): - self.check_service_client_function( - self.client.list_addresses_by_network, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_ADDRESS['addresses'], - server_id=self.server_id, - network_id=self.network_id - ) - - def test_action_with_str_body(self): - self._test_action() - - def test_action_with_bytes_body(self): - self._test_action(True) - - def _test_action(self, bytes_body=False): - self.check_service_client_function( - self.client.action, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - server_id=self.server_id, - action_name='fake-action-name', - schema={'status_code': 200} - ) - - def test_create_backup_with_str_body(self): - self._test_create_backup() - - def test_create_backup_with_bytes_body(self): - self._test_create_backup(True) - - def _test_create_backup(self, bytes_body=False): - self.check_service_client_function( - self.client.create_backup, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id, - backup_type='fake-backup', - rotation='fake-rotation', - name='fake-name' - ) - - def test_change_password_with_str_body(self): - self._test_change_password() - - def test_change_password_with_bytes_body(self): - self._test_change_password(True) - - def _test_change_password(self, bytes_body=False): - self.check_service_client_function( - self.client.change_password, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id, - adminPass='fake-admin-pass' - ) - - def test_show_password_with_str_body(self): - self._test_show_password() - - def test_show_password_with_bytes_body(self): - self._test_show_password(True) - - def _test_show_password(self, bytes_body=False): - self.check_service_client_function( - self.client.show_password, - 'tempest_lib.common.rest_client.RestClient.get', - {'password': 'fake-password'}, - server_id=self.server_id - ) - - def test_delete_password_with_str_body(self): - self._test_delete_password() - - def test_delete_password_with_bytes_body(self): - self._test_delete_password(True) - - def _test_delete_password(self, bytes_body=False): - self.check_service_client_function( - self.client.delete_password, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, - status=204, - server_id=self.server_id - ) - - def test_reboot_server_with_str_body(self): - self._test_reboot_server() - - def test_reboot_server_with_bytes_body(self): - self._test_reboot_server(True) - - def _test_reboot_server(self, bytes_body=False): - self.check_service_client_function( - self.client.reboot_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id, - type='fake-reboot-type' - ) - - def test_rebuild_server_with_str_body(self): - self._test_rebuild_server() - - def test_rebuild_server_with_bytes_body(self): - self._test_rebuild_server(True) - - def _test_rebuild_server(self, bytes_body=False): - self.check_service_client_function( - self.client.rebuild_server, - 'tempest_lib.common.rest_client.RestClient.post', - self.FAKE_REBUILD_SERVER, - status=202, - server_id=self.server_id, - image_ref='fake-image-ref' - ) - - def test_resize_server_with_str_body(self): - self._test_resize_server() - - def test_resize_server_with_bytes_body(self): - self._test_resize_server(True) - - def _test_resize_server(self, bytes_body=False): - self.check_service_client_function( - self.client.resize_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id, - flavor_ref='fake-flavor-ref' - ) - - def test_confirm_resize_server_with_str_body(self): - self._test_confirm_resize_server() - - def test_confirm_resize_server_with_bytes_body(self): - self._test_confirm_resize_server(True) - - def _test_confirm_resize_server(self, bytes_body=False): - self.check_service_client_function( - self.client.confirm_resize_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=204, - server_id=self.server_id - ) - - def test_revert_resize_server_with_str_body(self): - self._test_revert_resize() - - def test_revert_resize_server_with_bytes_body(self): - self._test_revert_resize(True) - - def _test_revert_resize(self, bytes_body=False): - self.check_service_client_function( - self.client.revert_resize_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_list_server_metadata_with_str_body(self): - self._test_list_server_metadata() - - def test_list_server_metadata_with_bytes_body(self): - self._test_list_server_metadata() - - def _test_list_server_metadata(self, bytes_body=False): - self.check_service_client_function( - self.client.list_server_metadata, - 'tempest_lib.common.rest_client.RestClient.get', - {'metadata': {'fake-key': 'fake-meta-data'}}, - server_id=self.server_id - ) - - def test_set_server_metadata_with_str_body(self): - self._test_set_server_metadata() - - def test_set_server_metadata_with_bytes_body(self): - self._test_set_server_metadata(True) - - def _test_set_server_metadata(self, bytes_body=False): - self.check_service_client_function( - self.client.set_server_metadata, - 'tempest_lib.common.rest_client.RestClient.put', - {'metadata': {'fake-key': 'fake-meta-data'}}, - server_id=self.server_id, - meta='fake-meta' - ) - - def test_update_server_metadata_with_str_body(self): - self._test_update_server_metadata() - - def test_update_server_metadata_with_bytes_body(self): - self._test_update_server_metadata(True) - - def _test_update_server_metadata(self, bytes_body=False): - self.check_service_client_function( - self.client.update_server_metadata, - 'tempest_lib.common.rest_client.RestClient.post', - {'metadata': {'fake-key': 'fake-meta-data'}}, - server_id=self.server_id, - meta='fake-meta' - ) - - def test_show_server_metadata_item_with_str_body(self): - self._test_show_server_metadata() - - def test_show_server_metadata_item_with_bytes_body(self): - self._test_show_server_metadata(True) - - def _test_show_server_metadata(self, bytes_body=False): - self.check_service_client_function( - self.client.show_server_metadata_item, - 'tempest_lib.common.rest_client.RestClient.get', - {'meta': {'fake-key': 'fake-meta-data'}}, - server_id=self.server_id, - key='fake-key' - ) - - def test_set_server_metadata_item_with_str_body(self): - self._test_set_server_metadata_item() - - def test_set_server_metadata_item_with_bytes_body(self): - self._test_set_server_metadata_item(True) - - def _test_set_server_metadata_item(self, bytes_body=False): - self.check_service_client_function( - self.client.set_server_metadata_item, - 'tempest_lib.common.rest_client.RestClient.put', - {'meta': {'fake-key': 'fake-meta-data'}}, - server_id=self.server_id, - key='fake-key', - meta='fake-meta' - ) - - def test_delete_server_metadata_item_with_str_body(self): - self._test_delete_server_metadata() - - def test_delete_server_metadata_item_with_bytes_body(self): - self._test_delete_server_metadata(True) - - def _test_delete_server_metadata(self, bytes_body=False): - self.check_service_client_function( - self.client.delete_server_metadata_item, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, - status=204, - server_id=self.server_id, - key='fake-key' - ) - - def test_stop_server_with_str_body(self): - self._test_stop_server() - - def test_stop_server_with_bytes_body(self): - self._test_stop_server(True) - - def _test_stop_server(self, bytes_body=False): - self.check_service_client_function( - self.client.stop_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_start_server_with_str_body(self): - self._test_start_server() - - def test_start_server_with_bytes_body(self): - self._test_start_server(True) - - def _test_start_server(self, bytes_body=False): - self.check_service_client_function( - self.client.start_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_attach_volume_with_str_body(self): - self._test_attach_volume_server() - - def test_attach_volume_with_bytes_body(self): - self._test_attach_volume_server(True) - - def _test_attach_volume_server(self, bytes_body=False): - self.check_service_client_function( - self.client.attach_volume, - 'tempest_lib.common.rest_client.RestClient.post', - {'volumeAttachment': self.FAKE_COMMON_VOLUME}, - server_id=self.server_id - ) - - def test_update_attached_volume(self): - self.check_service_client_function( - self.client.update_attached_volume, - 'tempest_lib.common.rest_client.RestClient.put', - {}, - status=202, - server_id=self.server_id, - attachment_id='fake-attachment-id', - volumeId='fake-volume-id' - ) - - def test_detach_volume_with_str_body(self): - self._test_detach_volume_server() - - def test_detach_volume_with_bytes_body(self): - self._test_detach_volume_server(True) - - def _test_detach_volume_server(self, bytes_body=False): - self.check_service_client_function( - self.client.detach_volume, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, - status=202, - server_id=self.server_id, - volume_id=self.FAKE_COMMON_VOLUME['volumeId'] - ) - - def test_show_volume_attachment_with_str_body(self): - self._test_show_volume_attachment() - - def test_show_volume_attachment_with_bytes_body(self): - self._test_show_volume_attachment(True) - - def _test_show_volume_attachment(self, bytes_body=False): - self.check_service_client_function( - self.client.show_volume_attachment, - 'tempest_lib.common.rest_client.RestClient.get', - {'volumeAttachment': self.FAKE_COMMON_VOLUME}, - server_id=self.server_id, - volume_id=self.FAKE_COMMON_VOLUME['volumeId'] - ) - - def test_list_volume_attachments_with_str_body(self): - self._test_list_volume_attachments() - - def test_list_volume_attachments_with_bytes_body(self): - self._test_list_volume_attachments(True) - - def _test_list_volume_attachments(self, bytes_body=False): - self.check_service_client_function( - self.client.list_volume_attachments, - 'tempest_lib.common.rest_client.RestClient.get', - {'volumeAttachments': [self.FAKE_COMMON_VOLUME]}, - server_id=self.server_id - ) - - def test_add_security_group_with_str_body(self): - self._test_add_security_group() - - def test_add_security_group_with_bytes_body(self): - self._test_add_security_group(True) - - def _test_add_security_group(self, bytes_body=False): - self.check_service_client_function( - self.client.add_security_group, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id, - name='fake-name' - ) - - def test_remove_security_group_with_str_body(self): - self._test_remove_security_group() - - def test_remove_security_group_with_bytes_body(self): - self._test_remove_security_group(True) - - def _test_remove_security_group(self, bytes_body=False): - self.check_service_client_function( - self.client.remove_security_group, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id, - name='fake-name' - ) - - def test_live_migrate_server_with_str_body(self): - self._test_live_migrate_server() - - def test_live_migrate_server_with_bytes_body(self): - self._test_live_migrate_server(True) - - def _test_live_migrate_server(self, bytes_body=False): - self.check_service_client_function( - self.client.live_migrate_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_migrate_server_with_str_body(self): - self._test_migrate_server() - - def test_migrate_server_with_bytes_body(self): - self._test_migrate_server(True) - - def _test_migrate_server(self, bytes_body=False): - self.check_service_client_function( - self.client.migrate_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_lock_server_with_str_body(self): - self._test_lock_server() - - def test_lock_server_with_bytes_body(self): - self._test_lock_server(True) - - def _test_lock_server(self, bytes_body=False): - self.check_service_client_function( - self.client.lock_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_unlock_server_with_str_body(self): - self._test_unlock_server() - - def test_unlock_server_with_bytes_body(self): - self._test_unlock_server(True) - - def _test_unlock_server(self, bytes_body=False): - self.check_service_client_function( - self.client.unlock_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_suspend_server_with_str_body(self): - self._test_suspend_server() - - def test_suspend_server_with_bytes_body(self): - self._test_suspend_server(True) - - def _test_suspend_server(self, bytes_body=False): - self.check_service_client_function( - self.client.suspend_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_resume_server_with_str_body(self): - self._test_resume_server() - - def test_resume_server_with_bytes_body(self): - self._test_resume_server(True) - - def _test_resume_server(self, bytes_body=False): - self.check_service_client_function( - self.client.resume_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_pause_server_with_str_body(self): - self._test_pause_server() - - def test_pause_server_with_bytes_body(self): - self._test_pause_server(True) - - def _test_pause_server(self, bytes_body=False): - self.check_service_client_function( - self.client.pause_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_unpause_server_with_str_body(self): - self._test_unpause_server() - - def test_unpause_server_with_bytes_body(self): - self._test_unpause_server(True) - - def _test_unpause_server(self, bytes_body=False): - self.check_service_client_function( - self.client.unpause_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_reset_state_with_str_body(self): - self._test_reset_state() - - def test_reset_state_with_bytes_body(self): - self._test_reset_state(True) - - def _test_reset_state(self, bytes_body=False): - self.check_service_client_function( - self.client.reset_state, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id, - state='fake-state' - ) - - def test_shelve_server_with_str_body(self): - self._test_shelve_server() - - def test_shelve_server_with_bytes_body(self): - self._test_shelve_server(True) - - def _test_shelve_server(self, bytes_body=False): - self.check_service_client_function( - self.client.shelve_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_unshelve_server_with_str_body(self): - self._test_unshelve_server() - - def test_unshelve_server_with_bytes_body(self): - self._test_unshelve_server(True) - - def _test_unshelve_server(self, bytes_body=False): - self.check_service_client_function( - self.client.unshelve_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_shelve_offload_server_with_str_body(self): - self._test_shelve_offload_server() - - def test_shelve_offload_server_with_bytes_body(self): - self._test_shelve_offload_server(True) - - def _test_shelve_offload_server(self, bytes_body=False): - self.check_service_client_function( - self.client.shelve_offload_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_get_console_output_with_str_body(self): - self._test_get_console_output() - - def test_get_console_output_with_bytes_body(self): - self._test_get_console_output(True) - - def _test_get_console_output(self, bytes_body=False): - self.check_service_client_function( - self.client.get_console_output, - 'tempest_lib.common.rest_client.RestClient.post', - {'output': 'fake-output'}, - server_id=self.server_id, - length='fake-length' - ) - - def test_list_virtual_interfaces_with_str_body(self): - self._test_list_virtual_interfaces() - - def test_list_virtual_interfaces_with_bytes_body(self): - self._test_list_virtual_interfaces(True) - - def _test_list_virtual_interfaces(self, bytes_body=False): - self.check_service_client_function( - self.client.list_virtual_interfaces, - 'tempest_lib.common.rest_client.RestClient.get', - {'virtual_interfaces': [self.FAKE_VIRTUAL_INTERFACES]}, - server_id=self.server_id - ) - - def test_rescue_server_with_str_body(self): - self._test_rescue_server() - - def test_rescue_server_with_bytes_body(self): - self._test_rescue_server(True) - - def _test_rescue_server(self, bytes_body=False): - self.check_service_client_function( - self.client.rescue_server, - 'tempest_lib.common.rest_client.RestClient.post', - {'adminPass': 'fake-admin-pass'}, - server_id=self.server_id - ) - - def test_unrescue_server_with_str_body(self): - self._test_unrescue_server() - - def test_unrescue_server_with_bytes_body(self): - self._test_unrescue_server(True) - - def _test_unrescue_server(self, bytes_body=False): - self.check_service_client_function( - self.client.unrescue_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_show_server_diagnostics_with_str_body(self): - self._test_show_server_diagnostics() - - def test_show_server_diagnostics_with_bytes_body(self): - self._test_show_server_diagnostics(True) - - def _test_show_server_diagnostics(self, bytes_body=False): - self.check_service_client_function( - self.client.show_server_diagnostics, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_SERVER_DIAGNOSTICS, - status=200, - server_id=self.server_id - ) - - def test_list_instance_actions_with_str_body(self): - self._test_list_instance_actions() - - def test_list_instance_actions_with_bytes_body(self): - self._test_list_instance_actions(True) - - def _test_list_instance_actions(self, bytes_body=False): - self.check_service_client_function( - self.client.list_instance_actions, - 'tempest_lib.common.rest_client.RestClient.get', - {'instanceActions': [self.FAKE_INSTANCE_ACTIONS]}, - server_id=self.server_id - ) - - def test_show_instance_action_with_str_body(self): - self._test_show_instance_action() - - def test_show_instance_action_with_bytes_body(self): - self._test_show_instance_action(True) - - def _test_show_instance_action(self, bytes_body=False): - self.check_service_client_function( - self.client.show_instance_action, - 'tempest_lib.common.rest_client.RestClient.get', - {'instanceAction': self.FAKE_INSTANCE_WITH_EVENTS}, - server_id=self.server_id, - request_id='fake-request-id' - ) - - def test_force_delete_server_with_str_body(self): - self._test_force_delete_server() - - def test_force_delete_server_with_bytes_body(self): - self._test_force_delete_server(True) - - def _test_force_delete_server(self, bytes_body=False): - self.check_service_client_function( - self.client.force_delete_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_restore_soft_deleted_server_with_str_body(self): - self._test_restore_soft_deleted_server() - - def test_restore_soft_deleted_server_with_bytes_body(self): - self._test_restore_soft_deleted_server(True) - - def _test_restore_soft_deleted_server(self, bytes_body=False): - self.check_service_client_function( - self.client.restore_soft_deleted_server, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_reset_network_with_str_body(self): - self._test_reset_network() - - def test_reset_network_with_bytes_body(self): - self._test_reset_network(True) - - def _test_reset_network(self, bytes_body=False): - self.check_service_client_function( - self.client.reset_network, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_inject_network_info_with_str_body(self): - self._test_inject_network_info() - - def test_inject_network_info_with_bytes_body(self): - self._test_inject_network_info(True) - - def _test_inject_network_info(self, bytes_body=False): - self.check_service_client_function( - self.client.inject_network_info, - 'tempest_lib.common.rest_client.RestClient.post', - {}, - status=202, - server_id=self.server_id - ) - - def test_get_vnc_console_with_str_body(self): - self._test_get_vnc_console() - - def test_get_vnc_console_with_bytes_body(self): - self._test_get_vnc_console(True) - - def _test_get_vnc_console(self, bytes_body=False): - self.check_service_client_function( - self.client.get_vnc_console, - 'tempest_lib.common.rest_client.RestClient.post', - {'console': self.FAKE_VNC_CONSOLE}, - server_id=self.server_id, - type='fake-console-type' - ) diff --git a/tempest_lib/tests/services/compute/test_services_client.py b/tempest_lib/tests/services/compute/test_services_client.py deleted file mode 100644 index 67d717a..0000000 --- a/tempest_lib/tests/services/compute/test_services_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from tempest_lib.services.compute import services_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestServicesClient(base.BaseComputeServiceTest): - - FAKE_SERVICES = { - "services": - [{ - "status": "enabled", - "binary": "nova-conductor", - "zone": "internal", - "state": "up", - "updated_at": "2015-08-19T06:50:55.000000", - "host": "controller", - "disabled_reason": None, - "id": 1 - }] - } - - FAKE_SERVICE = { - "service": - { - "status": "enabled", - "binary": "nova-conductor", - "host": "controller" - } - } - - def setUp(self): - super(TestServicesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = services_client.ServicesClient( - fake_auth, 'compute', 'regionOne') - - def test_list_services_with_str_body(self): - self.check_service_client_function( - self.client.list_services, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_SERVICES) - - def test_list_services_with_bytes_body(self): - self.check_service_client_function( - self.client.list_services, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_SERVICES, to_utf=True) - - def _test_enable_service(self, bytes_body=False): - self.check_service_client_function( - self.client.enable_service, - 'tempest_lib.common.rest_client.RestClient.put', - self.FAKE_SERVICE, - bytes_body, - host_name="nova-conductor", binary="controller") - - def test_enable_service_with_str_body(self): - self._test_enable_service() - - def test_enable_service_with_bytes_body(self): - self._test_enable_service(bytes_body=True) - - def _test_disable_service(self, bytes_body=False): - fake_service = copy.deepcopy(self.FAKE_SERVICE) - fake_service["service"]["status"] = "disable" - - self.check_service_client_function( - self.client.disable_service, - 'tempest_lib.common.rest_client.RestClient.put', - fake_service, - bytes_body, - host_name="nova-conductor", binary="controller") - - def test_disable_service_with_str_body(self): - self._test_disable_service() - - def test_disable_service_with_bytes_body(self): - self._test_disable_service(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_snapshots_client.py b/tempest_lib/tests/services/compute/test_snapshots_client.py deleted file mode 100644 index 008a7ea..0000000 --- a/tempest_lib/tests/services/compute/test_snapshots_client.py +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslotest import mockpatch - -from tempest_lib import exceptions as lib_exc -from tempest_lib.services.compute import snapshots_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestSnapshotsClient(base.BaseComputeServiceTest): - - FAKE_SNAPSHOT = { - "createdAt": "2015-10-02T16:27:54.724209", - "displayDescription": u"Another \u1234.", - "displayName": u"v\u1234-001", - "id": "100", - "size": 100, - "status": "available", - "volumeId": "12" - } - - FAKE_SNAPSHOTS = {"snapshots": [FAKE_SNAPSHOT]} - - def setUp(self): - super(TestSnapshotsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = snapshots_client.SnapshotsClient( - fake_auth, 'compute', 'regionOne') - - def _test_create_snapshot(self, bytes_body=False): - self.check_service_client_function( - self.client.create_snapshot, - 'tempest_lib.common.rest_client.RestClient.post', - {"snapshot": self.FAKE_SNAPSHOT}, - to_utf=bytes_body, status=200, - volume_id=self.FAKE_SNAPSHOT["volumeId"]) - - def test_create_snapshot_with_str_body(self): - self._test_create_snapshot() - - def test_create_shapshot_with_bytes_body(self): - self._test_create_snapshot(bytes_body=True) - - def _test_show_snapshot(self, bytes_body=False): - self.check_service_client_function( - self.client.show_snapshot, - 'tempest_lib.common.rest_client.RestClient.get', - {"snapshot": self.FAKE_SNAPSHOT}, - to_utf=bytes_body, snapshot_id=self.FAKE_SNAPSHOT["id"]) - - def test_show_snapshot_with_str_body(self): - self._test_show_snapshot() - - def test_show_snapshot_with_bytes_body(self): - self._test_show_snapshot(bytes_body=True) - - def _test_list_snapshots(self, bytes_body=False, **params): - self.check_service_client_function( - self.client.list_snapshots, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_SNAPSHOTS, to_utf=bytes_body, **params) - - def test_list_snapshots_with_str_body(self): - self._test_list_snapshots() - - def test_list_snapshots_with_byte_body(self): - self._test_list_snapshots(bytes_body=True) - - def test_list_snapshots_with_params(self): - self._test_list_snapshots('fake') - - def test_delete_snapshot(self): - self.check_service_client_function( - self.client.delete_snapshot, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=202, snapshot_id=self.FAKE_SNAPSHOT['id']) - - def test_is_resource_deleted_true(self): - module = ('tempest_lib.services.compute.snapshots_client.' - 'SnapshotsClient.show_snapshot') - self.useFixture(mockpatch.Patch( - module, side_effect=lib_exc.NotFound)) - self.assertTrue(self.client.is_resource_deleted('fake-id')) - - def test_is_resource_deleted_false(self): - module = ('tempest_lib.services.compute.snapshots_client.' - 'SnapshotsClient.show_snapshot') - self.useFixture(mockpatch.Patch( - module, return_value={})) - self.assertFalse(self.client.is_resource_deleted('fake-id')) diff --git a/tempest_lib/tests/services/compute/test_tenant_networks_client.py b/tempest_lib/tests/services/compute/test_tenant_networks_client.py deleted file mode 100644 index d21d85c..0000000 --- a/tempest_lib/tests/services/compute/test_tenant_networks_client.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import tenant_networks_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestTenantNetworksClient(base.BaseComputeServiceTest): - - FAKE_NETWORK = { - "cidr": "None", - "id": "c2329eb4-cc8e-4439-ac4c-932369309e36", - "label": u'\u30d7' - } - - FAKE_NETWORKS = [FAKE_NETWORK] - - NETWORK_ID = FAKE_NETWORK['id'] - - def setUp(self): - super(TestTenantNetworksClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = tenant_networks_client.TenantNetworksClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_tenant_networks(self, bytes_body=False): - self.check_service_client_function( - self.client.list_tenant_networks, - 'tempest_lib.common.rest_client.RestClient.get', - {"networks": self.FAKE_NETWORKS}, - bytes_body) - - def test_list_tenant_networks_with_str_body(self): - self._test_list_tenant_networks() - - def test_list_tenant_networks_with_bytes_body(self): - self._test_list_tenant_networks(bytes_body=True) - - def _test_show_tenant_network(self, bytes_body=False): - self.check_service_client_function( - self.client.show_tenant_network, - 'tempest_lib.common.rest_client.RestClient.get', - {"network": self.FAKE_NETWORK}, - bytes_body, - network_id=self.NETWORK_ID) - - def test_show_tenant_network_with_str_body(self): - self._test_show_tenant_network() - - def test_show_tenant_network_with_bytes_body(self): - self._test_show_tenant_network(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_tenant_usages_client.py b/tempest_lib/tests/services/compute/test_tenant_usages_client.py deleted file mode 100644 index 9ccb392..0000000 --- a/tempest_lib/tests/services/compute/test_tenant_usages_client.py +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest_lib.services.compute import tenant_usages_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestTenantUsagesClient(base.BaseComputeServiceTest): - - FAKE_SERVER_USAGES = [{ - "ended_at": None, - "flavor": "m1.tiny", - "hours": 1.0, - "instance_id": "1f1deceb-17b5-4c04-84c7-e0d4499c8fe0", - "local_gb": 1, - "memory_mb": 512, - "name": "new-server-test", - "started_at": "2012-10-08T20:10:44.541277", - "state": "active", - "tenant_id": "openstack", - "uptime": 3600, - "vcpus": 1 - }] - - FAKE_TENANT_USAGES = [{ - "server_usages": FAKE_SERVER_USAGES, - "start": "2012-10-08T21:10:44.587336", - "stop": "2012-10-08T22:10:44.587336", - "tenant_id": "openstack", - "total_hours": 1, - "total_local_gb_usage": 1, - "total_memory_mb_usage": 512, - "total_vcpus_usage": 1 - }] - - def setUp(self): - super(TestTenantUsagesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = tenant_usages_client.TenantUsagesClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_tenant_usages(self, bytes_body=False): - self.check_service_client_function( - self.client.list_tenant_usages, - 'tempest_lib.common.rest_client.RestClient.get', - {"tenant_usages": self.FAKE_TENANT_USAGES}, - to_utf=bytes_body) - - def test_list_tenant_usages_with_str_body(self): - self._test_list_tenant_usages() - - def test_list_tenant_usages_with_bytes_body(self): - self._test_list_tenant_usages(bytes_body=True) - - def _test_show_tenant_usage(self, bytes_body=False): - self.check_service_client_function( - self.client.show_tenant_usage, - 'tempest_lib.common.rest_client.RestClient.get', - {"tenant_usage": self.FAKE_TENANT_USAGES[0]}, - to_utf=bytes_body, - tenant_id='openstack') - - def test_show_tenant_usage_with_str_body(self): - self._test_show_tenant_usage() - - def test_show_tenant_usage_with_bytes_body(self): - self._test_show_tenant_usage(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_versions_client.py b/tempest_lib/tests/services/compute/test_versions_client.py deleted file mode 100644 index f79934e..0000000 --- a/tempest_lib/tests/services/compute/test_versions_client.py +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy -from oslotest import mockpatch - -from tempest_lib.services.compute import versions_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestVersionsClient(base.BaseComputeServiceTest): - - FAKE_INIT_VERSION = { - "version": { - "id": "v2.1", - "links": [ - { - "href": "http://openstack.example.com/v2.1/", - "rel": "self" - }, - { - "href": "http://docs.openstack.org/", - "rel": "describedby", - "type": "text/html" - } - ], - "status": "CURRENT", - "updated": "2013-07-23T11:33:21Z", - "version": "2.1", - "min_version": "2.1" - } - } - - FAKE_VERSIONS_INFO = { - "versions": [FAKE_INIT_VERSION["version"]] - } - - FAKE_VERSION_INFO = copy.deepcopy(FAKE_INIT_VERSION) - - FAKE_VERSION_INFO["version"]["media-types"] = [ - { - "base": "application/json", - "type": "application/vnd.openstack.compute+json;version=2.1" - } - ] - - def setUp(self): - super(TestVersionsClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.versions_client = ( - versions_client.VersionsClient - (fake_auth, 'compute', 'regionOne')) - - def _test_versions_client(self, bytes_body=False): - self.check_service_client_function( - self.versions_client.list_versions, - 'tempest_lib.common.rest_client.RestClient.raw_request', - self.FAKE_VERSIONS_INFO, - bytes_body, - 200) - - def _test_get_version_by_url(self, bytes_body=False): - self.useFixture(mockpatch.Patch( - "tempest_lib.common.rest_client.RestClient.token", - return_value="Dummy Token")) - params = {"version_url": self.versions_client._get_base_version_url()} - self.check_service_client_function( - self.versions_client.get_version_by_url, - 'tempest_lib.common.rest_client.RestClient.raw_request', - self.FAKE_VERSION_INFO, - bytes_body, - 200, **params) - - def test_list_versions_client_with_str_body(self): - self._test_versions_client() - - def test_list_versions_client_with_bytes_body(self): - self._test_versions_client(bytes_body=True) - - def test_get_version_by_url_with_str_body(self): - self._test_get_version_by_url() - - def test_get_version_by_url_with_bytes_body(self): - self._test_get_version_by_url(bytes_body=True) diff --git a/tempest_lib/tests/services/compute/test_volumes_client.py b/tempest_lib/tests/services/compute/test_volumes_client.py deleted file mode 100644 index 0687f35..0000000 --- a/tempest_lib/tests/services/compute/test_volumes_client.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2015 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from oslotest import mockpatch - -from tempest_lib import exceptions as lib_exc -from tempest_lib.services.compute import volumes_client -from tempest_lib.tests import fake_auth_provider -from tempest_lib.tests.services.compute import base - - -class TestVolumesClient(base.BaseComputeServiceTest): - - FAKE_VOLUME = { - "id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c", - "displayName": u"v\u12345ol-001", - "displayDescription": u"Another \u1234volume.", - "size": 30, - "status": "Active", - "volumeType": "289da7f8-6440-407c-9fb4-7db01ec49164", - "metadata": { - "contents": "junk" - }, - "availabilityZone": "us-east1", - "snapshotId": None, - "attachments": [], - "createdAt": "2012-02-14T20:53:07Z" - } - - FAKE_VOLUMES = {"volumes": [FAKE_VOLUME]} - - def setUp(self): - super(TestVolumesClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = volumes_client.VolumesClient( - fake_auth, 'compute', 'regionOne') - - def _test_list_volumes(self, bytes_body=False, **params): - self.check_service_client_function( - self.client.list_volumes, - 'tempest_lib.common.rest_client.RestClient.get', - self.FAKE_VOLUMES, to_utf=bytes_body, **params) - - def test_list_volumes_with_str_body(self): - self._test_list_volumes() - - def test_list_volumes_with_byte_body(self): - self._test_list_volumes(bytes_body=True) - - def test_list_volumes_with_params(self): - self._test_list_volumes(name='fake') - - def _test_show_volume(self, bytes_body=False): - self.check_service_client_function( - self.client.show_volume, - 'tempest_lib.common.rest_client.RestClient.get', - {"volume": self.FAKE_VOLUME}, - to_utf=bytes_body, volume_id=self.FAKE_VOLUME['id']) - - def test_show_volume_with_str_body(self): - self._test_show_volume() - - def test_show_volume_with_bytes_body(self): - self._test_show_volume(bytes_body=True) - - def _test_create_volume(self, bytes_body=False): - post_body = copy.deepcopy(self.FAKE_VOLUME) - del post_body['id'] - del post_body['createdAt'] - del post_body['status'] - self.check_service_client_function( - self.client.create_volume, - 'tempest_lib.common.rest_client.RestClient.post', - {"volume": self.FAKE_VOLUME}, - to_utf=bytes_body, status=200, **post_body) - - def test_create_volume_with_str_body(self): - self._test_create_volume() - - def test_create_volume_with_bytes_body(self): - self._test_create_volume(bytes_body=True) - - def test_delete_volume(self): - self.check_service_client_function( - self.client.delete_volume, - 'tempest_lib.common.rest_client.RestClient.delete', - {}, status=202, volume_id=self.FAKE_VOLUME['id']) - - def test_is_resource_deleted_true(self): - module = ('tempest_lib.services.compute.volumes_client.' - 'VolumesClient.show_volume') - self.useFixture(mockpatch.Patch( - module, side_effect=lib_exc.NotFound)) - self.assertTrue(self.client.is_resource_deleted('fake-id')) - - def test_is_resource_deleted_false(self): - module = ('tempest_lib.services.compute.volumes_client.' - 'VolumesClient.show_volume') - self.useFixture(mockpatch.Patch( - module, return_value={})) - self.assertFalse(self.client.is_resource_deleted('fake-id')) diff --git a/tempest_lib/tests/services/identity/__init__.py b/tempest_lib/tests/services/identity/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/tempest_lib/tests/services/identity/__init__.py +++ /dev/null diff --git a/tempest_lib/tests/services/identity/v2/__init__.py b/tempest_lib/tests/services/identity/v2/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/tempest_lib/tests/services/identity/v2/__init__.py +++ /dev/null diff --git a/tempest_lib/tests/services/identity/v2/test_token_client.py b/tempest_lib/tests/services/identity/v2/test_token_client.py deleted file mode 100644 index 57e439c..0000000 --- a/tempest_lib/tests/services/identity/v2/test_token_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import json - -import httplib2 -from oslotest import mockpatch - -from tempest_lib.common import rest_client -from tempest_lib import exceptions -from tempest_lib.services.identity.v2 import token_client -from tempest_lib.tests import base -from tempest_lib.tests import fake_http - - -class TestTokenClientV2(base.TestCase): - - def setUp(self): - super(TestTokenClientV2, self).setUp() - self.fake_200_http = fake_http.fake_httplib2(return_type=200) - - def test_init_without_authurl(self): - self.assertRaises(exceptions.IdentityError, - token_client.TokenClient, None) - - def test_auth(self): - token_client_v2 = token_client.TokenClient('fake_url') - post_mock = self.useFixture(mockpatch.PatchObject( - token_client_v2, 'post', return_value=self.fake_200_http.request( - 'fake_url', body={'access': {'token': 'fake_token'}}))) - resp = token_client_v2.auth('fake_user', 'fake_pass') - self.assertIsInstance(resp, rest_client.ResponseBody) - req_dict = json.dumps({ - 'auth': { - 'passwordCredentials': { - 'username': 'fake_user', - 'password': 'fake_pass', - }, - } - }, sort_keys=True) - post_mock.mock.assert_called_once_with('fake_url/tokens', - body=req_dict) - - def test_auth_with_tenant(self): - token_client_v2 = token_client.TokenClient('fake_url') - post_mock = self.useFixture(mockpatch.PatchObject( - token_client_v2, 'post', return_value=self.fake_200_http.request( - 'fake_url', body={'access': {'token': 'fake_token'}}))) - resp = token_client_v2.auth('fake_user', 'fake_pass', 'fake_tenant') - self.assertIsInstance(resp, rest_client.ResponseBody) - req_dict = json.dumps({ - 'auth': { - 'tenantName': 'fake_tenant', - 'passwordCredentials': { - 'username': 'fake_user', - 'password': 'fake_pass', - }, - } - }, sort_keys=True) - post_mock.mock.assert_called_once_with('fake_url/tokens', - body=req_dict) - - def test_request_with_str_body(self): - token_client_v2 = token_client.TokenClient('fake_url') - self.useFixture(mockpatch.PatchObject( - token_client_v2, 'raw_request', return_value=( - httplib2.Response({'status': '200'}), - str('{"access": {"token": "fake_token"}}')))) - resp, body = token_client_v2.request('GET', 'fake_uri') - self.assertIsInstance(resp, httplib2.Response) - self.assertIsInstance(body, dict) - - def test_request_with_bytes_body(self): - token_client_v2 = token_client.TokenClient('fake_url') - self.useFixture(mockpatch.PatchObject( - token_client_v2, 'raw_request', return_value=( - httplib2.Response({'status': '200'}), - bytes(b'{"access": {"token": "fake_token"}}')))) - resp, body = token_client_v2.request('GET', 'fake_uri') - self.assertIsInstance(resp, httplib2.Response) - self.assertIsInstance(body, dict) diff --git a/tempest_lib/tests/services/identity/v3/__init__.py b/tempest_lib/tests/services/identity/v3/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/tempest_lib/tests/services/identity/v3/__init__.py +++ /dev/null diff --git a/tempest_lib/tests/services/identity/v3/test_token_client.py b/tempest_lib/tests/services/identity/v3/test_token_client.py deleted file mode 100644 index b3a8b28..0000000 --- a/tempest_lib/tests/services/identity/v3/test_token_client.py +++ /dev/null @@ -1,145 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import json - -import httplib2 -from oslotest import mockpatch - -from tempest_lib.common import rest_client -from tempest_lib import exceptions -from tempest_lib.services.identity.v3 import token_client -from tempest_lib.tests import base -from tempest_lib.tests import fake_http - - -class TestTokenClientV2(base.TestCase): - - def setUp(self): - super(TestTokenClientV2, self).setUp() - self.fake_201_http = fake_http.fake_httplib2(return_type=201) - - def test_init_without_authurl(self): - self.assertRaises(exceptions.IdentityError, - token_client.V3TokenClient, None) - - def test_auth(self): - token_client_v3 = token_client.V3TokenClient('fake_url') - post_mock = self.useFixture(mockpatch.PatchObject( - token_client_v3, 'post', return_value=self.fake_201_http.request( - 'fake_url', body={'access': {'token': 'fake_token'}}))) - resp = token_client_v3.auth(username='fake_user', password='fake_pass') - self.assertIsInstance(resp, rest_client.ResponseBody) - req_dict = json.dumps({ - 'auth': { - 'identity': { - 'methods': ['password'], - 'password': { - 'user': { - 'name': 'fake_user', - 'password': 'fake_pass', - } - } - }, - } - }, sort_keys=True) - post_mock.mock.assert_called_once_with('fake_url/auth/tokens', - body=req_dict) - - def test_auth_with_project_id_and_domain_id(self): - token_client_v3 = token_client.V3TokenClient('fake_url') - post_mock = self.useFixture(mockpatch.PatchObject( - token_client_v3, 'post', return_value=self.fake_201_http.request( - 'fake_url', body={'access': {'token': 'fake_token'}}))) - resp = token_client_v3.auth( - username='fake_user', password='fake_pass', - project_id='fcac2a055a294e4c82d0a9c21c620eb4', - user_domain_id='14f4a9a99973404d8c20ba1d2af163ff', - project_domain_id='291f63ae9ac54ee292ca09e5f72d9676') - self.assertIsInstance(resp, rest_client.ResponseBody) - req_dict = json.dumps({ - 'auth': { - 'identity': { - 'methods': ['password'], - 'password': { - 'user': { - 'name': 'fake_user', - 'password': 'fake_pass', - 'domain': { - 'id': '14f4a9a99973404d8c20ba1d2af163ff' - } - } - } - }, - 'scope': { - 'project': { - 'id': 'fcac2a055a294e4c82d0a9c21c620eb4', - 'domain': { - 'id': '291f63ae9ac54ee292ca09e5f72d9676' - } - } - } - } - }, sort_keys=True) - post_mock.mock.assert_called_once_with('fake_url/auth/tokens', - body=req_dict) - - def test_auth_with_tenant(self): - token_client_v2 = token_client.V3TokenClient('fake_url') - post_mock = self.useFixture(mockpatch.PatchObject( - token_client_v2, 'post', return_value=self.fake_201_http.request( - 'fake_url', body={'access': {'token': 'fake_token'}}))) - resp = token_client_v2.auth(username='fake_user', password='fake_pass', - project_name='fake_tenant') - self.assertIsInstance(resp, rest_client.ResponseBody) - req_dict = json.dumps({ - 'auth': { - 'identity': { - 'methods': ['password'], - 'password': { - 'user': { - 'name': 'fake_user', - 'password': 'fake_pass', - } - }}, - 'scope': { - 'project': { - 'name': 'fake_tenant' - } - }, - } - }, sort_keys=True) - - post_mock.mock.assert_called_once_with('fake_url/auth/tokens', - body=req_dict) - - def test_request_with_str_body(self): - token_client_v3 = token_client.V3TokenClient('fake_url') - self.useFixture(mockpatch.PatchObject( - token_client_v3, 'raw_request', return_value=( - httplib2.Response({"status": "200"}), - str('{"access": {"token": "fake_token"}}')))) - resp, body = token_client_v3.request('GET', 'fake_uri') - self.assertIsInstance(resp, httplib2.Response) - self.assertIsInstance(body, dict) - - def test_request_with_bytes_body(self): - token_client_v3 = token_client.V3TokenClient('fake_url') - self.useFixture(mockpatch.PatchObject( - token_client_v3, 'raw_request', return_value=( - httplib2.Response({"status": "200"}), - bytes(b'{"access": {"token": "fake_token"}}')))) - resp, body = token_client_v3.request('GET', 'fake_uri') - self.assertIsInstance(resp, httplib2.Response) - self.assertIsInstance(body, dict) |