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
This commit is contained in:
kairat_kushaev 2015-02-06 18:57:42 +03:00
parent 7cfd85a145
commit 24eff5a887
7 changed files with 81 additions and 7 deletions

View File

@ -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:

View File

@ -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)
self._delete_stack(stack)

View File

@ -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)
check_interval=CONF.benchmark.heat_stack_delete_poll_interval)

View File

@ -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
}
}
}
]
}

View File

@ -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

View File

@ -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)
mock_delete.assert_called_once_with(fake_stack)

View File

@ -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")
raise self.fail("Unrecognized error status")