summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZane Bitter <zbitter@redhat.com>2019-10-29 15:10:55 -0400
committerZane Bitter <zbitter@redhat.com>2019-10-29 23:18:13 -0400
commit38614a78c1a06dca704a8e9badc2cc6ad55f613b (patch)
tree10b3f227edaf9cffdc0e677f0ec30de5b32e6e84
parent8cd6a06736c27d2dd50340c03987631143f3484d (diff)
downloadheat-38614a78c1a06dca704a8e9badc2cc6ad55f613b.tar.gz
Add unit test for nested stack cancel
Test that when cancelling a nested stack, its children also get cancelled. Change-Id: Icfd4ef1654dd141d17541bed48fee412001efdec
-rw-r--r--heat/engine/worker.py3
-rw-r--r--heat/tests/engine/test_engine_worker.py23
2 files changed, 26 insertions, 0 deletions
diff --git a/heat/engine/worker.py b/heat/engine/worker.py
index 274dd436f..ea8553d75 100644
--- a/heat/engine/worker.py
+++ b/heat/engine/worker.py
@@ -110,6 +110,9 @@ class WorkerService(object):
Marks the stack as FAILED due to cancellation, but, allows all
in_progress resources to complete normally; no worker is stopped
abruptly.
+
+ Any in-progress traversals are also stopped on all nested stacks that
+ are descendants of the one passed.
"""
_stop_traversal(stack)
diff --git a/heat/tests/engine/test_engine_worker.py b/heat/tests/engine/test_engine_worker.py
index affb51186..bdde6c8be 100644
--- a/heat/tests/engine/test_engine_worker.py
+++ b/heat/tests/engine/test_engine_worker.py
@@ -197,6 +197,29 @@ class WorkerServiceTest(common.HeatTestCase):
self.assertEqual('stack1', call_args1.name)
self.assertEqual('stack2', call_args2.name)
+ @mock.patch.object(worker, '_stop_traversal')
+ def test_stop_nested_traversal_stops_deeply_nested_stack(self, mock_st):
+ mock_tgm = mock.Mock()
+ ctx = utils.dummy_context()
+ tmpl = templatem.Template.create_empty_template()
+ stack1 = parser.Stack(ctx, 'stack1', tmpl,
+ current_traversal='123')
+ stack1.store()
+ stack2 = parser.Stack(ctx, 'stack2', tmpl,
+ owner_id=stack1.id, current_traversal='456')
+ stack2.store()
+ stack3 = parser.Stack(ctx, 'stack3', tmpl,
+ owner_id=stack2.id, current_traversal='789')
+ stack3.store()
+ _worker = worker.WorkerService('host-1', 'topic-1', 'engine-001',
+ mock_tgm)
+ _worker.stop_traversal(stack2)
+ self.assertEqual(2, mock_st.call_count)
+ call1, call2 = mock_st.call_args_list
+ call_args1, call_args2 = call1[0][0], call2[0][0]
+ self.assertEqual('stack2', call_args1.name)
+ self.assertEqual('stack3', call_args2.name)
+
@mock.patch.object(worker, '_cancel_workers')
@mock.patch.object(worker.WorkerService, 'stop_traversal')
def test_stop_all_workers_when_stack_in_progress(self, mock_st, mock_cw):