[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:
parent
4b55719e8e
commit
7d7e372ccf
@ -207,6 +207,19 @@
|
|||||||
# (floating point value)
|
# (floating point value)
|
||||||
#heat_stack_resume_poll_interval = 1.0
|
#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.
|
# Delay between creating Manila share and polling for its status.
|
||||||
# (floating point value)
|
# (floating point value)
|
||||||
#manila_share_create_prepoll_delay = 2.0
|
#manila_share_create_prepoll_delay = 2.0
|
||||||
|
@ -226,3 +226,19 @@
|
|||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
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
|
||||||
|
@ -745,7 +745,6 @@
|
|||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
|
||||||
|
|
||||||
Authenticate.keystone:
|
Authenticate.keystone:
|
||||||
-
|
-
|
||||||
runner:
|
runner:
|
||||||
|
@ -177,3 +177,30 @@ class HeatStacks(utils.HeatScenario):
|
|||||||
self, "heat.list_events_of_%s_stacks" % len(stacks)):
|
self, "heat.list_events_of_%s_stacks" % len(stacks)):
|
||||||
for stack in stacks:
|
for stack in stacks:
|
||||||
self.clients("heat").events.list(stack.id)
|
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)
|
||||||
|
@ -72,6 +72,22 @@ HEAT_BENCHMARK_OPTS = [
|
|||||||
default=1.0,
|
default=1.0,
|
||||||
help="Time interval(in sec) between checks when waiting for "
|
help="Time interval(in sec) between checks when waiting for "
|
||||||
"stack resume."),
|
"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
|
CONF = cfg.CONF
|
||||||
@ -221,3 +237,38 @@ class HeatScenario(base.Scenario):
|
|||||||
["RESUME_FAILED"]),
|
["RESUME_FAILED"]),
|
||||||
timeout=CONF.benchmark.heat_stack_resume_timeout,
|
timeout=CONF.benchmark.heat_stack_resume_timeout,
|
||||||
check_interval=CONF.benchmark.heat_stack_resume_poll_interval)
|
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
|
||||||
|
)
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -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
|
@ -171,3 +171,29 @@ class HeatStacksTestCase(test.ClientsTestCase):
|
|||||||
mock__delete_stack.assert_called_once_with(
|
mock__delete_stack.assert_called_once_with(
|
||||||
mock__create_stack.return_value
|
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)
|
||||||
|
@ -161,6 +161,36 @@ class HeatScenarioTestCase(test.ClientsTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"heat.resume_stack")
|
"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):
|
class HeatScenarioNegativeTestCase(test.ClientsTestCase):
|
||||||
def test_failed_create_stack(self):
|
def test_failed_create_stack(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user