Add create-check-delete stack scenario

The patch includes scenario that measures performance
for the following scenario steps:
- Create a new stack from template in Heat
- Check the created stack and its resources in Heat.
- Delete the stack.
The patch includes samples and unittests.

Change-Id: I512f5d5c01d8f5973b68672476e970c54000470b
This commit is contained in:
kairat_kushaev 2015-02-12 19:11:19 +03:00
parent 354ab30c1c
commit 3874076733
8 changed files with 130 additions and 2 deletions

View File

@ -193,6 +193,13 @@
# (floating point value)
#heat_stack_resume_poll_interval = 1.0
# Time(in sec) to wait for stack to be checked. (floating point value)
#heat_stack_check_timeout = 3600.0
# Time interval(in sec) between checks when waiting for stack checking.
# (floating point value)
#heat_stack_check_poll_interval = 1.0
# Time to sleep after start before polling for status (floating point
# value)
#nova_server_start_prepoll_delay = 0.0

View File

@ -509,6 +509,22 @@
failure_rate:
max: 0
HeatStacks.create_check_delete_stack:
-
args:
template_path: "/home/jenkins/.rally/extra/random_strings.yaml.template"
runner:
type: "constant"
times: 6
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
HeatStacks.create_update_delete_stack:
-
args:

View File

@ -83,6 +83,27 @@ class HeatStacks(utils.HeatScenario):
stack = self._create_stack(template)
self._delete_stack(stack)
@validation.required_services(consts.Service.HEAT)
@validation.required_openstack(users=True)
@base.scenario(context={"cleanup": ["heat"]})
def create_check_delete_stack(self, template_path=None):
"""Create, check and delete a stack.
Measure the performance of the following commands:
- heat stack-create
- heat action-check
- heat stack-delete
:param template_path: path to template file that will be used for
stack create. If None or incorrect, then
default empty template will be used.
"""
template = self._get_template_from_file(template_path)
stack = self._create_stack(template)
self._check_stack(stack)
self._delete_stack(stack)
@validation.required_services(consts.Service.HEAT)
@validation.required_openstack(users=True)
@base.scenario(context={"cleanup": ["heat"]})
@ -127,4 +148,4 @@ class HeatStacks(utils.HeatScenario):
s = self._create_stack(template)
self._suspend_stack(s)
self._resume_stack(s)
self._delete_stack(s)
self._delete_stack(s)

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
#
@ -40,6 +40,13 @@ HEAT_BENCHMARK_OPTS = [
default=1.0,
help="Time interval(in sec) between checks when waiting for "
"stack deletion."),
cfg.FloatOpt("heat_stack_check_timeout",
default=3600.0,
help="Time(in sec) to wait for stack to be checked."),
cfg.FloatOpt("heat_stack_check_poll_interval",
default=1.0,
help="Time interval(in sec) between checks when waiting for "
"stack checking."),
cfg.FloatOpt("heat_stack_update_prepoll_delay",
default=2.0,
help="Time(in sec) to sleep after updating a resource before "
@ -148,6 +155,22 @@ class HeatScenario(base.Scenario):
check_interval=CONF.benchmark.heat_stack_update_poll_interval)
return stack
@base.atomic_action_timer("heat.check_stack")
def _check_stack(self, stack):
"""Check given stack.
Check the stack and stack resources.
:param stack: stack that needs to be checked
"""
self.clients("heat").actions.check(stack.id)
bench_utils.wait_for(
stack,
is_ready=bench_utils.resource_is("CHECK_COMPLETE"),
update_resource=bench_utils.get_from_manager(["CHECK_FAILED"]),
timeout=CONF.benchmark.heat_stack_check_timeout,
check_interval=CONF.benchmark.heat_stack_check_poll_interval)
@base.atomic_action_timer("heat.delete_stack")
def _delete_stack(self, stack):
"""Delete given stack.

View File

@ -0,0 +1,20 @@
{
"HeatStacks.create_check_delete_stack": [
{
"args": {
"template_path": "templates/random_strings.yaml.template"
},
"runner": {
"type": "constant",
"times": 10,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 3
}
}
}
]
}

View File

@ -0,0 +1,13 @@
---
HeatStacks.create_check_delete_stack:
-
args:
template_path: "templates/random_strings.yaml.template"
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 3

View File

@ -73,6 +73,18 @@ class HeatStacksTestCase(test.TestCase):
self.assertTrue(mock_create.called)
mock_delete.assert_called_once_with(fake_stack)
@mock.patch(HEAT_STACKS + "._delete_stack")
@mock.patch(HEAT_STACKS + "._check_stack")
@mock.patch(HEAT_STACKS + "._create_stack")
def test_create_check_delete_stack(self, mock_create, mock_check,
mock_delete):
heat_scenario = stacks.HeatStacks()
mock_create.return_value = "fake_stack_create_check_delete"
heat_scenario.create_check_delete_stack()
mock_create.assert_called_once_with(None)
mock_check.assert_called_once_with("fake_stack_create_check_delete")
mock_delete.assert_called_once_with("fake_stack_create_check_delete")
@mock.patch(HEAT_STACKS + "._generate_random_name")
@mock.patch(HEAT_STACKS + "._delete_stack")
@mock.patch(HEAT_STACKS + "._update_stack")

View File

@ -88,6 +88,22 @@ class HeatScenarioTestCase(test.TestCase):
self._test_atomic_action_timer(scenario.atomic_actions(),
"heat.update_stack")
@mock.patch(HEAT_UTILS + ".HeatScenario.clients")
def test_check_stack(self, mock_clients):
scenario = utils.HeatScenario()
scenario._check_stack(self.stack)
mock_clients("heat").actions.check.assert_called_once_with(
self.stack.id)
self.wait_for.mock.assert_called_once_with(
self.stack,
update_resource=self.gfm(),
is_ready=self.res_is.mock(),
check_interval=utils.CONF.benchmark.heat_stack_check_poll_interval,
timeout=utils.CONF.benchmark.heat_stack_check_timeout)
self.res_is.mock.assert_has_calls([mock.call("CHECK_COMPLETE")])
self._test_atomic_action_timer(scenario.atomic_actions(),
"heat.check_stack")
def test_delete_stack(self):
scenario = utils.HeatScenario()
scenario._delete_stack(self.stack)