[Heat] create-snapshot-restore-delete stack scenario

The patch adds rally scenario that tests the following
sequence of actions for Heat:
1) create stack
2) create stack snapshot
3) restore stack from snapshot
4) delete stack

Change-Id: I5fb46be697c9ae1450b323a4e632ab13d7600998
This commit is contained in:
kairat_kushaev 2015-04-30 15:12:42 +03:00
parent 4b55719e8e
commit 7d7e372ccf
9 changed files with 196 additions and 1 deletions

View File

@ -207,6 +207,19 @@
# (floating point value)
#heat_stack_resume_poll_interval = 1.0
# Time(in sec) to wait for stack snapshot to be created.
#heat_stack_snapshot_timeout = 3600.0
# Time interval(in sec) between checks when waiting for stack snapshot
# to be created.
#heat_stack_snapshot_poll_interval = 1.0
# Time(in sec) to wait for stack to be restored from snapshot.
#heat_stack_restore_timeout = 3600.0
# Time interval(in sec) between checks when waiting for stack to be restored.
#heat_stack_restore_poll_interval = 1.0
# Delay between creating Manila share and polling for its status.
# (floating point value)
#manila_share_create_prepoll_delay = 2.0

View File

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

View File

@ -745,7 +745,6 @@
failure_rate:
max: 0
Authenticate.keystone:
-
runner:

View File

@ -177,3 +177,30 @@ class HeatStacks(utils.HeatScenario):
self, "heat.list_events_of_%s_stacks" % len(stacks)):
for stack in stacks:
self.clients("heat").events.list(stack.id)
@types.set(template_path=types.FileType, files=types.FileTypeDict)
@validation.required_services(consts.Service.HEAT)
@validation.required_openstack(users=True)
@base.scenario(context={"cleanup": ["heat"]})
def create_snapshot_restore_delete_stack(self, template_path,
parameters=None, files=None,
environment=None):
"""Create, snapshot-restore and then delete a stack.
Measure performance of the following commands:
heat stack-create
heat stack-snapshot
heat stack-restore
heat stack-delete
:param template_path: path to stack template file
:param parameters: parameters to use in heat template
:param files: files used in template
:param environment: stack environment definition
"""
stack = self._create_stack(
template_path, parameters, files, environment)
snapshot = self._snapshot_stack(stack)
self._restore_stack(stack, snapshot["id"])
self._delete_stack(stack)

View File

@ -72,6 +72,22 @@ HEAT_BENCHMARK_OPTS = [
default=1.0,
help="Time interval(in sec) between checks when waiting for "
"stack resume."),
cfg.FloatOpt("heat_stack_snapshot_timeout",
default=3600.0,
help="Time(in sec) to wait for stack snapshot to "
"be created."),
cfg.FloatOpt("heat_stack_snapshot_poll_interval",
default=1.0,
help="Time interval(in sec) between checks when waiting for "
"stack snapshot to be created."),
cfg.FloatOpt("heat_stack_restore_timeout",
default=3600.0,
help="Time(in sec) to wait for stack to be restored from "
"snapshot."),
cfg.FloatOpt("heat_stack_restore_poll_interval",
default=1.0,
help="Time interval(in sec) between checks when waiting for "
"stack to be restored.")
]
CONF = cfg.CONF
@ -221,3 +237,38 @@ class HeatScenario(base.Scenario):
["RESUME_FAILED"]),
timeout=CONF.benchmark.heat_stack_resume_timeout,
check_interval=CONF.benchmark.heat_stack_resume_poll_interval)
@base.atomic_action_timer("heat.snapshot_stack")
def _snapshot_stack(self, stack):
"""Creates a snapshot for given stack.
:param stack: stack that will be used as base for snapshot
:returns snapshot created for given stack
"""
snapshot = self.clients("heat").stacks.snapshot(
stack.id)
bench_utils.wait_for(
stack,
is_ready=bench_utils.resource_is("SNAPSHOT_COMPLETE"),
update_resource=bench_utils.get_from_manager(
["SNAPSHOT_FAILED"]),
timeout=CONF.benchmark.heat_stack_snapshot_timeout,
check_interval=CONF.benchmark.heat_stack_snapshot_poll_interval)
return snapshot
@base.atomic_action_timer("heat.restore_stack")
def _restore_stack(self, stack, snapshot_id):
"""Restores stack from given snapshot.
:param stack: stack that will be restored from snapshot
:param snapshot_id: id of given snapshot
"""
self.clients("heat").stacks.restore(stack.id, snapshot_id)
bench_utils.wait_for(
stack,
is_ready=bench_utils.resource_is("RESTORE_COMPLETE"),
update_resource=bench_utils.get_from_manager(
["RESTORE_FAILED"]),
timeout=CONF.benchmark.heat_stack_restore_timeout,
check_interval=CONF.benchmark.heat_stack_restore_poll_interval
)

View File

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

View File

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

View File

@ -171,3 +171,29 @@ class HeatStacksTestCase(test.ClientsTestCase):
mock__delete_stack.assert_called_once_with(
mock__create_stack.return_value
)
@mock.patch(HEAT_STACKS + "._delete_stack")
@mock.patch(HEAT_STACKS + "._restore_stack")
@mock.patch(HEAT_STACKS + "._snapshot_stack")
@mock.patch(HEAT_STACKS + "._create_stack")
def test_create_snapshot_restore_delete_stack(
self, mock__create_stack, mock__snapshot_stack,
mock__restore_stack, mock__delete_stack):
heat_scenario = stacks.HeatStacks()
mock__snapshot_stack.return_value = {"id": "dummy_id"}
heat_scenario.create_snapshot_restore_delete_stack(
template_path=self.default_template,
parameters=self.default_parameters,
files=self.default_files,
environment=self.default_environment
)
mock__create_stack.assert_called_once_with(
self.default_template, self.default_parameters,
self.default_files, self.default_environment)
mock__snapshot_stack.assert_called_once_with(
mock__create_stack.return_value)
mock__restore_stack.assert_called_once_with(
mock__create_stack.return_value, "dummy_id")
mock__delete_stack.assert_called_once_with(
mock__create_stack.return_value)

View File

@ -161,6 +161,36 @@ class HeatScenarioTestCase(test.ClientsTestCase):
self._test_atomic_action_timer(scenario.atomic_actions(),
"heat.resume_stack")
def test_snapshot_stack(self):
scenario = utils.HeatScenario()
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.stack,
update_resource=self.gfm(),
is_ready=self.res_is.mock(),
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._test_atomic_action_timer(scenario.atomic_actions(),
"heat.snapshot_stack")
def test_restore_stack(self):
scenario = utils.HeatScenario()
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.stack,
update_resource=self.gfm(),
is_ready=self.res_is.mock(),
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._test_atomic_action_timer(scenario.atomic_actions(),
"heat.restore_stack")
class HeatScenarioNegativeTestCase(test.ClientsTestCase):
def test_failed_create_stack(self):