diff --git a/rally/plugins/openstack/scenarios/authenticate/authenticate.py b/rally/plugins/openstack/scenarios/authenticate/authenticate.py index 2e99c309..ad54d385 100644 --- a/rally/plugins/openstack/scenarios/authenticate/authenticate.py +++ b/rally/plugins/openstack/scenarios/authenticate/authenticate.py @@ -47,9 +47,7 @@ class ValidateGlance(scenario.OpenStackScenario): """ glance_client = self.clients("glance") image_name = "__intentionally_non_existent_image___" - with atomic.ActionTimer( - self, - "authenticate.validate_glance_%s_times" % repetitions): + with atomic.ActionTimer(self, "authenticate.validate_glance"): for i in range(repetitions): list(glance_client.images.list(name=image_name)) @@ -68,9 +66,7 @@ class ValidateNova(scenario.OpenStackScenario): :param repetitions: number of times to validate """ nova_client = self.clients("nova") - with atomic.ActionTimer( - self, - "authenticate.validate_nova_%s_times" % repetitions): + with atomic.ActionTimer(self, "authenticate.validate_nova"): for i in range(repetitions): nova_client.flavors.list() @@ -90,9 +86,7 @@ class ValidateCeilometer(scenario.OpenStackScenario): :param repetitions: number of times to validate """ ceilometer_client = self.clients("ceilometer") - with atomic.ActionTimer( - self, - "authenticate.validate_ceilometer_%s_times" % repetitions): + with atomic.ActionTimer(self, "authenticate.validate_ceilometer"): for i in range(repetitions): ceilometer_client.meters.list() @@ -111,9 +105,7 @@ class ValidateCinder(scenario.OpenStackScenario): :param repetitions: number of times to validate """ cinder_client = self.clients("cinder") - with atomic.ActionTimer( - self, - "authenticate.validate_cinder_%s_times" % repetitions): + with atomic.ActionTimer(self, "authenticate.validate_cinder"): for i in range(repetitions): cinder_client.volume_types.list() @@ -132,9 +124,7 @@ class ValidateNeutron(scenario.OpenStackScenario): :param repetitions: number of times to validate """ neutron_client = self.clients("neutron") - with atomic.ActionTimer( - self, - "authenticate.validate_neutron_%s_times" % repetitions): + with atomic.ActionTimer(self, "authenticate.validate_neutron"): for i in range(repetitions): neutron_client.list_networks() @@ -153,9 +143,7 @@ class ValidateHeat(scenario.OpenStackScenario): :param repetitions: number of times to validate """ heat_client = self.clients("heat") - with atomic.ActionTimer( - self, - "authenticate.validate_heat_%s_times" % repetitions): + with atomic.ActionTimer(self, "authenticate.validate_heat"): for i in range(repetitions): list(heat_client.stacks.list(limit=0)) @@ -176,8 +164,6 @@ class ValidateMonasca(scenario.OpenStackScenario): :param repetitions: number of times to validate """ monasca_client = self.clients("monasca") - with atomic.ActionTimer( - self, - "authenticate.validate_monasca_%s_times" % repetitions): + with atomic.ActionTimer(self, "authenticate.validate_monasca"): for i in range(repetitions): list(monasca_client.metrics.list(limit=0)) diff --git a/rally/plugins/openstack/scenarios/heat/stacks.py b/rally/plugins/openstack/scenarios/heat/stacks.py index 3c7b55ce..b7c69b00 100644 --- a/rally/plugins/openstack/scenarios/heat/stacks.py +++ b/rally/plugins/openstack/scenarios/heat/stacks.py @@ -61,9 +61,8 @@ class ListStacksAndResources(utils.HeatScenario): def run(self): """List all resources from tenant stacks.""" stacks = self._list_stacks() - with atomic.ActionTimer( - self, "heat.list_resources_of_%s_stacks" % len(stacks)): - for stack in stacks: + for stack in stacks: + with atomic.ActionTimer(self, "heat.list_resources"): self.clients("heat").resources.list(stack.id) @@ -250,9 +249,8 @@ class ListStacksAndEvents(utils.HeatScenario): def run(self): """List events from tenant stacks.""" stacks = self._list_stacks() - with atomic.ActionTimer( - self, "heat.list_events_of_%s_stacks" % len(stacks)): - for stack in stacks: + for stack in stacks: + with atomic.ActionTimer(self, "heat.list_events"): self.clients("heat").events.list(stack.id) diff --git a/rally/plugins/openstack/scenarios/neutron/loadbalancer_v1.py b/rally/plugins/openstack/scenarios/neutron/loadbalancer_v1.py index 4012589a..f40bb76b 100644 --- a/rally/plugins/openstack/scenarios/neutron/loadbalancer_v1.py +++ b/rally/plugins/openstack/scenarios/neutron/loadbalancer_v1.py @@ -15,7 +15,6 @@ import random from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.neutron import utils -from rally.task import atomic from rally.task import validation @@ -132,9 +131,8 @@ class CreateAndListVips(utils.NeutronScenario): pool_create_args = pool_create_args or {} networks = self.context.get("tenant", {}).get("networks", []) pools = self._create_v1_pools(networks, **pool_create_args) - with atomic.ActionTimer(self, "neutron.create_%s_vips" % len(pools)): - for pool in pools: - self._create_v1_vip(pool, **vip_create_args) + for pool in pools: + self._create_v1_vip(pool, **vip_create_args) self._list_v1_vips() @@ -165,9 +163,8 @@ class CreateAndDeleteVips(utils.NeutronScenario): vip_create_args = vip_create_args or {} networks = self.context.get("tenant", {}).get("networks", []) pools = self._create_v1_pools(networks, **pool_create_args) - with atomic.ActionTimer(self, "neutron.create_%s_vips" % len(pools)): - for pool in pools: - vips.append(self._create_v1_vip(pool, **vip_create_args)) + for pool in pools: + vips.append(self._create_v1_vip(pool, **vip_create_args)) for vip in vips: self._delete_v1_vip(vip["vip"]) @@ -202,9 +199,8 @@ class CreateAndUpdateVips(utils.NeutronScenario): vip_update_args = vip_update_args or {} networks = self.context.get("tenant", {}).get("networks", []) pools = self._create_v1_pools(networks, **pool_create_args) - with atomic.ActionTimer(self, "neutron.create_%s_vips" % len(pools)): - for pool in pools: - vips.append(self._create_v1_vip(pool, **vip_create_args)) + for pool in pools: + vips.append(self._create_v1_vip(pool, **vip_create_args)) for vip in vips: self._update_v1_vip(vip, **vip_update_args) diff --git a/rally/plugins/openstack/scenarios/neutron/network.py b/rally/plugins/openstack/scenarios/neutron/network.py index fd349c41..ce7b16b7 100644 --- a/rally/plugins/openstack/scenarios/neutron/network.py +++ b/rally/plugins/openstack/scenarios/neutron/network.py @@ -16,7 +16,6 @@ from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.neutron import utils -from rally.task import atomic from rally.task import validation @@ -472,17 +471,15 @@ class CreateAndShowPorts(utils.NeutronScenario): port_create_args = port_create_args or {} network = self._get_or_create_network(network_create_args) - with atomic.ActionTimer(self, "neutron.create_and_show_%i_ports" % - ports_per_network): - for i in range(ports_per_network): - port = self._create_port(network, port_create_args) - msg = "Port isn't created" - self.assertTrue(port, err_msg=msg) + for i in range(ports_per_network): + port = self._create_port(network, port_create_args) + msg = "Port isn't created" + self.assertTrue(port, err_msg=msg) - port_info = self._show_port(port) - msg = "Created port and Showed port isn't equal" - self.assertEqual(port["port"]["id"], port_info["port"]["id"], - err_msg=msg) + port_info = self._show_port(port) + msg = "Created port and Showed port isn't equal" + self.assertEqual(port["port"]["id"], port_info["port"]["id"], + err_msg=msg) @validation.add("number", param_name="ports_per_network", minval=1, diff --git a/rally/plugins/openstack/scenarios/swift/objects.py b/rally/plugins/openstack/scenarios/swift/objects.py index fc6731bf..908f7585 100644 --- a/rally/plugins/openstack/scenarios/swift/objects.py +++ b/rally/plugins/openstack/scenarios/swift/objects.py @@ -18,7 +18,6 @@ import tempfile from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.swift import utils -from rally.task import atomic from rally.task import validation @@ -127,13 +126,8 @@ class ListObjectsInContainers(utils.SwiftScenario): containers = self._list_containers()[1] - key_suffix = "container" - if len(containers) > 1: - key_suffix = "%i_containers" % len(containers) - - with atomic.ActionTimer(self, "swift.list_objects_in_%s" % key_suffix): - for container in containers: - self._list_objects(container["name"]) + for container in containers: + self._list_objects(container["name"]) @validation.add("required_services", services=[consts.Service.SWIFT]) @@ -149,25 +143,12 @@ class ListAndDownloadObjectsInContainers(utils.SwiftScenario): containers = self._list_containers()[1] - list_key_suffix = "container" - if len(containers) > 1: - list_key_suffix = "%i_containers" % len(containers) - objects_dict = {} - with atomic.ActionTimer(self, - "swift.list_objects_in_%s" % list_key_suffix): - for container in containers: - container_name = container["name"] - objects_dict[container_name] = self._list_objects( - container_name)[1] + for container in containers: + container_name = container["name"] + objects_dict[container_name] = self._list_objects( + container_name)[1] - objects_total = sum(map(len, objects_dict.values())) - download_key_suffix = "object" - if objects_total > 1: - download_key_suffix = "%i_objects" % objects_total - - with atomic.ActionTimer(self, - "swift.download_%s" % download_key_suffix): - for container_name, objects in objects_dict.items(): - for obj in objects: - self._download_object(container_name, obj["name"]) + for container_name, objects in objects_dict.items(): + for obj in objects: + self._download_object(container_name, obj["name"]) diff --git a/tests/unit/plugins/openstack/scenarios/authenticate/test_authenticate.py b/tests/unit/plugins/openstack/scenarios/authenticate/test_authenticate.py index 22d49461..ec064607 100644 --- a/tests/unit/plugins/openstack/scenarios/authenticate/test_authenticate.py +++ b/tests/unit/plugins/openstack/scenarios/authenticate/test_authenticate.py @@ -43,14 +43,14 @@ class AuthenticateTestCase(test.ScenarioTestCase): self.clients("glance").images.list.call_args_list, [mock.call(name=mock.ANY)] * 5) self._test_atomic_action_timer(scenario_inst.atomic_actions(), - "authenticate.validate_glance_5_times") + "authenticate.validate_glance") def test_validate_nova(self): scenario_inst = authenticate.ValidateNova() scenario_inst.run(5) self.clients("nova").flavors.list.assert_has_calls([mock.call()] * 5) self._test_atomic_action_timer(scenario_inst.atomic_actions(), - "authenticate.validate_nova_5_times") + "authenticate.validate_nova") def test_validate_ceilometer(self): scenario_inst = authenticate.ValidateCeilometer() @@ -59,7 +59,7 @@ class AuthenticateTestCase(test.ScenarioTestCase): [mock.call()] * 5) self._test_atomic_action_timer( scenario_inst.atomic_actions(), - "authenticate.validate_ceilometer_5_times") + "authenticate.validate_ceilometer") def test_validate_cinder(self): scenario_inst = authenticate.ValidateCinder() @@ -67,7 +67,7 @@ class AuthenticateTestCase(test.ScenarioTestCase): self.clients("cinder").volume_types.list.assert_has_calls( [mock.call()] * 5) self._test_atomic_action_timer(scenario_inst.atomic_actions(), - "authenticate.validate_cinder_5_times") + "authenticate.validate_cinder") def test_validate_neutron(self): scenario_inst = authenticate.ValidateNeutron() @@ -75,7 +75,7 @@ class AuthenticateTestCase(test.ScenarioTestCase): self.clients("neutron").list_networks.assert_has_calls( [mock.call()] * 5) self._test_atomic_action_timer(scenario_inst.atomic_actions(), - "authenticate.validate_neutron_5_times") + "authenticate.validate_neutron") def test_validate_heat(self): scenario_inst = authenticate.ValidateHeat() @@ -84,7 +84,7 @@ class AuthenticateTestCase(test.ScenarioTestCase): self.clients("heat").stacks.list.call_args_list, [mock.call(limit=0)] * 5) self._test_atomic_action_timer(scenario_inst.atomic_actions(), - "authenticate.validate_heat_5_times") + "authenticate.validate_heat") def test_validate_monasca(self): scenario_inst = authenticate.ValidateMonasca() @@ -93,4 +93,4 @@ class AuthenticateTestCase(test.ScenarioTestCase): self.clients("monasca").metrics.list.call_args_list, [mock.call(limit=0)] * 5) self._test_atomic_action_timer(scenario_inst.atomic_actions(), - "authenticate.validate_monasca_5_times") + "authenticate.validate_monasca") diff --git a/tests/unit/plugins/openstack/scenarios/heat/test_stacks.py b/tests/unit/plugins/openstack/scenarios/heat/test_stacks.py index a79d4ca8..b877599b 100644 --- a/tests/unit/plugins/openstack/scenarios/heat/test_stacks.py +++ b/tests/unit/plugins/openstack/scenarios/heat/test_stacks.py @@ -90,7 +90,7 @@ class HeatStacksTestCase(test.ScenarioTestCase): self.clients("heat").resources.list.assert_called_once_with( stack.id) self._test_atomic_action_timer(heat_scenario.atomic_actions(), - "heat.list_resources_of_1_stacks") + "heat.list_resources") @mock.patch("%s.ListStacksAndEvents._list_stacks" % BASE) def test_list_stack_and_events(self, mock__list_stacks): @@ -100,7 +100,7 @@ class HeatStacksTestCase(test.ScenarioTestCase): heat_scenario.run() self.clients("heat").events.list.assert_called_once_with(stack.id) self._test_atomic_action_timer( - heat_scenario.atomic_actions(), "heat.list_events_of_1_stacks") + heat_scenario.atomic_actions(), "heat.list_events") @mock.patch("%s.CreateAndDeleteStack._delete_stack" % BASE) @mock.patch("%s.CreateAndDeleteStack._create_stack" % BASE) diff --git a/tests/unit/plugins/openstack/scenarios/swift/test_objects.py b/tests/unit/plugins/openstack/scenarios/swift/test_objects.py index 078cb7d4..9072e76c 100644 --- a/tests/unit/plugins/openstack/scenarios/swift/test_objects.py +++ b/tests/unit/plugins/openstack/scenarios/swift/test_objects.py @@ -82,12 +82,6 @@ class SwiftObjectsTestCase(test.ScenarioTestCase): for container in con_list] scenario._list_objects.assert_has_calls(con_calls) - key_suffix = "container" - if num_cons > 1: - key_suffix = "%i_containers" % num_cons - self._test_atomic_action_timer(scenario.atomic_actions(), - "swift.list_objects_in_%s" % key_suffix) - @ddt.data([1, 1], [1, 2], [2, 1], [3, 5]) @ddt.unpack def test_list_and_download_objects_in_containers(self, num_cons, num_objs): @@ -111,19 +105,6 @@ class SwiftObjectsTestCase(test.ScenarioTestCase): obj_calls.append(mock.call(container["name"], obj["name"])) scenario._download_object.assert_has_calls(obj_calls, any_order=True) - list_key_suffix = "container" - if num_cons > 1: - list_key_suffix = "%i_containers" % num_cons - self._test_atomic_action_timer( - scenario.atomic_actions(), - "swift.list_objects_in_%s" % list_key_suffix) - download_key_suffix = "object" - if num_cons * num_objs > 1: - download_key_suffix = "%i_objects" % (num_cons * num_objs) - self._test_atomic_action_timer( - scenario.atomic_actions(), - "swift.download_%s" % download_key_suffix) - def test_functional_create_container_and_object_then_list_objects(self): names_list = ["AA", "BB", "CC", "DD"] diff --git a/tests/unit/test.py b/tests/unit/test.py index 98b7e9d6..ceba1c16 100644 --- a/tests/unit/test.py +++ b/tests/unit/test.py @@ -49,7 +49,10 @@ class TestCase(base.BaseTestCase): def _test_atomic_action_timer(self, atomic_actions, name): atomic_wrapper = tutils.WrapperForAtomicActions(atomic_actions) action_duration = atomic_wrapper.get(name) - self.assertIsNotNone(action_duration) + if action_duration is None: + self.fail("The duration of atomic action '%s' should not be None. " + "None duration means that it had not called before the " + "check is executed." % name) self.assertIsInstance(action_duration, float) def assertSequenceEqual(self, iterable_1, iterable_2, msg=None):