@@ -138,7 +138,11 @@ def test_run_workflow(self):
138138 'workflow_execution_id' : str (wf_ex_db .id ),
139139 'action_execution_id' : str (ac_ex_db .id ),
140140 'api_url' : 'http://127.0.0.1/v1' ,
141- 'user' : username
141+ 'user' : username ,
142+ 'pack' : 'orquesta_tests'
143+ },
144+ 'parent' : {
145+ 'pack' : 'orquesta_tests'
142146 }
143147 }
144148
@@ -294,6 +298,40 @@ def test_run_workflow_with_unicode_input(self):
294298 self .assertDictEqual (lv_ac_db .result , expected_result )
295299 self .assertDictEqual (ac_ex_db .result , expected_result )
296300
301+ def test_run_workflow_action_config_context (self ):
302+ wf_meta = base .get_wf_fixture_meta_data (TEST_PACK_PATH , 'config-context.yaml' )
303+ wf_input = {}
304+ lv_ac_db = lv_db_models .LiveActionDB (action = wf_meta ['name' ], parameters = wf_input )
305+ lv_ac_db , ac_ex_db = ac_svc .request (lv_ac_db )
306+
307+ # Assert action execution is running.
308+ lv_ac_db = lv_db_access .LiveAction .get_by_id (str (lv_ac_db .id ))
309+ self .assertEqual (lv_ac_db .status , ac_const .LIVEACTION_STATUS_RUNNING , lv_ac_db .result )
310+ wf_ex_db = wf_db_access .WorkflowExecution .query (action_execution = str (ac_ex_db .id ))[0 ]
311+ self .assertEqual (wf_ex_db .status , ac_const .LIVEACTION_STATUS_RUNNING )
312+
313+ # Assert task1 is already completed.
314+ query_filters = {'workflow_execution' : str (wf_ex_db .id ), 'task_id' : 'task1' }
315+ tk1_ex_db = wf_db_access .TaskExecution .query (** query_filters )[0 ]
316+ tk1_ac_ex_db = ex_db_access .ActionExecution .query (task_execution = str (tk1_ex_db .id ))[0 ]
317+ tk1_lv_ac_db = lv_db_access .LiveAction .get_by_id (tk1_ac_ex_db .liveaction ['id' ])
318+ self .assertEqual (tk1_lv_ac_db .status , ac_const .LIVEACTION_STATUS_SUCCEEDED )
319+ self .assertTrue (wf_svc .is_action_execution_under_workflow_context (tk1_ac_ex_db ))
320+
321+ # Manually handle action execution completion.
322+ wf_svc .handle_action_execution_completion (tk1_ac_ex_db )
323+
324+ # Assert workflow is completed.
325+ wf_ex_db = wf_db_access .WorkflowExecution .get_by_id (wf_ex_db .id )
326+ self .assertEqual (wf_ex_db .status , wf_states .SUCCEEDED )
327+ lv_ac_db = lv_db_access .LiveAction .get_by_id (str (lv_ac_db .id ))
328+ self .assertEqual (lv_ac_db .status , ac_const .LIVEACTION_STATUS_SUCCEEDED )
329+ ac_ex_db = ex_db_access .ActionExecution .get_by_id (str (ac_ex_db .id ))
330+ self .assertEqual (ac_ex_db .status , ac_const .LIVEACTION_STATUS_SUCCEEDED )
331+
332+ # Verify config_context works
333+ self .assertEqual (wf_ex_db .output , {'msg' : 'value of config key a' })
334+
297335 def test_run_workflow_with_action_less_tasks (self ):
298336 wf_meta = base .get_wf_fixture_meta_data (TEST_PACK_PATH , 'action-less-tasks.yaml' )
299337 wf_input = {'name' : 'Thanos' }
0 commit comments