Merge "Replace the usage of 'os' with 'os_primary'"
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index c9d6f02..d893446 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -350,7 +350,7 @@
@classmethod
def delete_volume(cls, volume_id):
"""Deletes the given volume and waits for it to be gone."""
- cls._delete_volume(cls.volumes_extensions_client, volume_id)
+ cls._delete_volume(cls.volumes_client, volume_id)
@classmethod
def get_server_ip(cls, server):
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 11f236b..ea4c141 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -102,14 +102,10 @@
prefix_name = u'\u00CD\u00F1st\u00E1\u00F1c\u00E9'
self._update_server_name(server['id'], 'ACTIVE', prefix_name)
- @decorators.idempotent_id('6ac19cb1-27a3-40ec-b350-810bdc04c08e')
- def test_update_server_name_in_stop_state(self):
- # The server name should be changed to the provided value
- server = self.create_test_server(wait_until='ACTIVE')
+ # stop server and check server name update again
self.client.stop_server(server['id'])
waiters.wait_for_server_status(self.client, server['id'], 'SHUTOFF')
# Update instance name with non-ASCII characters
- prefix_name = u'\u00CD\u00F1st\u00E1\u00F1c\u00E9'
updated_server = self._update_server_name(server['id'],
'SHUTOFF',
prefix_name)
diff --git a/tempest/api/compute/volumes/test_volume_snapshots.py b/tempest/api/compute/volumes/test_volume_snapshots.py
index 2f3a06e..0f436eb 100644
--- a/tempest/api/compute/volumes/test_volume_snapshots.py
+++ b/tempest/api/compute/volumes/test_volume_snapshots.py
@@ -27,6 +27,11 @@
class VolumesSnapshotsTestJSON(base.BaseV2ComputeTest):
+ # These tests will fail with a 404 starting from microversion 2.36. For
+ # more information, see:
+ # https://developer.openstack.org/api-ref/compute/#volume-extension-os-volumes-os-snapshots-deprecated
+ max_microversion = '2.35'
+
@classmethod
def skip_checks(cls):
super(VolumesSnapshotsTestJSON, cls).skip_checks()
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index 43c837a..d9ee5b1 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -27,6 +27,11 @@
class VolumesGetTestJSON(base.BaseV2ComputeTest):
+ # These tests will fail with a 404 starting from microversion 2.36. For
+ # more information, see:
+ # https://developer.openstack.org/api-ref/compute/#volume-extension-os-volumes-os-snapshots-deprecated
+ max_microversion = '2.35'
+
@classmethod
def skip_checks(cls):
super(VolumesGetTestJSON, cls).skip_checks()
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index 0d8214f..b2aebe7 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -27,6 +27,11 @@
# If you are running a Devstack environment, ensure that the
# VOLUME_BACKING_FILE_SIZE is at least 4G in your localrc
+ # These tests will fail with a 404 starting from microversion 2.36. For
+ # more information, see:
+ # https://developer.openstack.org/api-ref/compute/#volume-extension-os-volumes-os-snapshots-deprecated
+ max_microversion = '2.35'
+
@classmethod
def skip_checks(cls):
super(VolumesTestJSON, cls).skip_checks()
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index 80db1be..87f7d8a 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -24,6 +24,11 @@
class VolumesNegativeTest(base.BaseV2ComputeTest):
+ # These tests will fail with a 404 starting from microversion 2.36. For
+ # more information, see:
+ # https://developer.openstack.org/api-ref/compute/#volume-extension-os-volumes-os-snapshots-deprecated
+ max_microversion = '2.35'
+
@classmethod
def skip_checks(cls):
super(VolumesNegativeTest, cls).skip_checks()
diff --git a/tempest/api/network/admin/test_routers.py b/tempest/api/network/admin/test_routers.py
new file mode 100644
index 0000000..ec8d260
--- /dev/null
+++ b/tempest/api/network/admin/test_routers.py
@@ -0,0 +1,231 @@
+# Copyright 2013 OpenStack Foundation
+# 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 testtools
+
+from tempest.api.network import base
+from tempest import config
+from tempest.lib.common.utils import data_utils
+from tempest.lib import decorators
+from tempest import test
+
+CONF = config.CONF
+
+
+class RoutersAdminTest(base.BaseAdminNetworkTest):
+ # NOTE(salv-orlando): This class inherits from BaseAdminNetworkTest
+ # as some router operations, such as enabling or disabling SNAT
+ # require admin credentials by default
+
+ def _cleanup_router(self, router):
+ self.delete_router(router)
+ self.routers.remove(router)
+
+ def _create_router(self, name=None, admin_state_up=False,
+ external_network_id=None, enable_snat=None):
+ # associate a cleanup with created routers to avoid quota limits
+ router = self.create_router(name, admin_state_up,
+ external_network_id, enable_snat)
+ self.addCleanup(self._cleanup_router, router)
+ return router
+
+ def _add_router_interface_with_subnet_id(self, router_id, subnet_id):
+ interface = self.routers_client.add_router_interface(
+ router_id, subnet_id=subnet_id)
+ self.addCleanup(self._remove_router_interface_with_subnet_id,
+ router_id, subnet_id)
+ self.assertEqual(subnet_id, interface['subnet_id'])
+ return interface
+
+ def _remove_router_interface_with_subnet_id(self, router_id, subnet_id):
+ body = self.routers_client.remove_router_interface(router_id,
+ subnet_id=subnet_id)
+ self.assertEqual(subnet_id, body['subnet_id'])
+
+ @classmethod
+ def skip_checks(cls):
+ super(RoutersAdminTest, cls).skip_checks()
+ if not test.is_extension_enabled('router', 'network'):
+ msg = "router extension not enabled."
+ raise cls.skipException(msg)
+
+ @classmethod
+ def resource_setup(cls):
+ super(RoutersAdminTest, cls).resource_setup()
+ cls.tenant_cidr = (CONF.network.project_network_cidr
+ if cls._ip_version == 4 else
+ CONF.network.project_network_v6_cidr)
+
+ @decorators.idempotent_id('e54dd3a3-4352-4921-b09d-44369ae17397')
+ def test_create_router_setting_project_id(self):
+ # Test creating router from admin user setting project_id.
+ project = data_utils.rand_name('test_tenant_')
+ description = data_utils.rand_name('desc_')
+ project = self.identity_utils.create_project(name=project,
+ description=description)
+ project_id = project['id']
+ self.addCleanup(self.identity_utils.delete_project, project_id)
+
+ name = data_utils.rand_name('router-')
+ create_body = self.admin_routers_client.create_router(
+ name=name, tenant_id=project_id)
+ self.addCleanup(self.admin_routers_client.delete_router,
+ create_body['router']['id'])
+ self.assertEqual(project_id, create_body['router']['tenant_id'])
+
+ @decorators.idempotent_id('847257cc-6afd-4154-b8fb-af49f5670ce8')
+ @test.requires_ext(extension='ext-gw-mode', service='network')
+ @testtools.skipUnless(CONF.network.public_network_id,
+ 'The public_network_id option must be specified.')
+ def test_create_router_with_default_snat_value(self):
+ # Create a router with default snat rule
+ router = self._create_router(
+ external_network_id=CONF.network.public_network_id)
+ self._verify_router_gateway(
+ router['id'], {'network_id': CONF.network.public_network_id,
+ 'enable_snat': True})
+
+ @decorators.idempotent_id('ea74068d-09e9-4fd7-8995-9b6a1ace920f')
+ @test.requires_ext(extension='ext-gw-mode', service='network')
+ @testtools.skipUnless(CONF.network.public_network_id,
+ 'The public_network_id option must be specified.')
+ def test_create_router_with_snat_explicit(self):
+ name = data_utils.rand_name('snat-router')
+ # Create a router enabling snat attributes
+ enable_snat_states = [False, True]
+ for enable_snat in enable_snat_states:
+ external_gateway_info = {
+ 'network_id': CONF.network.public_network_id,
+ 'enable_snat': enable_snat}
+ create_body = self.admin_routers_client.create_router(
+ name=name, external_gateway_info=external_gateway_info)
+ self.addCleanup(self.admin_routers_client.delete_router,
+ create_body['router']['id'])
+ # Verify snat attributes after router creation
+ self._verify_router_gateway(create_body['router']['id'],
+ exp_ext_gw_info=external_gateway_info)
+
+ def _verify_router_gateway(self, router_id, exp_ext_gw_info=None):
+ show_body = self.admin_routers_client.show_router(router_id)
+ actual_ext_gw_info = show_body['router']['external_gateway_info']
+ if exp_ext_gw_info is None:
+ self.assertIsNone(actual_ext_gw_info)
+ return
+ # Verify only keys passed in exp_ext_gw_info
+ for k, v in exp_ext_gw_info.items():
+ self.assertEqual(v, actual_ext_gw_info[k])
+
+ def _verify_gateway_port(self, router_id):
+ list_body = self.admin_ports_client.list_ports(
+ network_id=CONF.network.public_network_id,
+ device_id=router_id)
+ self.assertEqual(len(list_body['ports']), 1)
+ gw_port = list_body['ports'][0]
+ fixed_ips = gw_port['fixed_ips']
+ self.assertGreaterEqual(len(fixed_ips), 1)
+ # Assert that all of the IPs from the router gateway port
+ # are allocated from a valid public subnet.
+ public_net_body = self.admin_networks_client.show_network(
+ CONF.network.public_network_id)
+ public_subnet_ids = public_net_body['network']['subnets']
+ for fixed_ip in fixed_ips:
+ subnet_id = fixed_ip['subnet_id']
+ self.assertIn(subnet_id, public_subnet_ids)
+
+ @decorators.idempotent_id('6cc285d8-46bf-4f36-9b1a-783e3008ba79')
+ @testtools.skipUnless(CONF.network.public_network_id,
+ 'The public_network_id option must be specified.')
+ def test_update_router_set_gateway(self):
+ router = self._create_router()
+ self.routers_client.update_router(
+ router['id'],
+ external_gateway_info={
+ 'network_id': CONF.network.public_network_id})
+ # Verify operation - router
+ self._verify_router_gateway(
+ router['id'],
+ {'network_id': CONF.network.public_network_id})
+ self._verify_gateway_port(router['id'])
+
+ @decorators.idempotent_id('b386c111-3b21-466d-880c-5e72b01e1a33')
+ @test.requires_ext(extension='ext-gw-mode', service='network')
+ @testtools.skipUnless(CONF.network.public_network_id,
+ 'The public_network_id option must be specified.')
+ def test_update_router_set_gateway_with_snat_explicit(self):
+ router = self._create_router()
+ self.admin_routers_client.update_router(
+ router['id'],
+ external_gateway_info={
+ 'network_id': CONF.network.public_network_id,
+ 'enable_snat': True})
+ self._verify_router_gateway(
+ router['id'],
+ {'network_id': CONF.network.public_network_id,
+ 'enable_snat': True})
+ self._verify_gateway_port(router['id'])
+
+ @decorators.idempotent_id('96536bc7-8262-4fb2-9967-5c46940fa279')
+ @test.requires_ext(extension='ext-gw-mode', service='network')
+ @testtools.skipUnless(CONF.network.public_network_id,
+ 'The public_network_id option must be specified.')
+ def test_update_router_set_gateway_without_snat(self):
+ router = self._create_router()
+ self.admin_routers_client.update_router(
+ router['id'],
+ external_gateway_info={
+ 'network_id': CONF.network.public_network_id,
+ 'enable_snat': False})
+ self._verify_router_gateway(
+ router['id'],
+ {'network_id': CONF.network.public_network_id,
+ 'enable_snat': False})
+ self._verify_gateway_port(router['id'])
+
+ @decorators.idempotent_id('ad81b7ee-4f81-407b-a19c-17e623f763e8')
+ @testtools.skipUnless(CONF.network.public_network_id,
+ 'The public_network_id option must be specified.')
+ def test_update_router_unset_gateway(self):
+ router = self._create_router(
+ external_network_id=CONF.network.public_network_id)
+ self.routers_client.update_router(router['id'],
+ external_gateway_info={})
+ self._verify_router_gateway(router['id'])
+ # No gateway port expected
+ list_body = self.admin_ports_client.list_ports(
+ network_id=CONF.network.public_network_id,
+ device_id=router['id'])
+ self.assertFalse(list_body['ports'])
+
+ @decorators.idempotent_id('f2faf994-97f4-410b-a831-9bc977b64374')
+ @test.requires_ext(extension='ext-gw-mode', service='network')
+ @testtools.skipUnless(CONF.network.public_network_id,
+ 'The public_network_id option must be specified.')
+ def test_update_router_reset_gateway_without_snat(self):
+ router = self._create_router(
+ external_network_id=CONF.network.public_network_id)
+ self.admin_routers_client.update_router(
+ router['id'],
+ external_gateway_info={
+ 'network_id': CONF.network.public_network_id,
+ 'enable_snat': False})
+ self._verify_router_gateway(
+ router['id'],
+ {'network_id': CONF.network.public_network_id,
+ 'enable_snat': False})
+ self._verify_gateway_port(router['id'])
+
+
+class RoutersIpV6AdminTest(RoutersAdminTest):
+ _ip_version = 6
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 0466d3a..d78cd1e 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -25,10 +25,7 @@
CONF = config.CONF
-class RoutersTest(base.BaseAdminNetworkTest):
- # NOTE(salv-orlando): This class inherits from BaseAdminNetworkTest
- # as some router operations, such as enabling or disabling SNAT
- # require admin credentials by default
+class RoutersTest(base.BaseNetworkTest):
def _cleanup_router(self, router):
self.delete_router(router)
@@ -101,55 +98,6 @@
router['id'])['router']
self.assertEqual(router_show['name'], updated_name)
- @decorators.idempotent_id('e54dd3a3-4352-4921-b09d-44369ae17397')
- def test_create_router_setting_project_id(self):
- # Test creating router from admin user setting project_id.
- project = data_utils.rand_name('test_tenant_')
- description = data_utils.rand_name('desc_')
- project = self.identity_utils.create_project(name=project,
- description=description)
- project_id = project['id']
- self.addCleanup(self.identity_utils.delete_project, project_id)
-
- name = data_utils.rand_name('router-')
- create_body = self.admin_routers_client.create_router(
- name=name, tenant_id=project_id)
- self.addCleanup(self.admin_routers_client.delete_router,
- create_body['router']['id'])
- self.assertEqual(project_id, create_body['router']['tenant_id'])
-
- @decorators.idempotent_id('847257cc-6afd-4154-b8fb-af49f5670ce8')
- @test.requires_ext(extension='ext-gw-mode', service='network')
- @testtools.skipUnless(CONF.network.public_network_id,
- 'The public_network_id option must be specified.')
- def test_create_router_with_default_snat_value(self):
- # Create a router with default snat rule
- router = self._create_router(
- external_network_id=CONF.network.public_network_id)
- self._verify_router_gateway(
- router['id'], {'network_id': CONF.network.public_network_id,
- 'enable_snat': True})
-
- @decorators.idempotent_id('ea74068d-09e9-4fd7-8995-9b6a1ace920f')
- @test.requires_ext(extension='ext-gw-mode', service='network')
- @testtools.skipUnless(CONF.network.public_network_id,
- 'The public_network_id option must be specified.')
- def test_create_router_with_snat_explicit(self):
- name = data_utils.rand_name('snat-router')
- # Create a router enabling snat attributes
- enable_snat_states = [False, True]
- for enable_snat in enable_snat_states:
- external_gateway_info = {
- 'network_id': CONF.network.public_network_id,
- 'enable_snat': enable_snat}
- create_body = self.admin_routers_client.create_router(
- name=name, external_gateway_info=external_gateway_info)
- self.addCleanup(self.admin_routers_client.delete_router,
- create_body['router']['id'])
- # Verify snat attributes after router creation
- self._verify_router_gateway(create_body['router']['id'],
- exp_ext_gw_info=external_gateway_info)
-
@decorators.attr(type='smoke')
@decorators.idempotent_id('b42e6e39-2e37-49cc-a6f4-8467e940900a')
def test_add_remove_router_interface_with_subnet_id(self):
@@ -218,55 +166,6 @@
subnet_id = fixed_ip['subnet_id']
self.assertIn(subnet_id, public_subnet_ids)
- @decorators.idempotent_id('6cc285d8-46bf-4f36-9b1a-783e3008ba79')
- @testtools.skipUnless(CONF.network.public_network_id,
- 'The public_network_id option must be specified.')
- def test_update_router_set_gateway(self):
- router = self._create_router()
- self.routers_client.update_router(
- router['id'],
- external_gateway_info={
- 'network_id': CONF.network.public_network_id})
- # Verify operation - router
- self._verify_router_gateway(
- router['id'],
- {'network_id': CONF.network.public_network_id})
- self._verify_gateway_port(router['id'])
-
- @decorators.idempotent_id('b386c111-3b21-466d-880c-5e72b01e1a33')
- @test.requires_ext(extension='ext-gw-mode', service='network')
- @testtools.skipUnless(CONF.network.public_network_id,
- 'The public_network_id option must be specified.')
- def test_update_router_set_gateway_with_snat_explicit(self):
- router = self._create_router()
- self.admin_routers_client.update_router(
- router['id'],
- external_gateway_info={
- 'network_id': CONF.network.public_network_id,
- 'enable_snat': True})
- self._verify_router_gateway(
- router['id'],
- {'network_id': CONF.network.public_network_id,
- 'enable_snat': True})
- self._verify_gateway_port(router['id'])
-
- @decorators.idempotent_id('96536bc7-8262-4fb2-9967-5c46940fa279')
- @test.requires_ext(extension='ext-gw-mode', service='network')
- @testtools.skipUnless(CONF.network.public_network_id,
- 'The public_network_id option must be specified.')
- def test_update_router_set_gateway_without_snat(self):
- router = self._create_router()
- self.admin_routers_client.update_router(
- router['id'],
- external_gateway_info={
- 'network_id': CONF.network.public_network_id,
- 'enable_snat': False})
- self._verify_router_gateway(
- router['id'],
- {'network_id': CONF.network.public_network_id,
- 'enable_snat': False})
- self._verify_gateway_port(router['id'])
-
@decorators.idempotent_id('cbe42f84-04c2-11e7-8adb-fa163e4fa634')
@test.requires_ext(extension='ext-gw-mode', service='network')
@testtools.skipUnless(CONF.network.public_network_id,
@@ -298,39 +197,6 @@
'external_fixed_ips'][0]['ip_address'],
fixed_ip['ip_address'])
- @decorators.idempotent_id('ad81b7ee-4f81-407b-a19c-17e623f763e8')
- @testtools.skipUnless(CONF.network.public_network_id,
- 'The public_network_id option must be specified.')
- def test_update_router_unset_gateway(self):
- router = self._create_router(
- external_network_id=CONF.network.public_network_id)
- self.routers_client.update_router(router['id'],
- external_gateway_info={})
- self._verify_router_gateway(router['id'])
- # No gateway port expected
- list_body = self.admin_ports_client.list_ports(
- network_id=CONF.network.public_network_id,
- device_id=router['id'])
- self.assertFalse(list_body['ports'])
-
- @decorators.idempotent_id('f2faf994-97f4-410b-a831-9bc977b64374')
- @test.requires_ext(extension='ext-gw-mode', service='network')
- @testtools.skipUnless(CONF.network.public_network_id,
- 'The public_network_id option must be specified.')
- def test_update_router_reset_gateway_without_snat(self):
- router = self._create_router(
- external_network_id=CONF.network.public_network_id)
- self.admin_routers_client.update_router(
- router['id'],
- external_gateway_info={
- 'network_id': CONF.network.public_network_id,
- 'enable_snat': False})
- self._verify_router_gateway(
- router['id'],
- {'network_id': CONF.network.public_network_id,
- 'enable_snat': False})
- self._verify_gateway_port(router['id'])
-
@decorators.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c')
@test.requires_ext(extension='extraroute', service='network')
def test_update_delete_extra_route(self):
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index 98bf145..640dcd4 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+import fixtures
import mock
from oslo_serialization import jsonutils as json
-from oslotest import mockpatch
from tempest.cmd import verify_tempest_config
from tempest import config
@@ -73,12 +73,12 @@
fake_config.FakePrivate)
def test_get_keystone_api_versions(self):
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
return_value='http://fake_endpoint:5000'))
fake_resp = {'versions': {'values': [{'id': 'v2.0'}, {'id': 'v3.0'}]}}
fake_resp = json.dumps(fake_resp)
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.lib.common.http.ClosingHttp.request',
return_value=(None, fake_resp)))
fake_os = mock.MagicMock()
@@ -87,12 +87,12 @@
self.assertIn('v3.0', versions)
def test_get_cinder_api_versions(self):
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
return_value='http://fake_endpoint:5000'))
fake_resp = {'versions': [{'id': 'v1.0'}, {'id': 'v2.0'}]}
fake_resp = json.dumps(fake_resp)
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.lib.common.http.ClosingHttp.request',
return_value=(None, fake_resp)))
fake_os = mock.MagicMock()
@@ -101,12 +101,12 @@
self.assertIn('v2.0', versions)
def test_get_nova_versions(self):
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
return_value='http://fake_endpoint:5000'))
fake_resp = {'versions': [{'id': 'v2.0'}, {'id': 'v3.0'}]}
fake_resp = json.dumps(fake_resp)
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.lib.common.http.ClosingHttp.request',
return_value=(None, fake_resp)))
fake_os = mock.MagicMock()
@@ -117,17 +117,17 @@
def test_get_versions_invalid_response(self):
# When the response doesn't contain a JSON response, an error is
# logged.
- mock_log_error = self.useFixture(mockpatch.PatchObject(
+ mock_log_error = self.useFixture(fixtures.MockPatchObject(
verify_tempest_config.LOG, 'error')).mock
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint'))
# Simulated response is not JSON.
sample_body = (
'<html><head>Sample Response</head><body>This is the sample page '
'for the web server. Why are you requesting it?</body></html>')
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.lib.common.http.ClosingHttp.request',
return_value=(None, sample_body)))
@@ -157,7 +157,7 @@
@mock.patch('tempest.lib.common.http.ClosingHttp.request')
def test_verify_keystone_api_versions_no_v3(self, mock_request):
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
return_value='http://fake_endpoint:5000'))
fake_resp = {'versions': {'values': [{'id': 'v2.0'}]}}
@@ -173,7 +173,7 @@
@mock.patch('tempest.lib.common.http.ClosingHttp.request')
def test_verify_keystone_api_versions_no_v2(self, mock_request):
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
return_value='http://fake_endpoint:5000'))
fake_resp = {'versions': {'values': [{'id': 'v3.0'}]}}
@@ -189,7 +189,7 @@
@mock.patch('tempest.lib.common.http.ClosingHttp.request')
def test_verify_cinder_api_versions_no_v3(self, mock_request):
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
return_value='http://fake_endpoint:5000'))
fake_resp = {'versions': [{'id': 'v2.0'}]}
@@ -203,7 +203,7 @@
@mock.patch('tempest.lib.common.http.ClosingHttp.request')
def test_verify_cinder_api_versions_no_v2(self, mock_request):
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
return_value='http://fake_endpoint:5000'))
fake_resp = {'versions': [{'id': 'v3.0'}]}
@@ -221,7 +221,7 @@
@mock.patch('tempest.lib.common.http.ClosingHttp.request')
def test_verify_cinder_api_versions_no_v1(self, mock_request):
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
return_value='http://fake_endpoint:5000'))
fake_resp = {'versions': [{'id': 'v2.0'}, {'id': 'v3.0'}]}
@@ -276,7 +276,7 @@
fake_os = mock.MagicMock()
fake_os.network_extensions_client.list_extensions = (
fake_list_extensions)
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['fake1', 'fake2', 'fake3'])))
results = verify_tempest_config.verify_extensions(fake_os,
@@ -299,7 +299,7 @@
fake_os = mock.MagicMock()
fake_os.network_extensions_client.list_extensions = (
fake_list_extensions)
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['all'])))
results = verify_tempest_config.verify_extensions(fake_os,
@@ -319,7 +319,7 @@
fake_os.volumes_extension_client.list_extensions = fake_list_extensions
fake_os.volumes_v2_extension_client.list_extensions = (
fake_list_extensions)
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['fake1', 'fake2', 'fake3'])))
results = verify_tempest_config.verify_extensions(fake_os,
@@ -344,7 +344,7 @@
fake_os.volumes_extension_client.list_extensions = fake_list_extensions
fake_os.volumes_v2_extension_client.list_extensions = (
fake_list_extensions)
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['all'])))
results = verify_tempest_config.verify_extensions(fake_os,
@@ -360,7 +360,7 @@
{'alias': 'not_fake'}])
fake_os = mock.MagicMock()
fake_os.extensions_client.list_extensions = fake_list_extensions
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['fake1', 'fake2', 'fake3'])))
results = verify_tempest_config.verify_extensions(fake_os,
@@ -382,7 +382,7 @@
{'alias': 'not_fake'}]})
fake_os = mock.MagicMock()
fake_os.extensions_client.list_extensions = fake_list_extensions
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['all'])))
results = verify_tempest_config.verify_extensions(fake_os,
@@ -400,7 +400,7 @@
'swift': 'metadata'})
fake_os = mock.MagicMock()
fake_os.capabilities_client.list_capabilities = fake_list_extensions
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['fake1', 'fake2', 'fake3'])))
results = verify_tempest_config.verify_extensions(fake_os, 'swift', {})
@@ -422,7 +422,7 @@
'swift': 'metadata'})
fake_os = mock.MagicMock()
fake_os.capabilities_client.list_capabilities = fake_list_extensions
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['all'])))
results = verify_tempest_config.verify_extensions(fake_os,
diff --git a/tempest/tests/common/test_admin_available.py b/tempest/tests/common/test_admin_available.py
index 01a9cd0..c3d248c 100644
--- a/tempest/tests/common/test_admin_available.py
+++ b/tempest/tests/common/test_admin_available.py
@@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import fixtures
from oslo_config import cfg
-from oslotest import mockpatch
from tempest.common import credentials_factory as credentials
from tempest import config
@@ -52,16 +52,16 @@
'project_name': 'admin',
'password': 'p',
'types': ['admin']})
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=accounts))
cfg.CONF.set_default('test_accounts_file',
use_accounts_file, group='auth')
- self.useFixture(mockpatch.Patch('os.path.isfile',
- return_value=True))
+ self.useFixture(fixtures.MockPatch('os.path.isfile',
+ return_value=True))
else:
- self.useFixture(mockpatch.Patch('os.path.isfile',
- return_value=False))
+ self.useFixture(fixtures.MockPatch('os.path.isfile',
+ return_value=False))
if admin_creds:
username = 'u'
project = 't'
diff --git a/tempest/tests/common/test_alt_available.py b/tempest/tests/common/test_alt_available.py
index 27db95c..b9a8967 100644
--- a/tempest/tests/common/test_alt_available.py
+++ b/tempest/tests/common/test_alt_available.py
@@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import fixtures
from oslo_config import cfg
-from oslotest import mockpatch
from tempest.common import credentials_factory as credentials
from tempest import config
@@ -39,16 +39,16 @@
accounts = [dict(username="u%s" % ii,
project_name="t%s" % ii,
password="p") for ii in creds]
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=accounts))
cfg.CONF.set_default('test_accounts_file',
use_accounts_file, group='auth')
- self.useFixture(mockpatch.Patch('os.path.isfile',
- return_value=True))
+ self.useFixture(fixtures.MockPatch('os.path.isfile',
+ return_value=True))
else:
- self.useFixture(mockpatch.Patch('os.path.isfile',
- return_value=False))
+ self.useFixture(fixtures.MockPatch('os.path.isfile',
+ return_value=False))
expected = len(set(creds)) > 1 or dynamic_creds
observed = credentials.is_alt_available(
identity_version=self.identity_version)
diff --git a/tempest/tests/common/test_dynamic_creds.py b/tempest/tests/common/test_dynamic_creds.py
index b4fbd50..c739619 100644
--- a/tempest/tests/common/test_dynamic_creds.py
+++ b/tempest/tests/common/test_dynamic_creds.py
@@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+import fixtures
import mock
from oslo_config import cfg
-from oslotest import mockpatch
from tempest.common import credentials_factory as credentials
from tempest.common import dynamic_creds
@@ -84,7 +84,7 @@
tenant_name='fake_tenant')
def _mock_user_create(self, id, name):
- user_fix = self.useFixture(mockpatch.PatchObject(
+ user_fix = self.useFixture(fixtures.MockPatchObject(
self.users_client.UsersClient,
'create_user',
return_value=(rest_client.ResponseBody
@@ -92,7 +92,7 @@
return user_fix
def _mock_tenant_create(self, id, name):
- tenant_fix = self.useFixture(mockpatch.PatchObject(
+ tenant_fix = self.useFixture(fixtures.MockPatchObject(
self.tenants_client.TenantsClient,
'create_tenant',
return_value=(rest_client.ResponseBody
@@ -100,7 +100,7 @@
return tenant_fix
def _mock_list_roles(self, id, name):
- roles_fix = self.useFixture(mockpatch.PatchObject(
+ roles_fix = self.useFixture(fixtures.MockPatchObject(
self.roles_client.RolesClient,
'list_roles',
return_value=(rest_client.ResponseBody
@@ -111,7 +111,7 @@
return roles_fix
def _mock_list_2_roles(self):
- roles_fix = self.useFixture(mockpatch.PatchObject(
+ roles_fix = self.useFixture(fixtures.MockPatchObject(
self.roles_client.RolesClient,
'list_roles',
return_value=(rest_client.ResponseBody
@@ -122,7 +122,7 @@
return roles_fix
def _mock_assign_user_role(self):
- tenant_fix = self.useFixture(mockpatch.PatchObject(
+ tenant_fix = self.useFixture(fixtures.MockPatchObject(
self.roles_client.RolesClient,
'create_user_role_on_project',
return_value=(rest_client.ResponseBody
@@ -130,7 +130,7 @@
return tenant_fix
def _mock_list_role(self):
- roles_fix = self.useFixture(mockpatch.PatchObject(
+ roles_fix = self.useFixture(fixtures.MockPatchObject(
self.roles_client.RolesClient,
'list_roles',
return_value=(rest_client.ResponseBody
@@ -140,7 +140,7 @@
return roles_fix
def _mock_list_ec2_credentials(self, user_id, tenant_id):
- ec2_creds_fix = self.useFixture(mockpatch.PatchObject(
+ ec2_creds_fix = self.useFixture(fixtures.MockPatchObject(
self.users_client.UsersClient,
'list_user_ec2_credentials',
return_value=(rest_client.ResponseBody
@@ -153,21 +153,21 @@
return ec2_creds_fix
def _mock_network_create(self, iso_creds, id, name):
- net_fix = self.useFixture(mockpatch.PatchObject(
+ net_fix = self.useFixture(fixtures.MockPatchObject(
iso_creds.networks_admin_client,
'create_network',
return_value={'network': {'id': id, 'name': name}}))
return net_fix
def _mock_subnet_create(self, iso_creds, id, name):
- subnet_fix = self.useFixture(mockpatch.PatchObject(
+ subnet_fix = self.useFixture(fixtures.MockPatchObject(
iso_creds.subnets_admin_client,
'create_subnet',
return_value={'subnet': {'id': id, 'name': name}}))
return subnet_fix
def _mock_router_create(self, id, name):
- router_fix = self.useFixture(mockpatch.PatchObject(
+ router_fix = self.useFixture(fixtures.MockPatchObject(
routers_client.RoutersClient,
'create_router',
return_value={'router': {'id': id, 'name': name}}))
@@ -634,7 +634,7 @@
def setUp(self):
super(TestDynamicCredentialProviderV3, self).setUp()
self.useFixture(fake_config.ConfigFixture())
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
domains_client.DomainsClient, 'list_domains',
return_value=dict(domains=[dict(id='default',
name='Default')])))
@@ -645,7 +645,7 @@
pass
def _mock_tenant_create(self, id, name):
- project_fix = self.useFixture(mockpatch.PatchObject(
+ project_fix = self.useFixture(fixtures.MockPatchObject(
self.tenants_client.ProjectsClient,
'create_project',
return_value=(rest_client.ResponseBody
diff --git a/tempest/tests/common/test_preprov_creds.py b/tempest/tests/common/test_preprov_creds.py
index 2fd375d..414b106 100644
--- a/tempest/tests/common/test_preprov_creds.py
+++ b/tempest/tests/common/test_preprov_creds.py
@@ -20,9 +20,9 @@
import six
import testtools
+import fixtures
from oslo_concurrency.fixture import lockutils as lockutils_fixtures
from oslo_config import cfg
-from oslotest import mockpatch
from tempest.common import preprov_creds
from tempest import config
@@ -86,10 +86,11 @@
self.patch(self.token_client, side_effect=self.identity_response)
self.useFixture(lockutils_fixtures.ExternalLockFixture())
self.test_accounts = self._fake_accounts(cfg.CONF.identity.admin_role)
- self.accounts_mock = self.useFixture(mockpatch.Patch(
+ self.accounts_mock = self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=self.test_accounts))
- self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
+ self.useFixture(fixtures.MockPatch(
+ 'os.path.isfile', return_value=True))
def tearDown(self):
super(TestPreProvisionedCredentials, self).tearDown()
@@ -138,7 +139,8 @@
def test_create_hash_file_previous_file(self):
# Emulate the lock existing on the filesystem
- self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
+ self.useFixture(fixtures.MockPatch(
+ 'os.path.isfile', return_value=True))
with mock.patch('six.moves.builtins.open', mock.mock_open(),
create=True):
test_account_class = (
@@ -150,7 +152,8 @@
def test_create_hash_file_no_previous_file(self):
# Emulate the lock not existing on the filesystem
- self.useFixture(mockpatch.Patch('os.path.isfile', return_value=False))
+ self.useFixture(fixtures.MockPatch(
+ 'os.path.isfile', return_value=False))
with mock.patch('six.moves.builtins.open', mock.mock_open(),
create=True):
test_account_class = (
@@ -163,10 +166,12 @@
@mock.patch('oslo_concurrency.lockutils.lock')
def test_get_free_hash_no_previous_accounts(self, lock_mock):
# Emulate no pre-existing lock
- self.useFixture(mockpatch.Patch('os.path.isdir', return_value=False))
+ self.useFixture(fixtures.MockPatch(
+ 'os.path.isdir', return_value=False))
hash_list = self._get_hash_list(self.test_accounts)
- mkdir_mock = self.useFixture(mockpatch.Patch('os.mkdir'))
- self.useFixture(mockpatch.Patch('os.path.isfile', return_value=False))
+ mkdir_mock = self.useFixture(fixtures.MockPatch('os.mkdir'))
+ self.useFixture(fixtures.MockPatch(
+ 'os.path.isfile', return_value=False))
test_account_class = preprov_creds.PreProvisionedCredentialProvider(
**self.fixed_params)
with mock.patch('six.moves.builtins.open', mock.mock_open(),
@@ -182,9 +187,10 @@
def test_get_free_hash_no_free_accounts(self, lock_mock):
hash_list = self._get_hash_list(self.test_accounts)
# Emulate pre-existing lock dir
- self.useFixture(mockpatch.Patch('os.path.isdir', return_value=True))
- # Emulate all lcoks in list are in use
- self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
+ self.useFixture(fixtures.MockPatch('os.path.isdir', return_value=True))
+ # Emulate all locks in list are in use
+ self.useFixture(fixtures.MockPatch(
+ 'os.path.isfile', return_value=True))
test_account_class = preprov_creds.PreProvisionedCredentialProvider(
**self.fixed_params)
with mock.patch('six.moves.builtins.open', mock.mock_open(),
@@ -195,7 +201,7 @@
@mock.patch('oslo_concurrency.lockutils.lock')
def test_get_free_hash_some_in_use_accounts(self, lock_mock):
# Emulate no pre-existing lock
- self.useFixture(mockpatch.Patch('os.path.isdir', return_value=True))
+ self.useFixture(fixtures.MockPatch('os.path.isdir', return_value=True))
hash_list = self._get_hash_list(self.test_accounts)
test_account_class = preprov_creds.PreProvisionedCredentialProvider(
**self.fixed_params)
@@ -219,13 +225,14 @@
def test_remove_hash_last_account(self, lock_mock):
hash_list = self._get_hash_list(self.test_accounts)
# Pretend the pseudo-lock is there
- self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
+ self.useFixture(
+ fixtures.MockPatch('os.path.isfile', return_value=True))
# Pretend the lock dir is empty
- self.useFixture(mockpatch.Patch('os.listdir', return_value=[]))
+ self.useFixture(fixtures.MockPatch('os.listdir', return_value=[]))
test_account_class = preprov_creds.PreProvisionedCredentialProvider(
**self.fixed_params)
- remove_mock = self.useFixture(mockpatch.Patch('os.remove'))
- rmdir_mock = self.useFixture(mockpatch.Patch('os.rmdir'))
+ remove_mock = self.useFixture(fixtures.MockPatch('os.remove'))
+ rmdir_mock = self.useFixture(fixtures.MockPatch('os.rmdir'))
test_account_class.remove_hash(hash_list[2])
hash_path = os.path.join(self.fixed_params['accounts_lock_dir'],
hash_list[2])
@@ -237,14 +244,15 @@
def test_remove_hash_not_last_account(self, lock_mock):
hash_list = self._get_hash_list(self.test_accounts)
# Pretend the pseudo-lock is there
- self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
+ self.useFixture(fixtures.MockPatch(
+ 'os.path.isfile', return_value=True))
# Pretend the lock dir is empty
- self.useFixture(mockpatch.Patch('os.listdir', return_value=[
+ self.useFixture(fixtures.MockPatch('os.listdir', return_value=[
hash_list[1], hash_list[4]]))
test_account_class = preprov_creds.PreProvisionedCredentialProvider(
**self.fixed_params)
- remove_mock = self.useFixture(mockpatch.Patch('os.remove'))
- rmdir_mock = self.useFixture(mockpatch.Patch('os.rmdir'))
+ remove_mock = self.useFixture(fixtures.MockPatch('os.remove'))
+ rmdir_mock = self.useFixture(fixtures.MockPatch('os.rmdir'))
test_account_class.remove_hash(hash_list[2])
hash_path = os.path.join(self.fixed_params['accounts_lock_dir'],
hash_list[2])
@@ -258,7 +266,7 @@
def test_is_not_multi_user(self):
self.test_accounts = [self.test_accounts[0]]
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=self.test_accounts))
test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
@@ -270,7 +278,7 @@
**self.fixed_params)
hashes = test_accounts_class.hash_dict['roles']['role4']
temp_hash = hashes[0]
- get_free_hash_mock = self.useFixture(mockpatch.PatchObject(
+ get_free_hash_mock = self.useFixture(fixtures.MockPatchObject(
test_accounts_class, '_get_free_hash', return_value=temp_hash))
# Test a single role returns all matching roles
test_accounts_class._get_creds(roles=['role4'])
@@ -287,7 +295,7 @@
hashes2 = test_accounts_class.hash_dict['roles']['role2']
hashes = list(set(hashes) & set(hashes2))
temp_hash = hashes[0]
- get_free_hash_mock = self.useFixture(mockpatch.PatchObject(
+ get_free_hash_mock = self.useFixture(fixtures.MockPatchObject(
test_accounts_class, '_get_free_hash', return_value=temp_hash))
# Test an intersection of multiple roles
test_accounts_class._get_creds(roles=['role2', 'role4'])
@@ -304,7 +312,7 @@
admin_hashes = test_accounts_class.hash_dict['roles'][
cfg.CONF.identity.admin_role]
temp_hash = hashes[0]
- get_free_hash_mock = self.useFixture(mockpatch.PatchObject(
+ get_free_hash_mock = self.useFixture(fixtures.MockPatchObject(
test_accounts_class, '_get_free_hash', return_value=temp_hash))
# Test an intersection of multiple roles
test_accounts_class._get_creds()
@@ -322,7 +330,7 @@
{'username': 'test_user14', 'tenant_name': 'test_tenant14',
'password': 'p', 'roles': ['role-7', 'role-11'],
'resources': {'network': 'network-2'}}]
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=test_accounts))
test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
@@ -350,7 +358,7 @@
def test_get_primary_creds_none_available(self):
admin_accounts = [x for x in self.test_accounts if 'test_admin'
in x['username']]
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=admin_accounts))
test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
@@ -368,7 +376,7 @@
def test_get_alt_creds_none_available(self):
admin_accounts = [x for x in self.test_accounts if 'test_admin'
in x['username']]
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=admin_accounts))
test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
@@ -389,7 +397,7 @@
'password': 'p', 'roles': ['role1', 'role2', 'role3', 'role4']},
{'username': 'test_admin1', 'tenant_name': 'test_tenant11',
'password': 'p', 'types': ['admin']}]
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=test_accounts))
test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
@@ -403,7 +411,7 @@
'password': 'p', 'roles': ['role1', 'role2', 'role3', 'role4']},
{'username': 'test_admin1', 'tenant_name': 'test_tenant11',
'password': 'p', 'roles': [cfg.CONF.identity.admin_role]}]
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=test_accounts))
test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
@@ -414,7 +422,7 @@
def test_get_admin_creds_none_available(self):
non_admin_accounts = [x for x in self.test_accounts if 'test_admin'
not in x['username']]
- self.useFixture(mockpatch.Patch(
+ self.useFixture(fixtures.MockPatch(
'tempest.common.preprov_creds.read_accounts_yaml',
return_value=non_admin_accounts))
test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
diff --git a/tempest/tests/common/utils/linux/test_remote_client.py b/tempest/tests/common/utils/linux/test_remote_client.py
index ecb8e64..739357b 100644
--- a/tempest/tests/common/utils/linux/test_remote_client.py
+++ b/tempest/tests/common/utils/linux/test_remote_client.py
@@ -16,7 +16,6 @@
import fixtures
from oslo_config import cfg
-from oslotest import mockpatch
from tempest.common.utils.linux import remote_client
from tempest import config
@@ -64,8 +63,8 @@
cfg.CONF.set_default('connect_timeout', 1, group='validation')
self.conn = remote_client.RemoteClient('127.0.0.1', 'user', 'pass')
- self.ssh_mock = self.useFixture(mockpatch.PatchObject(self.conn,
- 'ssh_client'))
+ self.ssh_mock = self.useFixture(fixtures.MockPatchObject(self.conn,
+ 'ssh_client'))
def test_write_to_console_regular_str(self):
self.conn.write_to_console('test')
@@ -111,7 +110,7 @@
booted_at = 10000
uptime_sec = 5000.02
self.ssh_mock.mock.exec_command.return_value = uptime_sec
- self.useFixture(mockpatch.PatchObject(
+ self.useFixture(fixtures.MockPatchObject(
time, 'time', return_value=booted_at + uptime_sec))
self.assertEqual(self.conn.get_boot_time(),
time.localtime(booted_at))
diff --git a/tempest/tests/lib/test_auth.py b/tempest/tests/lib/test_auth.py
index ac13a13..c3a792f 100644
--- a/tempest/tests/lib/test_auth.py
+++ b/tempest/tests/lib/test_auth.py
@@ -16,7 +16,7 @@
import copy
import datetime
-from oslotest import mockpatch
+import fixtures
import testtools
from tempest.lib import auth
@@ -82,9 +82,9 @@
def test_auth_data_property_when_cache_exists(self):
self.auth_provider.cache = 'foo'
- self.useFixture(mockpatch.PatchObject(self.auth_provider,
- 'is_expired',
- return_value=False))
+ self.useFixture(fixtures.MockPatchObject(self.auth_provider,
+ 'is_expired',
+ return_value=False))
self.assertEqual('foo', getattr(self.auth_provider, 'auth_data'))
def test_delete_auth_data_property_through_deleter(self):
diff --git a/tempest/tests/lib/test_rest_client.py b/tempest/tests/lib/test_rest_client.py
index 43bb6d0..ace2b80 100644
--- a/tempest/tests/lib/test_rest_client.py
+++ b/tempest/tests/lib/test_rest_client.py
@@ -15,8 +15,8 @@
import copy
import json
+import fixtures
import jsonschema
-from oslotest import mockpatch
import six
from tempest.lib.common import http
@@ -38,16 +38,16 @@
self.rest_client = rest_client.RestClient(
self.fake_auth_provider, None, None)
self.patchobject(http.ClosingHttp, 'request', self.fake_http.request)
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- '_log_request'))
+ self.useFixture(fixtures.MockPatchObject(self.rest_client,
+ '_log_request'))
class TestRestClientHTTPMethods(BaseRestClientTestClass):
def setUp(self):
self.fake_http = fake_http.fake_httplib2()
super(TestRestClientHTTPMethods, self).setUp()
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- '_error_checker'))
+ self.useFixture(fixtures.MockPatchObject(self.rest_client,
+ '_error_checker'))
def test_post(self):
__, return_dict = self.rest_client.post(self.url, {}, {})
@@ -70,8 +70,8 @@
self.assertEqual('PUT', return_dict['method'])
def test_head(self):
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- 'response_checker'))
+ self.useFixture(fixtures.MockPatchObject(self.rest_client,
+ 'response_checker'))
__, return_dict = self.rest_client.head(self.url)
self.assertEqual('HEAD', return_dict['method'])
@@ -122,8 +122,8 @@
self._verify_headers(resp)
def test_head(self):
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- 'response_checker'))
+ self.useFixture(fixtures.MockPatchObject(self.rest_client,
+ 'response_checker'))
resp, __ = self.rest_client.head(self.url)
self._verify_headers(resp)
@@ -136,8 +136,8 @@
def setUp(self):
self.fake_http = fake_http.fake_httplib2()
super(TestRestClientUpdateHeaders, self).setUp()
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- '_error_checker'))
+ self.useFixture(fixtures.MockPatchObject(self.rest_client,
+ '_error_checker'))
self.headers = {'X-Configuration-Session': 'session_id'}
def test_post_update_headers(self):
@@ -201,8 +201,8 @@
)
def test_head_update_headers(self):
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- 'response_checker'))
+ self.useFixture(fixtures.MockPatchObject(self.rest_client,
+ 'response_checker'))
__, return_dict = self.rest_client.head(self.url,
extra_headers=True,
@@ -1145,8 +1145,8 @@
}
def test_current_json_schema_validator_version(self):
- with mockpatch.PatchObject(jsonschema.Draft4Validator,
- "check_schema") as chk_schema:
+ with fixtures.MockPatchObject(jsonschema.Draft4Validator,
+ "check_schema") as chk_schema:
body = {'foo': 'test'}
self._test_validate_pass(self.schema, body)
chk_schema.mock.assert_called_once_with(
diff --git a/tempest/tests/test_decorators.py b/tempest/tests/test_decorators.py
index 8b6472b..2fc84dc 100644
--- a/tempest/tests/test_decorators.py
+++ b/tempest/tests/test_decorators.py
@@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import fixtures
from oslo_config import cfg
-from oslotest import mockpatch
import testtools
from tempest import config
@@ -95,8 +95,8 @@
'bad_service')
def test_services_decorator_with_service_valid_and_unavailable(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'cinder', False))
+ self.useFixture(fixtures.MockPatchObject(test.CONF.service_available,
+ 'cinder', False))
self.assertRaises(testtools.TestCase.skipException,
self._test_services_helper, 'compute',
'volume')