diff --git a/gcloud/taskflow3/domains/dispatchers/node.py b/gcloud/taskflow3/domains/dispatchers/node.py index b53d4c99d9..36d591b324 100644 --- a/gcloud/taskflow3/domains/dispatchers/node.py +++ b/gcloud/taskflow3/domains/dispatchers/node.py @@ -778,14 +778,10 @@ def get_node_detail_v2( format_pipeline_status(hist) # 节点未执行 else: - pipeline_instance = kwargs["pipeline_instance"] - node = self._get_node_info( - node_id=self.node_id, pipeline=pipeline_instance.execution_data, subprocess_stack=subprocess_stack - ) detail.update( { - "name": node["name"], - "error_ignorable": node.get("error_ignorable", False), + "name": node_info["name"], + "error_ignorable": node_info.get("error_ignorable", False), "state": bamboo_engine_states.READY, } ) diff --git a/gcloud/tests/taskflow3/dispatchers/node/node_command_dispatcher/test_get_node_detail_v2.py b/gcloud/tests/taskflow3/dispatchers/node/node_command_dispatcher/test_get_node_detail_v2.py index b4579d304e..d098185bd0 100644 --- a/gcloud/tests/taskflow3/dispatchers/node/node_command_dispatcher/test_get_node_detail_v2.py +++ b/gcloud/tests/taskflow3/dispatchers/node/node_command_dispatcher/test_get_node_detail_v2.py @@ -11,12 +11,11 @@ specific language governing permissions and limitations under the License. """ +from bamboo_engine import states as bamboo_engine_states from django.test import TestCase from gcloud import err_code from gcloud.taskflow3.domains.dispatchers.node import NodeCommandDispatcher -from bamboo_engine import states as bamboo_engine_states - from gcloud.tests.mock import * # noqa from gcloud.tests.mock_settings import * # noqa @@ -87,7 +86,7 @@ def test_node_started_loop_is_none(self): bamboo_api.get_node_histories = MagicMock(return_value=get_node_histories_return) dispatcher = NodeCommandDispatcher(engine_ver=2, node_id="node_id") - dispatcher._get_node_info = MagicMock() + dispatcher._get_node_info = MagicMock(return_value={"type": "ServiceActivity"}) format_pipeline_status = MagicMock() with patch(TASKFLOW_DISPATCHERS_NODE_BAMBOO_RUNTIME, runtime_init): @@ -103,7 +102,9 @@ def test_node_started_loop_is_none(self): bamboo_api.get_children_states.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id) bamboo_api.get_node_histories.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id, loop=1) - dispatcher._get_node_info.assert_not_called() + dispatcher._get_node_info.assert_called_once_with( + node_id=dispatcher.node_id, pipeline=pipeline_instance.execution_data, subprocess_stack=subprocess_stack + ) self.assertEqual( node_detail, @@ -149,7 +150,7 @@ def test_node_started_loop_is_latest(self): bamboo_api.get_node_histories = MagicMock(return_value=get_node_histories_return) dispatcher = NodeCommandDispatcher(engine_ver=2, node_id="node_id") - dispatcher._get_node_info = MagicMock() + dispatcher._get_node_info = MagicMock(return_value={"type": "ServiceActivity"}) format_pipeline_status = MagicMock() with patch(TASKFLOW_DISPATCHERS_NODE_BAMBOO_RUNTIME, runtime_init): @@ -165,7 +166,9 @@ def test_node_started_loop_is_latest(self): bamboo_api.get_children_states.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id) bamboo_api.get_node_histories.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id, loop=1) - dispatcher._get_node_info.assert_not_called() + dispatcher._get_node_info.assert_called_once_with( + node_id=dispatcher.node_id, pipeline=pipeline_instance.execution_data, subprocess_stack=subprocess_stack + ) self.assertEqual( node_detail, @@ -213,7 +216,7 @@ def test_node_started_loop_is_not_latest(self): bamboo_api.get_node_histories = MagicMock(return_value=get_node_histories_return) dispatcher = NodeCommandDispatcher(engine_ver=2, node_id="node_id") - dispatcher._get_node_info = MagicMock() + dispatcher._get_node_info = MagicMock(return_value={"type": "ServiceActivity"}) dispatcher._assemble_histroy_detail = MagicMock() format_pipeline_status = MagicMock() @@ -230,7 +233,9 @@ def test_node_started_loop_is_not_latest(self): bamboo_api.get_children_states.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id) bamboo_api.get_node_histories.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id, loop=1) - dispatcher._get_node_info.assert_not_called() + dispatcher._get_node_info.assert_called_once_with( + node_id=dispatcher.node_id, pipeline=pipeline_instance.execution_data, subprocess_stack=subprocess_stack + ) dispatcher._assemble_histroy_detail.assert_called_once() self.assertEqual(