From 24eff5a8870ac7f7ca565558b93c08a9ff44924c Mon Sep 17 00:00:00 2001 From: kairat_kushaev Date: Fri, 6 Feb 2015 18:57:42 +0300 Subject: [PATCH] Add list-stack-with-resources scenario Added scenario that allows to test list_resources(stack) command in Heat. In addition, added samples and unittest for the scenario. Change-Id: I05c8dd12807756d35191a79820f3ff9ec0ab35ac --- rally-jobs/rally.yaml | 17 +++++++++++++++ rally/benchmark/scenarios/heat/stacks.py | 14 ++++++++++++- rally/benchmark/scenarios/heat/utils.py | 7 +++---- .../heat/list-stack-and-resources.json | 21 +++++++++++++++++++ .../heat/list-stack-and-resources.yaml | 14 +++++++++++++ .../benchmark/scenarios/heat/test_stacks.py | 13 +++++++++++- .../benchmark/scenarios/heat/test_utils.py | 2 +- 7 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 samples/tasks/scenarios/heat/list-stack-and-resources.json create mode 100644 samples/tasks/scenarios/heat/list-stack-and-resources.yaml diff --git a/rally-jobs/rally.yaml b/rally-jobs/rally.yaml index 135cb2deb3..906b722a05 100755 --- a/rally-jobs/rally.yaml +++ b/rally-jobs/rally.yaml @@ -585,6 +585,23 @@ failure_rate: max: 0 + HeatStacks.list_stacks_and_resources: + - + runner: + type: "constant" + times: 6 + concurrency: 3 + context: + users: + tenants: 2 + users_per_tenant: 3 + stacks: + stacks_per_tenant: 2 + resources_per_stack: 10 + sla: + failure_rate: + max: 0 + Authenticate.keystone: - runner: diff --git a/rally/benchmark/scenarios/heat/stacks.py b/rally/benchmark/scenarios/heat/stacks.py index 2e8ef1311d..fe3bf2ac49 100644 --- a/rally/benchmark/scenarios/heat/stacks.py +++ b/rally/benchmark/scenarios/heat/stacks.py @@ -54,6 +54,18 @@ class HeatStacks(utils.HeatScenario): self._create_stack(template) self._list_stacks() + @validation.required_services(consts.Service.HEAT) + @validation.required_openstack(users=True) + @base.scenario() + def list_stacks_and_resources(self): + """List resources from tenant stacks.""" + + stacks = self._list_stacks() + with base.AtomicAction( + self, "heat.list_resources_of_%s_stacks" % len(stacks)): + for stack in stacks: + self.clients("heat").resources.list(stack.id) + @validation.required_services(consts.Service.HEAT) @validation.required_openstack(users=True) @base.scenario(context={"cleanup": ["heat"]}) @@ -93,4 +105,4 @@ class HeatStacks(utils.HeatScenario): stack = self._create_stack(template) updated_template = self._get_template_from_file(updated_template_path) self._update_stack(stack, updated_template) - self._delete_stack(stack) \ No newline at end of file + self._delete_stack(stack) diff --git a/rally/benchmark/scenarios/heat/utils.py b/rally/benchmark/scenarios/heat/utils.py index 29b731cb6f..9228a2e5d7 100644 --- a/rally/benchmark/scenarios/heat/utils.py +++ b/rally/benchmark/scenarios/heat/utils.py @@ -1,7 +1,7 @@ # Copyright 2014: Mirantis Inc. # All Rights Reserved. # -# Licensed under the Apache License, Version 2.0 (the "License"); you may +# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # @@ -53,7 +53,6 @@ heat_benchmark_opts = [ "update."), ] - CONF = cfg.CONF benchmark_group = cfg.OptGroup(name="benchmark", title="benchmark options") CONF.register_opts(heat_benchmark_opts, group=benchmark_group) @@ -111,7 +110,7 @@ class HeatScenario(base.Scenario): :param stack: stack that need to be updated :param template: Updated template - :return: object of updated stack + :returns: object of updated stack """ template = template or self.default_template @@ -148,4 +147,4 @@ class HeatScenario(base.Scenario): stack, update_resource=bench_utils.get_from_manager(), timeout=CONF.benchmark.heat_stack_delete_timeout, - check_interval=CONF.benchmark.heat_stack_delete_poll_interval) \ No newline at end of file + check_interval=CONF.benchmark.heat_stack_delete_poll_interval) diff --git a/samples/tasks/scenarios/heat/list-stack-and-resources.json b/samples/tasks/scenarios/heat/list-stack-and-resources.json new file mode 100644 index 0000000000..a1d1485ad6 --- /dev/null +++ b/samples/tasks/scenarios/heat/list-stack-and-resources.json @@ -0,0 +1,21 @@ +{ + "HeatStacks.list_stacks_and_resources": [ + { + "runner": { + "type": "constant", + "times": 10, + "concurrency": 1 + }, + "context": { + "users": { + "tenants": 1, + "users_per_tenant": 1 + }, + "stacks": { + "stacks_per_tenant": 2, + "resources_per_stack": 10 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/heat/list-stack-and-resources.yaml b/samples/tasks/scenarios/heat/list-stack-and-resources.yaml new file mode 100644 index 0000000000..1ff45c7dce --- /dev/null +++ b/samples/tasks/scenarios/heat/list-stack-and-resources.yaml @@ -0,0 +1,14 @@ +--- + HeatStacks.list_stacks_and_resources: + - + runner: + type: "constant" + times: 10 + concurrency: 1 + context: + users: + tenants: 1 + users_per_tenant: 1 + stacks: + stacks_per_tenant: 2 + resources_per_stack: 10 \ No newline at end of file diff --git a/tests/unit/benchmark/scenarios/heat/test_stacks.py b/tests/unit/benchmark/scenarios/heat/test_stacks.py index 25e6fabb98..16083797eb 100644 --- a/tests/unit/benchmark/scenarios/heat/test_stacks.py +++ b/tests/unit/benchmark/scenarios/heat/test_stacks.py @@ -37,6 +37,17 @@ class HeatStacksTestCase(test.TestCase): self.assertEqual(1, mock_create.called) mock_list.assert_called_once_with() + @mock.patch(HEAT_STACKS + ".clients") + @mock.patch(HEAT_STACKS + "._list_stacks") + def test_list_stack_and_resources(self, mock_list_stack, mock_clients): + stack = mock.Mock() + mock_list_stack.return_value = [stack] + heat_scenario = stacks.HeatStacks() + heat_scenario.list_stacks_and_resources() + mock_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") + @mock.patch(HEAT_STACKS + "._generate_random_name") @mock.patch(HEAT_STACKS + "._list_stacks") @mock.patch(HEAT_STACKS + "._create_stack") @@ -76,4 +87,4 @@ class HeatStacksTestCase(test.TestCase): self.assertTrue(mock_create.called) mock_update.assert_called_once_with(fake_stack, None) - mock_delete.assert_called_once_with(fake_stack) \ No newline at end of file + mock_delete.assert_called_once_with(fake_stack) diff --git a/tests/unit/benchmark/scenarios/heat/test_utils.py b/tests/unit/benchmark/scenarios/heat/test_utils.py index 2e7256642a..e9702159ae 100644 --- a/tests/unit/benchmark/scenarios/heat/test_utils.py +++ b/tests/unit/benchmark/scenarios/heat/test_utils.py @@ -143,4 +143,4 @@ class HeatScenarioNegativeTestCase(test.TestCase): scenario._update_stack, stack) self.assertIn("has UPDATE_FAILED status", str(ex)) except exceptions.TimeoutException: - raise self.fail("Unrecognized error status") \ No newline at end of file + raise self.fail("Unrecognized error status")