diff --git a/vitrage/evaluator/actions/recipes/mark_down.py b/vitrage/evaluator/actions/recipes/mark_down.py index 4436424f8..714835285 100644 --- a/vitrage/evaluator/actions/recipes/mark_down.py +++ b/vitrage/evaluator/actions/recipes/mark_down.py @@ -53,6 +53,7 @@ class MarkDown(base.Recipe): update_vertex_params = { VProps.VITRAGE_ID: target_id, + VProps.IS_REAL_VITRAGE_ID: True, VProps.IS_MARKED_DOWN: is_marked_down } update_vertex_step = ActionStepWrapper(UPDATE_VERTEX, diff --git a/vitrage/tests/functional/evaluator/test_action_executor.py b/vitrage/tests/functional/evaluator/test_action_executor.py index 89f7532a4..c5fa586be 100644 --- a/vitrage/tests/functional/evaluator/test_action_executor.py +++ b/vitrage/tests/functional/evaluator/test_action_executor.py @@ -46,7 +46,7 @@ class TestActionExecutor(TestFunctionalBase): for datasource_name in cls.conf.datasources.types: register_opts(cls.conf, datasource_name, cls.conf.datasources.path) - def test_execute_update_vertex(self): + def test_execute_set_state(self): # Test Setup processor = self._create_processor_with_graph(self.conf, uuid=True) @@ -94,6 +94,43 @@ class TestActionExecutor(TestFunctionalBase): self.assertNotIn( VProps.VITRAGE_STATE, host_vertex_after_undo.properties) + def test_execute_mark_down(self): + + # Test Setup + processor = self._create_processor_with_graph(self.conf, uuid=True) + + vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE} + host_vertices = processor.entity_graph.get_vertices( + vertex_attr_filter=vertex_attrs) + host_vertex_before = host_vertices[0] + + targets = {TFields.TARGET: host_vertex_before} + props = {} + action_spec = ActionSpecs(ActionType.MARK_DOWN, targets, props) + + event_queue = queue.Queue() + action_executor = ActionExecutor(event_queue) + + # Test Action - do + action_executor.execute(action_spec, ActionMode.DO) + processor.process_event(event_queue.get()) + + host_vertex_after = processor.entity_graph.get_vertex( + host_vertex_before.vertex_id) + + # Test Assertions + self.assertTrue(host_vertex_after.get(VProps.IS_MARKED_DOWN)) + + # Test Action - undo + action_executor.execute(action_spec, ActionMode.UNDO) + processor.process_event(event_queue.get()) + + host_vertex_after_undo = processor.entity_graph.get_vertex( + host_vertex_before.vertex_id) + + # Test Assertions + self.assertFalse(host_vertex_after_undo.get(VProps.IS_MARKED_DOWN)) + def test_execute_add_edge(self): # Test Setup diff --git a/vitrage/tests/unit/evaluator/recipes/test_mark_down.py b/vitrage/tests/unit/evaluator/recipes/test_mark_down.py index 2333d511d..c8c722e04 100644 --- a/vitrage/tests/unit/evaluator/recipes/test_mark_down.py +++ b/vitrage/tests/unit/evaluator/recipes/test_mark_down.py @@ -45,7 +45,7 @@ class MarkDownRecipeTest(base.BaseTest): self.assertEqual(UPDATE_VERTEX, action_steps[0].type) update_vertex_step_params = action_steps[0].params - self.assertEqual(2, len(update_vertex_step_params)) + self.assertEqual(3, len(update_vertex_step_params)) is_marked_down = update_vertex_step_params[VProps.IS_MARKED_DOWN] self.assertTrue(is_marked_down) @@ -53,6 +53,10 @@ class MarkDownRecipeTest(base.BaseTest): vitrage_id = update_vertex_step_params[VProps.VITRAGE_ID] self.assertEqual(self.target_vertex.vertex_id, vitrage_id) + is_real_vitrage_id = \ + update_vertex_step_params[VProps.IS_REAL_VITRAGE_ID] + self.assertTrue(is_real_vitrage_id) + def test_get_undo_recipe(self): # Test Action @@ -65,10 +69,14 @@ class MarkDownRecipeTest(base.BaseTest): self.assertEqual(UPDATE_VERTEX, action_steps[0].type) update_vertex_step_params = action_steps[0].params - self.assertEqual(2, len(update_vertex_step_params)) + self.assertEqual(3, len(update_vertex_step_params)) is_marked_down = update_vertex_step_params[VProps.IS_MARKED_DOWN] self.assertFalse(is_marked_down) vitrage_id = update_vertex_step_params[VProps.VITRAGE_ID] self.assertEqual(self.target_vertex.vertex_id, vitrage_id) + + is_real_vitrage_id = \ + update_vertex_step_params[VProps.IS_REAL_VITRAGE_ID] + self.assertTrue(is_real_vitrage_id)