Skip to content

Commit

Permalink
Add create-check-delete stack scenario
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mira-nomad committed Mar 6, 2015
1 parent 354ab30 commit 3874076
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 2 deletions.
7 changes: 7 additions & 0 deletions etc/rally/rally.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions rally-jobs/rally.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 22 additions & 1 deletion rally/benchmark/scenarios/heat/stacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,27 @@ def create_and_delete_stack(self, template_path=None):
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"]})
Expand Down Expand Up @@ -127,4 +148,4 @@ def create_suspend_resume_delete_stack(self, template_path=None):
s = self._create_stack(template)
self._suspend_stack(s)
self._resume_stack(s)
self._delete_stack(s)
self._delete_stack(s)
25 changes: 24 additions & 1 deletion rally/benchmark/scenarios/heat/utils.py
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down Expand Up @@ -40,6 +40,13 @@
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 "
Expand Down Expand Up @@ -148,6 +155,22 @@ def _update_stack(self, stack, template=None):
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.
Expand Down
20 changes: 20 additions & 0 deletions samples/tasks/scenarios/heat/create-check-delete-stack.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
]
}
13 changes: 13 additions & 0 deletions samples/tasks/scenarios/heat/create-check-delete-stack.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tests/unit/benchmark/scenarios/heat/test_stacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ def test_create_and_delete_stack(self, mock_create, mock_delete,
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")
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/benchmark/scenarios/heat/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ def test_update_stack(self, mock_bench, mock_clients):
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)
Expand Down

0 comments on commit 3874076

Please sign in to comment.