Skip to content

Commit

Permalink
更新trace功能报错跳过逻辑,完全删掉trace部分报错链路 (#562)
Browse files Browse the repository at this point in the history
* 更新trace功能报错跳过逻辑,完全删掉trace部分报错链路

* 更新单元测试

---------

Co-authored-by: yinjiaqi <[email protected]>
  • Loading branch information
C9luster and yinjiaqi authored Oct 24, 2024
1 parent 8489bfb commit 3e748fc
Show file tree
Hide file tree
Showing 2 changed files with 211 additions and 50 deletions.
40 changes: 40 additions & 0 deletions appbuilder/tests/test_trace_skip_raise_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def test_session_post(self):
with self.assertRaises(TestException):
mock_post_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_post_02()

def test_client_run_trace(self):
# test_client_run_trace APPBUILDER_TRACE_DEBUG = true
os.environ["APPBUILDER_TRACE_DEBUG"] = "true"
Expand All @@ -145,6 +149,10 @@ def test_client_run_trace(self):
with self.assertRaises(TestException):
mock_client_run_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_client_run_trace_02()

def test_client_tool_trace(self):
# test_client_tool_trace APPBUILDER_TRACE_DEBUG = true
os.environ["APPBUILDER_TRACE_DEBUG"] = "true"
Expand All @@ -157,6 +165,10 @@ def test_client_tool_trace(self):
with self.assertRaises(TestException):
mock_client_tool_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_client_tool_trace_02()

def test_assistent_tool_trace(self):
# test_assistent_tool_trace APPBUILDER_TRACE_DEBUG = true
os.environ["APPBUILDER_TRACE_DEBUG"] = "true"
Expand All @@ -169,6 +181,10 @@ def test_assistent_tool_trace(self):
with self.assertRaises(TestException):
mock_assistent_tool_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_assistent_tool_trace_02()

def test_assistant_run_trace(self):
# test_assistant_run_trace APPBUILDER_TRACE_DEBUG = true
os.environ["APPBUILDER_TRACE_DEBUG"] = "true"
Expand All @@ -180,6 +196,10 @@ def test_assistant_run_trace(self):
mock_assistant_run_trace_01()
with self.assertRaises(TestException):
mock_assistant_run_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_assistant_run_trace_02()

def test_assistent_stream_run_trace(self):
# test_assistent_stream_run_trace APPBUILDER_TRACE_DEBUG = true
Expand All @@ -192,6 +212,10 @@ def test_assistent_stream_run_trace(self):
mock_assistent_stream_run_trace_01()
with self.assertRaises(TestException):
mock_assistent_stream_run_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_assistent_stream_run_trace_02()

def test_assistent_stream_run_with_handler_trace(self):
# test_assistent_stream_run_with_handler_trace APPBUILDER_TRACE_DEBUG = true
Expand All @@ -205,6 +229,10 @@ def test_assistent_stream_run_with_handler_trace(self):
with self.assertRaises(TestException):
mock_assistent_stream_run_with_handler_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_assistent_stream_run_with_handler_trace_02()

def test_components_run_trace(self):
# test_components_run_trace APPBUILDER_TRACE_DEBUG = true
os.environ["APPBUILDER_TRACE_DEBUG"] = "true"
Expand All @@ -216,6 +244,10 @@ def test_components_run_trace(self):
mock_components_run_trace_01()
with self.assertRaises(TestException):
mock_components_run_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_components_run_trace_02()

def test_components_run_stream_trace(self):
# test_components_run_stream_trace APPBUILDER_TRACE_DEBUG = true
Expand All @@ -229,6 +261,10 @@ def test_components_run_stream_trace(self):
with self.assertRaises(TestException):
mock_components_run_stream_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_components_run_stream_trace_02()

def test_list_trace(self):
# test_list_trace APPBUILDER_TRACE_DEBUG = true
os.environ["APPBUILDER_TRACE_DEBUG"] = "true"
Expand All @@ -241,6 +277,10 @@ def test_list_trace(self):
with self.assertRaises(TestException):
mock_list_trace_02()

os.environ["APPBUILDER_SDK_TRACE_ENABLE"] = "false"
with self.assertRaises(Exception):
mock_list_trace_02()


if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 3e748fc

Please sign in to comment.