Better Scenario test case fixtures
This adds five persistent fixtures for Scenario test cases; previously they had been variously mocked, patched, etc., in different ways individually in many test cases. It improves the way those fixtures are used, mostly by using the .return_value attribute of Mock objects instead of calling the Mock objects in the test cases and dealing with strange side effects of that. It also adds assertions for get_from_manager() calls. Change-Id: I81a69683ef8ca0fc00bb408c951ec2f9a98e7ba0
This commit is contained in:
parent
b94ec1d62d
commit
434e8173fa
@ -22,7 +22,7 @@ AUTHENTICATE_MODULE = (
|
||||
"rally.plugins.openstack.scenarios.authenticate.authenticate")
|
||||
|
||||
|
||||
class AuthenticateTestCase(test.ClientsTestCase):
|
||||
class AuthenticateTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test_keystone(self):
|
||||
scenario = authenticate.Authenticate()
|
||||
|
@ -15,27 +15,17 @@
|
||||
import copy
|
||||
|
||||
import mock
|
||||
from oslotest import mockpatch
|
||||
|
||||
from rally.plugins.openstack.scenarios.ceilometer import utils
|
||||
from tests.unit import test
|
||||
|
||||
BM_UTILS = "rally.task.utils"
|
||||
CEILOMETER_UTILS = "rally.plugins.openstack.scenarios.ceilometer.utils"
|
||||
|
||||
|
||||
class CeilometerScenarioTestCase(test.ClientsTestCase):
|
||||
class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
||||
def setUp(self):
|
||||
super(CeilometerScenarioTestCase, self).setUp()
|
||||
self.scenario = utils.CeilometerScenario()
|
||||
self.res_is = mockpatch.Patch(BM_UTILS + ".resource_is")
|
||||
self.get_fm = mockpatch.Patch(BM_UTILS + ".get_from_manager")
|
||||
self.wait_for = mockpatch.Patch(CEILOMETER_UTILS +
|
||||
".bench_utils.wait_for")
|
||||
self.useFixture(self.wait_for)
|
||||
self.useFixture(self.res_is)
|
||||
self.useFixture(self.get_fm)
|
||||
self.gfm = self.get_fm.mock
|
||||
|
||||
def test__list_alarms_by_id(self):
|
||||
self.assertEqual(self.clients("ceilometer").alarms.get.return_value,
|
||||
@ -112,13 +102,14 @@ class CeilometerScenarioTestCase(test.ClientsTestCase):
|
||||
alarm = mock.Mock()
|
||||
self.clients("ceilometer").alarms.create.return_value = alarm
|
||||
return_alarm = self.scenario._set_alarm_state(alarm, "ok", 100)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
alarm,
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=100, check_interval=1)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ok")])
|
||||
self.assertEqual(self.wait_for.mock(), return_alarm)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ok")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_alarm)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"ceilometer.set_alarm_state")
|
||||
|
||||
|
@ -15,32 +15,20 @@
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslotest import mockpatch
|
||||
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack.scenarios.cinder import utils
|
||||
from tests.unit import fakes
|
||||
from tests.unit import test
|
||||
|
||||
BM_UTILS = "rally.task.utils"
|
||||
CINDER_UTILS = "rally.plugins.openstack.scenarios.cinder.utils"
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
class CinderScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(CinderScenarioTestCase, self).setUp()
|
||||
self.res_is = mockpatch.Patch(BM_UTILS + ".resource_is")
|
||||
self.get_fm = mockpatch.Patch(BM_UTILS + ".get_from_manager")
|
||||
self.wait_for = mockpatch.Patch(CINDER_UTILS + ".bench_utils.wait_for")
|
||||
self.wait_for_delete = mockpatch.Patch(
|
||||
CINDER_UTILS + ".bench_utils.wait_for_delete")
|
||||
self.useFixture(self.wait_for)
|
||||
self.useFixture(self.wait_for_delete)
|
||||
self.useFixture(self.res_is)
|
||||
self.useFixture(self.get_fm)
|
||||
self.gfm = self.get_fm.mock
|
||||
self.useFixture(mockpatch.Patch("time.sleep"))
|
||||
self.scenario = utils.CinderScenario()
|
||||
|
||||
def test__list_volumes(self):
|
||||
@ -101,23 +89,22 @@ class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
volume, keys, deletes=2, delete_size=3)
|
||||
|
||||
def test__create_volume(self):
|
||||
CONF = cfg.CONF
|
||||
return_volume = self.scenario._create_volume(1)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.clients("cinder").volumes.create.return_value,
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=CONF.benchmark.cinder_volume_create_poll_interval
|
||||
)
|
||||
self.res_is.mock.assert_has_calls([mock.call("available")])
|
||||
self.assertEqual(self.wait_for.mock(), return_volume)
|
||||
self.mock_resource_is.mock.assert_called_once_with("available")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_volume)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.create_volume")
|
||||
|
||||
@mock.patch("rally.plugins.openstack.scenarios.cinder.utils.random")
|
||||
def test__create_volume_with_size_range(self, mock_random):
|
||||
CONF = cfg.CONF
|
||||
mock_random.randint.return_value = 3
|
||||
|
||||
return_volume = self.scenario._create_volume(
|
||||
@ -127,15 +114,16 @@ class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
self.clients("cinder").volumes.create.assert_called_once_with(
|
||||
3, display_name="TestVolume")
|
||||
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.clients("cinder").volumes.create.return_value,
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=CONF.benchmark.cinder_volume_create_poll_interval
|
||||
)
|
||||
self.res_is.mock.assert_has_calls([mock.call("available")])
|
||||
self.assertEqual(self.wait_for.mock(), return_volume)
|
||||
self.mock_resource_is.mock.assert_called_once_with("available")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_volume)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.create_volume")
|
||||
|
||||
@ -143,18 +131,18 @@ class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
cinder = mock.Mock()
|
||||
self.scenario._delete_volume(cinder)
|
||||
cinder.delete.assert_called_once_with()
|
||||
self.wait_for_delete.mock.assert_called_once_with(
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
cinder,
|
||||
update_resource=self.gfm(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=cfg.CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=cfg.CONF.benchmark
|
||||
.cinder_volume_create_poll_interval)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.delete_volume")
|
||||
|
||||
@mock.patch("rally.plugins.openstack.scenarios.cinder.utils.random")
|
||||
def test__extend_volume_with_size_range(self, mock_random):
|
||||
CONF = cfg.CONF
|
||||
volume = mock.Mock()
|
||||
mock_random.randint.return_value = 3
|
||||
self.clients("cinder").volumes.extend.return_value = volume
|
||||
@ -162,30 +150,31 @@ class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
self.scenario._extend_volume(volume, new_size={"min": 1, "max": 5})
|
||||
|
||||
volume.extend.assert_called_once_with(volume, 3)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
volume,
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=CONF.benchmark.cinder_volume_create_poll_interval
|
||||
)
|
||||
self.res_is.mock.assert_has_calls([mock.call("available")])
|
||||
self.mock_resource_is.mock.assert_called_once_with("available")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.extend_volume")
|
||||
|
||||
def test__extend_volume(self):
|
||||
CONF = cfg.CONF
|
||||
volume = mock.Mock()
|
||||
self.clients("cinder").volumes.extend.return_value = volume
|
||||
self.scenario._extend_volume(volume, 2)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
volume,
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=CONF.benchmark.cinder_volume_create_poll_interval
|
||||
)
|
||||
self.res_is.mock.assert_has_calls([mock.call("available")])
|
||||
self.mock_resource_is.mock.assert_called_once_with("available")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.extend_volume")
|
||||
|
||||
@ -202,21 +191,41 @@ class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
|
||||
volume.upload_to_image.assert_called_once_with(False, "test_vol",
|
||||
"container", "disk")
|
||||
self.assertTrue(self.wait_for.mock.called)
|
||||
self.assertEqual(2, self.wait_for.mock.call_count)
|
||||
self.mock_wait_for.mock.assert_has_calls([
|
||||
mock.call(
|
||||
volume,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=CONF.benchmark.
|
||||
cinder_volume_create_poll_interval),
|
||||
mock.call(
|
||||
self.clients("glance").images.get.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=CONF.benchmark.glance_image_create_timeout,
|
||||
check_interval=CONF.benchmark.
|
||||
glance_image_create_poll_interval)
|
||||
])
|
||||
self.mock_get_from_manager.mock.assert_has_calls([mock.call(),
|
||||
mock.call()])
|
||||
self.mock_resource_is.mock.assert_has_calls([mock.call("available"),
|
||||
mock.call("active")])
|
||||
self.clients("glance").images.get.assert_called_once_with(1)
|
||||
|
||||
def test__create_snapshot(self):
|
||||
return_snapshot = self.scenario._create_snapshot("uuid", False)
|
||||
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.clients("cinder").volume_snapshots.create.return_value,
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=cfg.CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=cfg.CONF.benchmark
|
||||
.cinder_volume_create_poll_interval)
|
||||
self.res_is.mock.assert_has_calls([mock.call("available")])
|
||||
self.assertEqual(self.wait_for.mock(), return_snapshot)
|
||||
self.mock_resource_is.mock.assert_called_once_with("available")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_snapshot)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.create_snapshot")
|
||||
|
||||
@ -224,27 +233,29 @@ class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
snapshot = mock.Mock()
|
||||
self.scenario._delete_snapshot(snapshot)
|
||||
snapshot.delete.assert_called_once_with()
|
||||
self.wait_for_delete.mock.assert_called_once_with(
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
snapshot,
|
||||
update_resource=self.gfm(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=cfg.CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=cfg.CONF.benchmark
|
||||
.cinder_volume_create_poll_interval)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.delete_snapshot")
|
||||
|
||||
def test__create_backup(self):
|
||||
return_backup = self.scenario._create_backup("uuid")
|
||||
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.clients("cinder").backups.create.return_value,
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=cfg.CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=cfg.CONF.benchmark
|
||||
.cinder_volume_create_poll_interval)
|
||||
self.res_is.mock.assert_has_calls([mock.call("available")])
|
||||
self.assertEqual(self.wait_for.mock(), return_backup)
|
||||
self.mock_resource_is.mock.assert_called_once_with("available")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_backup)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.create_backup")
|
||||
|
||||
@ -252,12 +263,13 @@ class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
backup = mock.Mock()
|
||||
self.scenario._delete_backup(backup)
|
||||
backup.delete.assert_called_once_with()
|
||||
self.wait_for_delete.mock.assert_called_once_with(
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
backup,
|
||||
update_resource=self.gfm(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=cfg.CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=cfg.CONF.benchmark
|
||||
.cinder_volume_create_poll_interval)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.delete_backup")
|
||||
|
||||
@ -269,15 +281,16 @@ class CinderScenarioTestCase(test.ClientsTestCase):
|
||||
|
||||
return_restore = self.scenario._restore_backup(backup.id, None)
|
||||
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
restore,
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=cfg.CONF.benchmark.cinder_volume_create_timeout,
|
||||
check_interval=cfg.CONF.benchmark
|
||||
.cinder_volume_create_poll_interval)
|
||||
self.res_is.mock.assert_has_calls([mock.call("available")])
|
||||
self.assertEqual(self.wait_for.mock(), return_restore)
|
||||
self.mock_resource_is.mock.assert_called_once_with("available")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_restore)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.restore_backup")
|
||||
|
||||
|
@ -26,7 +26,7 @@ class fake_type(object):
|
||||
name = "fake"
|
||||
|
||||
|
||||
class CinderServersTestCase(test.ClientsTestCase):
|
||||
class CinderServersTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test_create_and_list_volume(self):
|
||||
scenario = volumes.CinderVolumes()
|
||||
|
@ -22,7 +22,7 @@ from tests.unit import test
|
||||
DESIGNATE_UTILS = "rally.plugins.openstack.scenarios.designate.utils."
|
||||
|
||||
|
||||
class DesignateScenarioTestCase(test.ClientsTestCase):
|
||||
class DesignateScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(DesignateScenarioTestCase, self).setUp()
|
||||
|
@ -21,15 +21,11 @@ from tests.unit import test
|
||||
UTILS = "rally.plugins.openstack.scenarios.ec2.utils."
|
||||
|
||||
|
||||
class EC2ServersTestCase(test.ClientsTestCase):
|
||||
class EC2ServersTestCase(test.ScenarioTestCase):
|
||||
|
||||
@mock.patch("rally.task.utils.wait_for",
|
||||
return_value="running_server")
|
||||
@mock.patch(UTILS + "ec2_resource_is", return_value="foo_state")
|
||||
@mock.patch(UTILS + "time")
|
||||
@mock.patch(UTILS + "CONF")
|
||||
def test_boot_server(self, mock_conf, mock_time, mock_ec2_resource_is,
|
||||
mock_wait_for):
|
||||
def test_boot_server(self, mock_conf, mock_ec2_resource_is):
|
||||
mock_conf.benchmark.ec2_server_boot_prepoll_delay = "foo_delay"
|
||||
mock_conf.benchmark.ec2_server_boot_timeout = "foo_timeout"
|
||||
mock_conf.benchmark.ec2_server_boot_poll_interval = "foo_interval"
|
||||
@ -40,9 +36,10 @@ class EC2ServersTestCase(test.ClientsTestCase):
|
||||
self.clients("ec2").run_instances.return_value = mock_instances
|
||||
server = scenario._boot_server("foo_image", "foo_flavor", foo="bar")
|
||||
|
||||
mock_wait_for.assert_called_once_with("foo_inst", is_ready="foo_state",
|
||||
update_resource="foo_update",
|
||||
timeout="foo_timeout",
|
||||
check_interval="foo_interval")
|
||||
mock_time.sleep.assert_called_once_with("foo_delay")
|
||||
self.assertEqual(server, "running_server")
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
"foo_inst", is_ready="foo_state",
|
||||
update_resource="foo_update",
|
||||
timeout="foo_timeout",
|
||||
check_interval="foo_interval")
|
||||
self.mock_sleep.mock.assert_called_once_with("foo_delay")
|
||||
self.assertEqual(server, self.mock_wait_for.mock.return_value)
|
||||
|
@ -38,37 +38,29 @@ class EC2UtilsTestCase(test.TestCase):
|
||||
resource.update.assert_called_once_with()
|
||||
|
||||
|
||||
class EC2ScenarioTestCase(test.ClientsTestCase):
|
||||
class EC2ScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(EC2ScenarioTestCase, self).setUp()
|
||||
self.server = mock.MagicMock()
|
||||
self.reservation = mock.MagicMock(instances=[self.server])
|
||||
self.res_is = mockpatch.Patch(EC2_UTILS + ".ec2_resource_is")
|
||||
self.update_res = mockpatch.Patch(
|
||||
self.mock_resource_is = mockpatch.Patch(EC2_UTILS + ".ec2_resource_is")
|
||||
self.mock_update_resource = mockpatch.Patch(
|
||||
EC2_UTILS + ".EC2Scenario._update_resource")
|
||||
self.wait_for = mockpatch.Patch(EC2_UTILS + ".utils.wait_for")
|
||||
self.useFixture(self.wait_for)
|
||||
self.useFixture(self.res_is)
|
||||
self.useFixture(self.update_res)
|
||||
self.useFixture(mockpatch.Patch("time.sleep"))
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions, name):
|
||||
action_duration = atomic_actions.get(name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
self.useFixture(self.mock_resource_is)
|
||||
self.useFixture(self.mock_update_resource)
|
||||
|
||||
def test__boot_server(self):
|
||||
self.clients("ec2").run_instances.return_value = self.reservation
|
||||
ec2_scenario = utils.EC2Scenario(context={})
|
||||
return_server = ec2_scenario._boot_server("image", "flavor")
|
||||
expected = mock.call(
|
||||
self.server, is_ready=self.res_is.mock(),
|
||||
update_resource=self.update_res.mock,
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_update_resource.mock,
|
||||
check_interval=CONF.benchmark.ec2_server_boot_poll_interval,
|
||||
timeout=CONF.benchmark.ec2_server_boot_timeout)
|
||||
self.assertEqual([expected], self.wait_for.mock.mock_calls)
|
||||
self.res_is.mock.assert_has_calls([mock.call("RUNNING")])
|
||||
self.assertEqual(self.wait_for.mock(), return_server)
|
||||
self.mock_resource_is.mock.assert_called_once_with("RUNNING")
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_server)
|
||||
self._test_atomic_action_timer(ec2_scenario.atomic_actions(),
|
||||
"ec2.boot_server")
|
||||
|
@ -71,12 +71,11 @@ class GlanceImagesTestCase(test.TestCase):
|
||||
mock__create_image.return_value = fake_image
|
||||
mock__boot_servers.return_value = fake_servers
|
||||
kwargs = {"fakearg": "f"}
|
||||
with mock.patch("rally.plugins.openstack.scenarios."
|
||||
"glance.utils.time.sleep"):
|
||||
glance_scenario.create_image_and_boot_instances("cf", "url",
|
||||
"df", "fid",
|
||||
5, **kwargs)
|
||||
mock__create_image.assert_called_once_with(
|
||||
"cf", "url", "df")
|
||||
mock__boot_servers.assert_called_once_with(
|
||||
"image-id-0", "fid", 5, **kwargs)
|
||||
|
||||
glance_scenario.create_image_and_boot_instances("cf", "url",
|
||||
"df", "fid",
|
||||
5, **kwargs)
|
||||
mock__create_image.assert_called_once_with(
|
||||
"cf", "url", "df")
|
||||
mock__boot_servers.assert_called_once_with(
|
||||
"image-id-0", "fid", 5, **kwargs)
|
||||
|
@ -15,33 +15,21 @@
|
||||
import tempfile
|
||||
|
||||
import mock
|
||||
from oslotest import mockpatch
|
||||
from oslo_config import cfg
|
||||
|
||||
from rally.plugins.openstack.scenarios.glance import utils
|
||||
from tests.unit import test
|
||||
|
||||
BM_UTILS = "rally.task.utils"
|
||||
GLANCE_UTILS = "rally.plugins.openstack.scenarios.glance.utils"
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class GlanceScenarioTestCase(test.ClientsTestCase):
|
||||
class GlanceScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(GlanceScenarioTestCase, self).setUp()
|
||||
self.image = mock.Mock()
|
||||
self.image1 = mock.Mock()
|
||||
self.res_is = mockpatch.Patch(BM_UTILS + ".resource_is")
|
||||
self.get_fm = mockpatch.Patch(BM_UTILS + ".get_from_manager")
|
||||
self.wait_for = mockpatch.Patch(GLANCE_UTILS + ".utils.wait_for")
|
||||
self.wait_for_delete = mockpatch.Patch(
|
||||
GLANCE_UTILS + ".utils.wait_for_delete")
|
||||
self.useFixture(self.wait_for)
|
||||
self.useFixture(self.wait_for_delete)
|
||||
self.useFixture(self.res_is)
|
||||
self.useFixture(self.get_fm)
|
||||
self.gfm = self.get_fm.mock
|
||||
self.useFixture(mockpatch.Patch("time.sleep"))
|
||||
self.scenario = utils.GlanceScenario()
|
||||
|
||||
def test_list_images(self):
|
||||
scenario = utils.GlanceScenario()
|
||||
@ -59,13 +47,15 @@ class GlanceScenarioTestCase(test.ClientsTestCase):
|
||||
return_image = scenario._create_image("container_format",
|
||||
image_location.name,
|
||||
"disk_format")
|
||||
self.wait_for.mock.assert_called_once_with(self.image,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
check_interval=1,
|
||||
timeout=120)
|
||||
self.res_is.mock.assert_has_calls([mock.call("active")])
|
||||
self.assertEqual(self.wait_for.mock(), return_image)
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.image,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.glance_image_create_poll_interval,
|
||||
timeout=CONF.benchmark.glance_image_create_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("active")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_image)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"glance.create_image")
|
||||
|
||||
@ -75,13 +65,15 @@ class GlanceScenarioTestCase(test.ClientsTestCase):
|
||||
return_image = scenario._create_image("container_format",
|
||||
"image_location",
|
||||
"disk_format")
|
||||
self.wait_for.mock.assert_called_once_with(self.image,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
check_interval=1,
|
||||
timeout=120)
|
||||
self.res_is.mock.assert_has_calls([mock.call("active")])
|
||||
self.assertEqual(self.wait_for.mock(), return_image)
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.image,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.glance_image_create_poll_interval,
|
||||
timeout=CONF.benchmark.glance_image_create_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("active")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_image)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"glance.create_image")
|
||||
|
||||
@ -89,10 +81,11 @@ class GlanceScenarioTestCase(test.ClientsTestCase):
|
||||
scenario = utils.GlanceScenario()
|
||||
scenario._delete_image(self.image)
|
||||
self.image.delete.assert_called_once_with()
|
||||
self.wait_for_delete.mock.assert_called_once_with(
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
self.image,
|
||||
update_resource=self.gfm(),
|
||||
check_interval=1,
|
||||
timeout=120)
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.glance_image_delete_poll_interval,
|
||||
timeout=CONF.benchmark.glance_image_delete_timeout)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"glance.delete_image")
|
||||
|
@ -21,7 +21,7 @@ from tests.unit import test
|
||||
HEAT_STACKS = "rally.plugins.openstack.scenarios.heat.stacks.HeatStacks"
|
||||
|
||||
|
||||
class HeatStacksTestCase(test.ClientsTestCase):
|
||||
class HeatStacksTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(HeatStacksTestCase, self).setUp()
|
||||
|
@ -14,33 +14,20 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import mockpatch
|
||||
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack.scenarios.heat import utils
|
||||
from tests.unit import test
|
||||
|
||||
BM_UTILS = "rally.task.utils"
|
||||
HEAT_UTILS = "rally.plugins.openstack.scenarios.heat.utils"
|
||||
|
||||
CONF = utils.CONF
|
||||
|
||||
|
||||
class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
class HeatScenarioTestCase(test.ScenarioTestCase):
|
||||
def setUp(self):
|
||||
super(HeatScenarioTestCase, self).setUp()
|
||||
self.stack = mock.Mock()
|
||||
self.res_is = mockpatch.Patch(BM_UTILS + ".resource_is")
|
||||
self.get_fm = mockpatch.Patch(BM_UTILS + ".get_from_manager")
|
||||
self.wait_for = mockpatch.Patch(HEAT_UTILS + ".utils.wait_for")
|
||||
self.wait_for_delete = mockpatch.Patch(
|
||||
HEAT_UTILS + ".utils.wait_for_delete")
|
||||
self.useFixture(self.wait_for)
|
||||
self.useFixture(self.wait_for_delete)
|
||||
self.useFixture(self.res_is)
|
||||
self.useFixture(self.get_fm)
|
||||
self.gfm = self.get_fm.mock
|
||||
self.useFixture(mockpatch.Patch("time.sleep"))
|
||||
self.scenario = utils.HeatScenario()
|
||||
self.default_template = "heat_template_version: 2013-05-23"
|
||||
self.dummy_parameters = {"dummy_param": "dummy_key"}
|
||||
@ -71,14 +58,16 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
self.assertIn(self.default_template, kwargs.values())
|
||||
self.assertIn(self.dummy_files, kwargs.values())
|
||||
self.assertIn(self.dummy_environment, kwargs.values())
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.stack,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.heat_stack_create_poll_interval,
|
||||
timeout=CONF.benchmark.heat_stack_create_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("CREATE_COMPLETE")])
|
||||
self.assertEqual(self.wait_for.mock(), return_stack)
|
||||
self.mock_resource_is.mock.assert_called_once_with("CREATE_COMPLETE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with(
|
||||
["CREATE_FAILED"])
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_stack)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"heat.create_stack")
|
||||
|
||||
@ -94,13 +83,15 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
self.assertIn(self.dummy_files, kwargs.values())
|
||||
self.assertIn(self.dummy_environment, kwargs.values())
|
||||
self.assertIn(self.stack.id, args)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.stack,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.heat_stack_update_poll_interval,
|
||||
timeout=CONF.benchmark.heat_stack_update_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("UPDATE_COMPLETE")])
|
||||
self.mock_resource_is.mock.assert_called_once_with("UPDATE_COMPLETE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with(
|
||||
["UPDATE_FAILED"])
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"heat.update_stack")
|
||||
|
||||
@ -109,13 +100,13 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
scenario._check_stack(self.stack)
|
||||
self.clients("heat").actions.check.assert_called_once_with(
|
||||
self.stack.id)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.stack,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.heat_stack_check_poll_interval,
|
||||
timeout=CONF.benchmark.heat_stack_check_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("CHECK_COMPLETE")])
|
||||
self.mock_resource_is.mock.assert_called_once_with("CHECK_COMPLETE")
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"heat.check_stack")
|
||||
|
||||
@ -123,11 +114,12 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
scenario = utils.HeatScenario()
|
||||
scenario._delete_stack(self.stack)
|
||||
self.stack.delete.assert_called_once_with()
|
||||
self.wait_for_delete.mock.assert_called_once_with(
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
self.stack,
|
||||
update_resource=self.gfm(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.heat_stack_delete_poll_interval,
|
||||
timeout=CONF.benchmark.heat_stack_delete_timeout)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"heat.delete_stack")
|
||||
|
||||
@ -136,13 +128,15 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
scenario._suspend_stack(self.stack)
|
||||
self.clients("heat").actions.suspend.assert_called_once_with(
|
||||
self.stack.id)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.stack,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.heat_stack_suspend_poll_interval,
|
||||
timeout=CONF.benchmark.heat_stack_suspend_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("SUSPEND_COMPLETE")])
|
||||
self.mock_resource_is.mock.assert_called_once_with("SUSPEND_COMPLETE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with(
|
||||
["SUSPEND_FAILED"])
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"heat.suspend_stack")
|
||||
|
||||
@ -151,13 +145,15 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
scenario._resume_stack(self.stack)
|
||||
self.clients("heat").actions.resume.assert_called_once_with(
|
||||
self.stack.id)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.stack,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.heat_stack_resume_poll_interval,
|
||||
timeout=CONF.benchmark.heat_stack_resume_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("RESUME_COMPLETE")])
|
||||
self.mock_resource_is.mock.assert_called_once_with("RESUME_COMPLETE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with(
|
||||
["RESUME_FAILED"])
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"heat.resume_stack")
|
||||
|
||||
@ -166,13 +162,15 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
scenario._snapshot_stack(self.stack)
|
||||
self.clients("heat").stacks.snapshot.assert_called_once_with(
|
||||
self.stack.id)
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.stack,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.heat_stack_snapshot_poll_interval,
|
||||
timeout=CONF.benchmark.heat_stack_snapshot_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("SNAPSHOT_COMPLETE")])
|
||||
self.mock_resource_is.mock.assert_called_once_with("SNAPSHOT_COMPLETE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with(
|
||||
["SNAPSHOT_FAILED"])
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"heat.snapshot_stack")
|
||||
|
||||
@ -181,18 +179,22 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
||||
scenario._restore_stack(self.stack, "dummy_id")
|
||||
self.clients("heat").stacks.restore.assert_called_once_with(
|
||||
self.stack.id, "dummy_id")
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.stack,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.heat_stack_restore_poll_interval,
|
||||
timeout=CONF.benchmark.heat_stack_restore_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("RESTORE_COMPLETE")])
|
||||
self.mock_resource_is.mock.assert_called_once_with("RESTORE_COMPLETE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with(
|
||||
["RESTORE_FAILED"])
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"heat.restore_stack")
|
||||
|
||||
|
||||
class HeatScenarioNegativeTestCase(test.ClientsTestCase):
|
||||
class HeatScenarioNegativeTestCase(test.ScenarioTestCase):
|
||||
patch_benchmark_utils = False
|
||||
|
||||
def test_failed_create_stack(self):
|
||||
self.clients("heat").stacks.create.return_value = {
|
||||
"stack": {"id": "test_id"}
|
||||
@ -203,12 +205,9 @@ class HeatScenarioNegativeTestCase(test.ClientsTestCase):
|
||||
stack.manager.get.return_value = resource
|
||||
self.clients("heat").stacks.get.return_value = stack
|
||||
scenario = utils.HeatScenario()
|
||||
try:
|
||||
ex = self.assertRaises(exceptions.GetResourceErrorStatus,
|
||||
scenario._create_stack, "stack_name")
|
||||
self.assertIn("has CREATE_FAILED status", str(ex))
|
||||
except exceptions.TimeoutException:
|
||||
raise self.fail("Unrecognized error status")
|
||||
ex = self.assertRaises(exceptions.GetResourceErrorStatus,
|
||||
scenario._create_stack, "stack_name")
|
||||
self.assertIn("has CREATE_FAILED status", str(ex))
|
||||
|
||||
def test_failed_update_stack(self):
|
||||
stack = mock.Mock()
|
||||
@ -217,10 +216,7 @@ class HeatScenarioNegativeTestCase(test.ClientsTestCase):
|
||||
stack.manager.get.return_value = resource
|
||||
self.clients("heat").stacks.get.return_value = stack
|
||||
scenario = utils.HeatScenario()
|
||||
try:
|
||||
ex = self.assertRaises(exceptions.GetResourceErrorStatus,
|
||||
scenario._update_stack, stack,
|
||||
"heat_template_version: 2013-05-23")
|
||||
self.assertIn("has UPDATE_FAILED status", str(ex))
|
||||
except exceptions.TimeoutException:
|
||||
raise self.fail("Unrecognized error status")
|
||||
ex = self.assertRaises(exceptions.GetResourceErrorStatus,
|
||||
scenario._update_stack, stack,
|
||||
"heat_template_version: 2013-05-23")
|
||||
self.assertIn("has UPDATE_FAILED status", str(ex))
|
||||
|
@ -45,7 +45,7 @@ class KeystoneUtilsTestCase(test.TestCase):
|
||||
self.assertEqual(utils.is_temporary(resource), is_valid)
|
||||
|
||||
|
||||
class KeystoneScenarioTestCase(test.ClientsTestCase):
|
||||
class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
@mock.patch(UTILS + "uuid.uuid4", return_value="pwd")
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
|
@ -23,7 +23,7 @@ BM_UTILS = "rally.task.utils."
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ManilaScenarioTestCase(test.ClientsTestCase):
|
||||
class ManilaScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ManilaScenarioTestCase, self).setUp()
|
||||
|
@ -19,7 +19,7 @@ from tests.unit import test
|
||||
MISTRAL_UTILS = "rally.plugins.openstack.scenarios.mistral.utils"
|
||||
|
||||
|
||||
class MistralScenarioTestCase(test.ClientsTestCase):
|
||||
class MistralScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test_list_workbooks(self):
|
||||
scenario = utils.MistralScenario()
|
||||
|
@ -14,30 +14,16 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import mockpatch
|
||||
from oslo_config import cfg
|
||||
|
||||
from rally.plugins.openstack.scenarios.murano import utils
|
||||
from tests.unit import test
|
||||
|
||||
BM_UTILS = "rally.task.utils"
|
||||
MRN_UTILS = "rally.plugins.openstack.scenarios.murano.utils"
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class MuranoScenarioTestCase(test.ClientsTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(MuranoScenarioTestCase, self).setUp()
|
||||
self.res_is = mockpatch.Patch(BM_UTILS + ".resource_is")
|
||||
self.get_fm = mockpatch.Patch(BM_UTILS + ".get_from_manager")
|
||||
self.wait_for = mockpatch.Patch(MRN_UTILS + ".utils.wait_for")
|
||||
self.wait_for_delete = mockpatch.Patch(
|
||||
MRN_UTILS + ".utils.wait_for_delete")
|
||||
self.useFixture(self.wait_for)
|
||||
self.useFixture(self.wait_for_delete)
|
||||
self.useFixture(self.res_is)
|
||||
self.useFixture(self.get_fm)
|
||||
self.gfm = self.get_fm.mock
|
||||
self.useFixture(mockpatch.Patch("time.sleep"))
|
||||
class MuranoScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test_list_environments(self):
|
||||
self.clients("murano").environments.list.return_value = []
|
||||
@ -66,11 +52,12 @@ class MuranoScenarioTestCase(test.ClientsTestCase):
|
||||
environment.id
|
||||
)
|
||||
|
||||
self.wait_for_delete.mock.assert_called_once_with(
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
environment,
|
||||
update_resource=self.gfm(),
|
||||
timeout=180,
|
||||
check_interval=2)
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
timeout=CONF.benchmark.delete_environment_timeout,
|
||||
check_interval=CONF.benchmark.delete_environment_check_interval)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"murano.delete_environment")
|
||||
|
||||
@ -107,11 +94,14 @@ class MuranoScenarioTestCase(test.ClientsTestCase):
|
||||
environment.id, session.id
|
||||
)
|
||||
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
environment,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=self.res_is.mock(),
|
||||
check_interval=5.0,
|
||||
timeout=1200.0)
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
check_interval=CONF.benchmark.deploy_environment_check_interval,
|
||||
timeout=CONF.benchmark.deploy_environment_timeout)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with(
|
||||
["DEPLOY FAILURE"])
|
||||
self.mock_resource_is.mock.assert_called_once_with("READY")
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"murano.deploy_environment")
|
||||
|
@ -22,7 +22,7 @@ NEUTRON_NETWORKS = ("rally.plugins.openstack.scenarios.neutron.network"
|
||||
".NeutronNetworks")
|
||||
|
||||
|
||||
class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
class NeutronNetworksTestCase(test.ScenarioTestCase):
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._list_networks")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
|
@ -22,7 +22,7 @@ from tests.unit import test
|
||||
NEUTRON_UTILS = "rally.plugins.openstack.scenarios.neutron.utils."
|
||||
|
||||
|
||||
class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
class NeutronScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NeutronScenarioTestCase, self).setUp()
|
||||
@ -469,7 +469,7 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
"neutron.list_pools")
|
||||
|
||||
|
||||
class NeutronScenarioFunctionalTestCase(test.FakeClientsTestCase):
|
||||
class NeutronScenarioFunctionalTestCase(test.FakeClientsScenarioTestCase):
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + "network_wrapper.generate_cidr")
|
||||
def test_functional_create_network_and_subnets(self, mock_generate_cidr):
|
||||
|
@ -25,7 +25,7 @@ NOVA_SERVERS_MODULE = "rally.plugins.openstack.scenarios.nova.servers"
|
||||
NOVA_SERVERS = NOVA_SERVERS_MODULE + ".NovaServers"
|
||||
|
||||
|
||||
class NovaServersTestCase(test.ClientsTestCase):
|
||||
class NovaServersTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test_boot_rescue_unrescue(self):
|
||||
actions = [{"rescue_unrescue": 5}]
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslotest import mockpatch
|
||||
|
||||
from rally import exceptions as rally_exceptions
|
||||
from rally.plugins.openstack.scenarios.nova import utils
|
||||
@ -27,7 +26,7 @@ NOVA_UTILS = "rally.plugins.openstack.scenarios.nova.utils"
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NovaScenarioTestCase, self).setUp()
|
||||
@ -37,45 +36,6 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
self.floating_ip = mock.Mock()
|
||||
self.image = mock.Mock()
|
||||
self.keypair = mock.Mock()
|
||||
self.res_is = mockpatch.Patch(BM_UTILS + ".resource_is")
|
||||
self.get_fm = mockpatch.Patch(BM_UTILS + ".get_from_manager")
|
||||
self.wait_for = mockpatch.Patch(NOVA_UTILS + ".utils.wait_for")
|
||||
self.wait_for_delete = mockpatch.Patch(NOVA_UTILS +
|
||||
".utils.wait_for_delete")
|
||||
self.useFixture(self.wait_for_delete)
|
||||
self.useFixture(self.wait_for)
|
||||
self.useFixture(self.res_is)
|
||||
self.useFixture(self.get_fm)
|
||||
self.gfm = self.get_fm.mock
|
||||
self.useFixture(mockpatch.Patch("time.sleep"))
|
||||
|
||||
def _test_assert_called_once_with(self, mock, resource,
|
||||
chk_interval, time_out, **kwargs):
|
||||
"""Method to replace repeatative asserts on resources
|
||||
|
||||
:param mock: The mock to call assert with
|
||||
:param resource: The resource used in mock
|
||||
:param chk_interval: The interval used for polling the action
|
||||
:param time_out: Time out value for action
|
||||
:param kwargs: currently used for validating the is_ready attribute,
|
||||
can be extended as required
|
||||
"""
|
||||
|
||||
isready = self.res_is.mock()
|
||||
if kwargs:
|
||||
if kwargs["is_ready"]:
|
||||
mock.assert_called_once_with(
|
||||
resource,
|
||||
update_resource=self.gfm(),
|
||||
is_ready=isready,
|
||||
check_interval=chk_interval,
|
||||
timeout=time_out)
|
||||
else:
|
||||
mock.assert_called_once_with(
|
||||
resource,
|
||||
update_resource=self.gfm(),
|
||||
check_interval=chk_interval,
|
||||
timeout=time_out)
|
||||
|
||||
def test__list_servers(self):
|
||||
servers_list = []
|
||||
@ -93,12 +53,15 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario(context={})
|
||||
return_server = nova_scenario._boot_server("image_id",
|
||||
"flavor_id")
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
CONF.benchmark.nova_server_boot_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.assertEqual(self.wait_for.mock(), return_server)
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_boot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_boot_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_server)
|
||||
self.clients("nova").servers.create.assert_called_once_with(
|
||||
"foo_server_name", "image_id", "flavor_id")
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
@ -118,15 +81,18 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
return_server = nova_scenario._boot_server("image_id",
|
||||
"flavor_id",
|
||||
auto_assign_nic=True)
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
CONF.benchmark.nova_server_boot_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_boot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_boot_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.clients("nova").servers.create.assert_called_once_with(
|
||||
"foo_server_name", "image_id", "flavor_id",
|
||||
nics=[{"net-id": "bar_id"}])
|
||||
self.assertEqual(self.wait_for.mock(), return_server)
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_server)
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.boot_server")
|
||||
|
||||
@ -146,12 +112,15 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
"user": {"secgroup": {"name": "test"}}}
|
||||
)
|
||||
return_server = nova_scenario._boot_server("image_id", "flavor_id")
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
CONF.benchmark.nova_server_boot_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.assertEqual(self.wait_for.mock(), return_server)
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_boot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_boot_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_server)
|
||||
self.clients("nova").servers.create.assert_called_once_with(
|
||||
"foo_server_name", "image_id", "flavor_id",
|
||||
security_groups=["test"])
|
||||
@ -168,12 +137,15 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
return_server = nova_scenario._boot_server(
|
||||
"image_id", "flavor_id",
|
||||
security_groups=["test"])
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
CONF.benchmark.nova_server_boot_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.assertEqual(self.wait_for.mock(), return_server)
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_boot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_boot_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_server)
|
||||
self.clients("nova").servers.create.assert_called_once_with(
|
||||
"foo_server_name", "image_id", "flavor_id",
|
||||
security_groups=["test", "new"])
|
||||
@ -191,12 +163,15 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
return_server = nova_scenario._boot_server(
|
||||
"image_id", "flavor_id",
|
||||
security_groups=["test1"])
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
CONF.benchmark.nova_server_boot_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.assertEqual(self.wait_for.mock(), return_server)
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_boot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_boot_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_server)
|
||||
self.clients("nova").servers.create.assert_called_once_with(
|
||||
"foo_server_name", "image_id", "flavor_id",
|
||||
security_groups=["test1"])
|
||||
@ -207,11 +182,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._suspend_server(self.server)
|
||||
self.server.suspend.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_suspend_poll_interval,
|
||||
CONF.benchmark.nova_server_suspend_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("SUSPENDED")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_suspend_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_suspend_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("SUSPENDED")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.suspend_server")
|
||||
|
||||
@ -219,11 +197,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._resume_server(self.server)
|
||||
self.server.resume.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_resume_poll_interval,
|
||||
CONF.benchmark.nova_server_resume_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_resume_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_resume_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.resume_server")
|
||||
|
||||
@ -231,11 +212,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._pause_server(self.server)
|
||||
self.server.pause.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_pause_poll_interval,
|
||||
CONF.benchmark.nova_server_pause_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("PAUSED")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_pause_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_pause_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("PAUSED")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.pause_server")
|
||||
|
||||
@ -243,11 +227,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._unpause_server(self.server)
|
||||
self.server.unpause.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_unpause_poll_interval,
|
||||
CONF.benchmark.nova_server_unpause_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_unpause_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_unpause_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.unpause_server")
|
||||
|
||||
@ -255,11 +242,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._shelve_server(self.server)
|
||||
self.server.shelve.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_shelve_poll_interval,
|
||||
CONF.benchmark.nova_server_shelve_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("SHELVED_OFFLOADED")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_shelve_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_shelve_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("SHELVED_OFFLOADED")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.shelve_server")
|
||||
|
||||
@ -267,11 +257,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._unshelve_server(self.server)
|
||||
self.server.unshelve.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_unshelve_poll_interval,
|
||||
CONF.benchmark.nova_server_unshelve_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_unshelve_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_unshelve_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.unshelve_server")
|
||||
|
||||
@ -279,12 +272,16 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
self.clients("nova").images.get.return_value = self.image
|
||||
nova_scenario = utils.NovaScenario()
|
||||
return_image = nova_scenario._create_image(self.server)
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.image,
|
||||
CONF.benchmark.nova_server_image_create_poll_interval,
|
||||
CONF.benchmark.nova_server_image_create_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.assertEqual(self.wait_for.mock(), return_image)
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.image,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.
|
||||
nova_server_image_create_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_image_create_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(self.mock_wait_for.mock.return_value, return_image)
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.create_image")
|
||||
|
||||
@ -292,11 +289,12 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._delete_server(self.server)
|
||||
self.server.delete.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for_delete.mock, self.server,
|
||||
CONF.benchmark.nova_server_delete_poll_interval,
|
||||
CONF.benchmark.nova_server_delete_timeout,
|
||||
is_ready=None)
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
self.server,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_delete_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_delete_timeout)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.delete_server")
|
||||
|
||||
@ -304,11 +302,12 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._delete_server(self.server, force=True)
|
||||
self.server.force_delete.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for_delete.mock, self.server,
|
||||
CONF.benchmark.nova_server_delete_poll_interval,
|
||||
CONF.benchmark.nova_server_delete_timeout,
|
||||
is_ready=None)
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
self.server,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_delete_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_delete_timeout)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.force_delete_server")
|
||||
|
||||
@ -316,11 +315,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._reboot_server(self.server)
|
||||
self.server.reboot.assert_called_once_with(reboot_type="HARD")
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_reboot_poll_interval,
|
||||
CONF.benchmark.nova_server_reboot_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_reboot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_reboot_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.reboot_server")
|
||||
|
||||
@ -328,11 +330,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._soft_reboot_server(self.server)
|
||||
self.server.reboot.assert_called_once_with(reboot_type="SOFT")
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_reboot_poll_interval,
|
||||
CONF.benchmark.nova_server_reboot_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_reboot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_reboot_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.soft_reboot_server")
|
||||
|
||||
@ -340,11 +345,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._rebuild_server(self.server, "img", fakearg="fakearg")
|
||||
self.server.rebuild.assert_called_once_with("img", fakearg="fakearg")
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_rebuild_poll_interval,
|
||||
CONF.benchmark.nova_server_rebuild_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_rebuild_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_rebuild_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.rebuild_server")
|
||||
|
||||
@ -352,11 +360,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._start_server(self.server)
|
||||
self.server.start.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_start_poll_interval,
|
||||
CONF.benchmark.nova_server_start_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_start_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_start_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.start_server")
|
||||
|
||||
@ -364,11 +375,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._stop_server(self.server)
|
||||
self.server.stop.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_stop_poll_interval,
|
||||
CONF.benchmark.nova_server_stop_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("SHUTOFF")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_stop_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_stop_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("SHUTOFF")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.stop_server")
|
||||
|
||||
@ -376,11 +390,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._rescue_server(self.server)
|
||||
self.server.rescue.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_rescue_poll_interval,
|
||||
CONF.benchmark.nova_server_rescue_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("RESCUE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_rescue_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_rescue_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("RESCUE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.rescue_server")
|
||||
|
||||
@ -388,11 +405,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._unrescue_server(self.server)
|
||||
self.server.unrescue.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_unrescue_poll_interval,
|
||||
CONF.benchmark.nova_server_unrescue_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_unrescue_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_unrescue_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.unrescue_server")
|
||||
|
||||
@ -404,7 +424,8 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
expected = []
|
||||
for server in servers:
|
||||
expected.append(mock.call(
|
||||
server, update_resource=self.gfm(),
|
||||
server,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=check_interval,
|
||||
timeout=CONF.benchmark.nova_server_delete_timeout))
|
||||
if force:
|
||||
@ -414,7 +435,7 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
server.delete.assert_called_once_with()
|
||||
self.assertFalse(server.force_delete.called)
|
||||
|
||||
self.assertEqual(expected, self.wait_for_delete.mock.mock_calls)
|
||||
self.mock_wait_for_delete.mock.assert_has_calls(expected)
|
||||
timer_name = "nova.%sdelete_servers" % ("force_" if force else "")
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
timer_name)
|
||||
@ -429,11 +450,13 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._delete_image(self.image)
|
||||
self.image.delete.assert_called_once_with()
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for_delete.mock, self.image,
|
||||
CONF.benchmark.nova_server_image_delete_poll_interval,
|
||||
CONF.benchmark.nova_server_image_delete_timeout,
|
||||
is_ready=None)
|
||||
self.mock_wait_for_delete.mock.assert_called_once_with(
|
||||
self.image,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.
|
||||
nova_server_image_delete_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_image_delete_timeout)
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.delete_image")
|
||||
|
||||
@ -444,20 +467,25 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario._boot_servers("image", "flavor", 2)
|
||||
expected = [
|
||||
mock.call(
|
||||
self.server, is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_boot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_boot_timeout
|
||||
),
|
||||
mock.call(
|
||||
self.server1, is_ready=self.res_is.mock(),
|
||||
update_resource=self.gfm(),
|
||||
self.server1,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_boot_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_boot_timeout
|
||||
)
|
||||
]
|
||||
self.assertEqual(expected, self.wait_for.mock.mock_calls)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_has_calls(expected)
|
||||
self.mock_resource_is.mock.assert_has_calls([mock.call("ACTIVE"),
|
||||
mock.call("ACTIVE")])
|
||||
self.mock_get_from_manager.mock.assert_has_calls([mock.call(),
|
||||
mock.call()])
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.boot_servers")
|
||||
|
||||
@ -559,11 +587,15 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
disk_over_commit=False,
|
||||
skip_host_check=True)
|
||||
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_live_migrate_poll_interval,
|
||||
CONF.benchmark.nova_server_live_migrate_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
self.server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.
|
||||
nova_server_live_migrate_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_live_migrate_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("ACTIVE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.live_migrate")
|
||||
|
||||
@ -596,11 +628,14 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._migrate(fake_server, skip_host_check=True)
|
||||
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, fake_server,
|
||||
CONF.benchmark.nova_server_migrate_poll_interval,
|
||||
CONF.benchmark.nova_server_migrate_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("VERIFY_RESIZE")])
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
fake_server,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.nova_server_migrate_poll_interval,
|
||||
timeout=CONF.benchmark.nova_server_migrate_timeout)
|
||||
self.mock_resource_is.mock.assert_called_once_with("VERIFY_RESIZE")
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.migrate")
|
||||
|
||||
|
@ -19,7 +19,7 @@ from rally.plugins.openstack.scenarios.quotas import quotas
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
class QuotasTestCase(test.ClientsTestCase):
|
||||
class QuotasTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(QuotasTestCase, self).setUp()
|
||||
|
@ -20,7 +20,7 @@ from rally.plugins.openstack.scenarios.quotas import utils
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
class QuotasScenarioTestCase(test.ClientsTestCase):
|
||||
class QuotasScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test__update_quotas(self):
|
||||
tenant_id = "fake_tenant"
|
||||
|
@ -23,7 +23,7 @@ SAHARA_CLUSTERS = ("rally.plugins.openstack.scenarios.sahara.clusters"
|
||||
SAHARA_UTILS = "rally.plugins.openstack.scenarios.sahara.utils"
|
||||
|
||||
|
||||
class SaharaClustersTestCase(test.ClientsTestCase):
|
||||
class SaharaClustersTestCase(test.ScenarioTestCase):
|
||||
|
||||
@mock.patch(SAHARA_CLUSTERS + "._delete_cluster")
|
||||
@mock.patch(SAHARA_CLUSTERS + "._launch_cluster",
|
||||
|
@ -25,7 +25,7 @@ SAHARA_JOB = "rally.plugins.openstack.scenarios.sahara.jobs.SaharaJob"
|
||||
SAHARA_UTILS = "rally.plugins.openstack.scenarios.sahara.utils"
|
||||
|
||||
|
||||
class SaharaJobTestCase(test.ClientsTestCase):
|
||||
class SaharaJobTestCase(test.ScenarioTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SaharaJobTestCase, self).setUp()
|
||||
|
@ -28,7 +28,15 @@ CONF = cfg.CONF
|
||||
SAHARA_UTILS = "rally.plugins.openstack.scenarios.sahara.utils"
|
||||
|
||||
|
||||
class SaharaScenarioTestCase(test.ClientsTestCase):
|
||||
class SaharaScenarioTestCase(test.ScenarioTestCase):
|
||||
# NOTE(stpierre): the Sahara utils generally do funny stuff with
|
||||
# wait_for() calls -- frequently the the is_ready and
|
||||
# update_resource arguments are functions defined in the Sahara
|
||||
# utils themselves instead of the more standard resource_is() and
|
||||
# get_from_manager() calls. As a result, the tests below do more
|
||||
# integrated/functional testing of wait_for() calls, and we can't
|
||||
# just mock out wait_for and friends the way we usually do.
|
||||
patch_benchmark_utils = False
|
||||
|
||||
def setUp(self):
|
||||
super(SaharaScenarioTestCase, self).setUp()
|
||||
|
@ -19,7 +19,7 @@ from rally.plugins.openstack.scenarios.swift import objects
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
class SwiftObjectsTestCase(test.ClientsTestCase):
|
||||
class SwiftObjectsTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test_create_container_and_object_then_list_objects(self):
|
||||
scenario = objects.SwiftObjects()
|
||||
|
@ -21,7 +21,7 @@ from tests.unit import test
|
||||
SWIFT_UTILS = "rally.plugins.openstack.scenarios.swift.utils"
|
||||
|
||||
|
||||
class SwiftScenarioTestCase(test.ClientsTestCase):
|
||||
class SwiftScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test__list_containers(self):
|
||||
headers_dict = mock.MagicMock()
|
||||
|
@ -18,7 +18,6 @@ import subprocess
|
||||
|
||||
import mock
|
||||
import netaddr
|
||||
from oslotest import mockpatch
|
||||
|
||||
from rally.plugins.openstack.scenarios.vm import utils
|
||||
from tests.unit import test
|
||||
@ -26,13 +25,7 @@ from tests.unit import test
|
||||
VMTASKS_UTILS = "rally.plugins.openstack.scenarios.vm.utils"
|
||||
|
||||
|
||||
class VMScenarioTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(VMScenarioTestCase, self).setUp()
|
||||
self.wait_for = mockpatch.Patch(VMTASKS_UTILS +
|
||||
".utils.wait_for")
|
||||
self.useFixture(self.wait_for)
|
||||
class VMScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
@mock.patch("%s.open" % VMTASKS_UTILS,
|
||||
side_effect=mock.mock_open(), create=True)
|
||||
@ -92,19 +85,16 @@ class VMScenarioTestCase(test.TestCase):
|
||||
vm_scenario._wait_for_ssh(ssh)
|
||||
ssh.wait.assert_called_once_with()
|
||||
|
||||
@mock.patch(VMTASKS_UTILS + ".utils.resource_is")
|
||||
@mock.patch(VMTASKS_UTILS + ".VMScenario._ping_ip_address",
|
||||
return_value=True)
|
||||
def test__wait_for_ping(self, mock_vm_scenario__ping_ip_address,
|
||||
mock_resource_is):
|
||||
def test__wait_for_ping(self):
|
||||
vm_scenario = utils.VMScenario()
|
||||
vm_scenario._ping_ip_address = mock.Mock(return_value=True)
|
||||
vm_scenario._wait_for_ping(netaddr.IPAddress("1.2.3.4"))
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
self.mock_wait_for.mock.assert_called_once_with(
|
||||
netaddr.IPAddress("1.2.3.4"),
|
||||
is_ready=mock_resource_is.return_value,
|
||||
is_ready=self.mock_resource_is.mock.return_value,
|
||||
timeout=120)
|
||||
mock_resource_is.assert_called_once_with(
|
||||
"ICMP UP", mock_vm_scenario__ping_ip_address)
|
||||
self.mock_resource_is.mock.assert_called_once_with(
|
||||
"ICMP UP", vm_scenario._ping_ip_address)
|
||||
|
||||
@mock.patch(VMTASKS_UTILS + ".VMScenario._run_command_over_ssh")
|
||||
@mock.patch("rally.common.sshutils.SSH")
|
||||
|
@ -21,7 +21,7 @@ from tests.unit import test
|
||||
UTILS = "rally.plugins.openstack.scenarios.zaqar.utils."
|
||||
|
||||
|
||||
class ZaqarScenarioTestCase(test.ClientsTestCase):
|
||||
class ZaqarScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
@mock.patch(UTILS + "ZaqarScenario._generate_random_name",
|
||||
return_value="kitkat")
|
||||
|
@ -18,6 +18,7 @@ import os
|
||||
import mock
|
||||
from oslo_config import fixture
|
||||
from oslotest import base
|
||||
from oslotest import mockpatch
|
||||
|
||||
from rally import db
|
||||
from tests.unit import fakes
|
||||
@ -58,8 +59,10 @@ class DBTestCase(TestCase):
|
||||
self.useFixture(DatabaseFixture())
|
||||
|
||||
|
||||
class ClientsTestCase(TestCase):
|
||||
class ScenarioTestCase(TestCase):
|
||||
"""Base class for Scenario tests using mocked self.clients."""
|
||||
benchmark_utils = "rally.task.utils"
|
||||
patch_benchmark_utils = True
|
||||
|
||||
def client_factory(self, client_type, version=None, admin=False):
|
||||
"""Create a new client object."""
|
||||
@ -91,7 +94,24 @@ class ClientsTestCase(TestCase):
|
||||
return key in self._clients
|
||||
|
||||
def setUp(self):
|
||||
super(ClientsTestCase, self).setUp()
|
||||
super(ScenarioTestCase, self).setUp()
|
||||
if self.patch_benchmark_utils:
|
||||
self.mock_resource_is = mockpatch.Patch(
|
||||
self.benchmark_utils + ".resource_is")
|
||||
self.mock_get_from_manager = mockpatch.Patch(
|
||||
self.benchmark_utils + ".get_from_manager")
|
||||
self.mock_wait_for = mockpatch.Patch(
|
||||
self.benchmark_utils + ".wait_for")
|
||||
self.mock_wait_for_delete = mockpatch.Patch(
|
||||
self.benchmark_utils + ".wait_for_delete")
|
||||
self.useFixture(self.mock_resource_is)
|
||||
self.useFixture(self.mock_get_from_manager)
|
||||
self.useFixture(self.mock_wait_for)
|
||||
self.useFixture(self.mock_wait_for_delete)
|
||||
|
||||
self.mock_sleep = mockpatch.Patch("time.sleep")
|
||||
self.useFixture(self.mock_sleep)
|
||||
|
||||
self._clients = {}
|
||||
self._client_mocks = [
|
||||
mock.patch("rally.task.scenarios.base.Scenario.clients",
|
||||
@ -105,15 +125,15 @@ class ClientsTestCase(TestCase):
|
||||
def tearDown(self):
|
||||
for patcher in self._client_mocks:
|
||||
patcher.stop()
|
||||
super(ClientsTestCase, self).tearDown()
|
||||
super(ScenarioTestCase, self).tearDown()
|
||||
|
||||
|
||||
class FakeClientsTestCase(ClientsTestCase):
|
||||
class FakeClientsScenarioTestCase(ScenarioTestCase):
|
||||
"""Base class for Scenario tests using fake (not mocked) self.clients."""
|
||||
|
||||
def client_factory(self, client_type, version=None, admin=False):
|
||||
return getattr(self._fake_clients, client_type)()
|
||||
|
||||
def setUp(self):
|
||||
super(FakeClientsTestCase, self).setUp()
|
||||
super(FakeClientsScenarioTestCase, self).setUp()
|
||||
self._fake_clients = fakes.FakeClients()
|
||||
|
Loading…
Reference in New Issue
Block a user