已合并
Fix the relative path of op-plugin's UT to run load_all_ut #12687
AtomGit-Bot创建于 2024年6月26日
Fix the relative path of op-plugin's UT to run load_all_ut #12687
已合并
AtomGit-Bot创建于 2024年6月26日
refs/pull/12687/head合入到master
3 个文件变更+8-3
@@ -1,5 +1,5 @@
1from .constants import (1from .constants import (
2- BASE_DIR, TEST_DIR,2+ BASE_DIR, TEST_DIR, NETWORK_OPS_DIR,
3 SLOW_TEST_BLOCKLIST, NOT_RUN_DIRECTLY, INCLUDE_FILES, EXEC_TIMEOUT3 SLOW_TEST_BLOCKLIST, NOT_RUN_DIRECTLY, INCLUDE_FILES, EXEC_TIMEOUT
4)4)
5from .test_manager import TestMgr5from .test_manager import TestMgr
@@ -3,6 +3,7 @@ from pathlib import Path
3 3 
4BASE_DIR = Path(__file__).absolute().parent.parent.parent4BASE_DIR = Path(__file__).absolute().parent.parent.parent
5TEST_DIR = BASE_DIR / 'test'5TEST_DIR = BASE_DIR / 'test'
6+NETWORK_OPS_DIR = BASE_DIR / 'third_party/op-plugin/test'
6 7 
7SLOW_TEST_BLOCKLIST = [8SLOW_TEST_BLOCKLIST = [
8 'test_ops',9 'test_ops',
@@ -11,7 +11,7 @@ import random
11import psutil11import psutil
12from access_control import (12from access_control import (
13 TestMgr,13 TestMgr,
14- BASE_DIR, TEST_DIR, SLOW_TEST_BLOCKLIST, NOT_RUN_DIRECTLY, EXEC_TIMEOUT14+ BASE_DIR, TEST_DIR, SLOW_TEST_BLOCKLIST, NOT_RUN_DIRECTLY, EXEC_TIMEOUT, NETWORK_OPS_DIR
15)15)
16 16 
17 17 
@@ -25,6 +25,8 @@ def exec_ut(files):
25 return op_name[5:] if op_name.startswith("test_") else op_name25 return op_name[5:] if op_name.startswith("test_") else op_name
26 26 
27 def get_ut_name(ut_file):27 def get_ut_name(ut_file):
28+ if 'op-plugin' in str(Path(ut_file)):
29+ return str(Path(ut_file).relative_to(NETWORK_OPS_DIR))[:-3]
28 return str(Path(ut_file).relative_to(TEST_DIR))[:-3]30 return str(Path(ut_file).relative_to(TEST_DIR))[:-3]
29 31 
30 def get_ut_cmd(ut_type, ut_file):32 def get_ut_cmd(ut_type, ut_file):
D
Ddilililiwhy12024年6月26日

建议使用卫语句即可,减少复杂度

likedislike
@@ -32,6 +34,8 @@ def exec_ut(files):
32 if ut_type == "op_ut_files":34 if ut_type == "op_ut_files":
33 # do not skip ops related test entries35 # do not skip ops related test entries
34 return cmd + ["-e"] + SLOW_TEST_BLOCKLIST[1:] + ["-i", "test_ops", "--", "-k", "_" + get_op_name(ut_file)]36 return cmd + ["-e"] + SLOW_TEST_BLOCKLIST[1:] + ["-i", "test_ops", "--", "-k", "_" + get_op_name(ut_file)]
37+ if 'op-plugin' in str(Path(ut_file)):
38+ cmd = [sys.executable, NETWORK_OPS_DIR / "run_test.py", "-v"]
35 return cmd + ["-i", get_ut_name(ut_file)]39 return cmd + ["-i", get_ut_name(ut_file)]
36 40 
37 def wait_thread(process, event_timer):41 def wait_thread(process, event_timer):
@@ -92,7 +96,7 @@ def exec_ut(files):
92 if ut_type == "op_ut_files":96 if ut_type == "op_ut_files":
93 ut_info = "test_ops " + ut_info97 ut_info = "test_ops " + ut_info
94 else:98 else:
95- cmd = cmd + ["--init_method={}".format(init_method)]99+ cmd = cmd if 'op-plugin' in str(Path(ut_file)) else cmd + ["--init_method={}".format(init_method)]
96 ret = run_cmd_with_timeout(cmd)100 ret = run_cmd_with_timeout(cmd)
97 if ret:101 if ret:
98 has_failed = ret102 has_failed = ret