From 0f48b1d66c2427be2116d8bc60abc62795b05250 Mon Sep 17 00:00:00 2001 From: Anant Patil Date: Thu, 25 Aug 2016 11:31:18 +0530 Subject: [PATCH] Convergence: Run scenario tests synchronously The convergence scenario tests run the stack CRUD operations using engine service and the service runs the functions in another thread. This causes issues as the convergence scenario tests expect functions to be run synchronously. Change-Id: I065ea6dad5ac0ee9d3d233d3d807acecbed7b98f --- .../convergence/framework/engine_wrapper.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/heat/tests/convergence/framework/engine_wrapper.py b/heat/tests/convergence/framework/engine_wrapper.py index 72edc7f1b9..07f8ed35df 100644 --- a/heat/tests/convergence/framework/engine_wrapper.py +++ b/heat/tests/convergence/framework/engine_wrapper.py @@ -22,6 +22,17 @@ from heat.tests.convergence.framework import scenario_template from heat.tests import utils +class SynchronousThreadGroupManager(service.ThreadGroupManager): + """Wrapper for thread group manager. + + The start method of thread group manager needs to be overriden to + run the function synchronously so that the convergence scenario + tests can run. + """ + def start(self, stack_id, func, *args, **kwargs): + func(*args, **kwargs) + + class Engine(message_processor.MessageProcessor): """Wrapper to the engine service. @@ -63,8 +74,7 @@ class Engine(message_processor.MessageProcessor): def create_stack(self, stack_name, scenario_tmpl): cnxt = utils.dummy_context() srv = service.EngineService("host", "engine") - thread_group_mgr = service.ThreadGroupManager() - srv.thread_group_mgr = thread_group_mgr + srv.thread_group_mgr = SynchronousThreadGroupManager() hot_tmpl = self.scenario_template_to_hot(scenario_tmpl) srv.create_stack(cnxt, stack_name, hot_tmpl, params={}, files={}, environment_files=None, args={}) @@ -74,8 +84,7 @@ class Engine(message_processor.MessageProcessor): cnxt = utils.dummy_context() db_stack = db_api.stack_get_by_name(cnxt, stack_name) srv = service.EngineService("host", "engine") - thread_group_mgr = service.ThreadGroupManager() - srv.thread_group_mgr = thread_group_mgr + srv.thread_group_mgr = SynchronousThreadGroupManager() hot_tmpl = self.scenario_template_to_hot(scenario_tmpl) stack_identity = {'stack_name': stack_name, 'stack_id': db_stack.id, @@ -93,6 +102,7 @@ class Engine(message_processor.MessageProcessor): 'tenant': db_stack.tenant, 'path': ''} srv = service.EngineService("host", "engine") + srv.thread_group_mgr = SynchronousThreadGroupManager() srv.delete_stack(cnxt, stack_identity) @message_processor.asynchronous