From 96b90ad625ac380a745ae67b96b7cfb067e554db Mon Sep 17 00:00:00 2001 From: ZT-AIA <63220130+ZT-AIA@users.noreply.github.com> Date: Wed, 29 Apr 2026 10:17:08 +0800 Subject: [PATCH] [CI] repair bug custom op ci conftest.py (#8786) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What this PR does / why we need it? repair bug custom op ci `conftest.py`:Some test cases fail or are skipped, leading to incorrect time retrieval. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? nightly Signed-off-by: ZT-AIA <1028681969@qq.com> --- tests/e2e/nightly/single_node/ops/conftest.py | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/tests/e2e/nightly/single_node/ops/conftest.py b/tests/e2e/nightly/single_node/ops/conftest.py index cb177000..b455eb23 100644 --- a/tests/e2e/nightly/single_node/ops/conftest.py +++ b/tests/e2e/nightly/single_node/ops/conftest.py @@ -14,41 +14,37 @@ def pytest_runtest_setup(item): item.start_time = time.time() -def pytest_runtest_teardown(item, nextitem): +@pytest.hookimpl(tryfirst=True, hookwrapper=True) +def pytest_runtest_makereport(item, call): + outcome = yield + report = outcome.get_result() + global _current_file + if report.when != 'call': + return + if not hasattr(item, 'start_time'): + return + time_stamp = datetime.now().strftime("[%H:%M:%S]") + print(f"{time_stamp}") + file_path = item.fspath duration = time.time() - item.start_time - if file_path not in _per_file_slow_cases: _per_file_slow_cases[file_path] = 0 if duration > DURATION_THRESHOLD: _per_file_slow_cases[file_path] += 1 cnt = _per_file_slow_cases[file_path] - print(f" Detected that the test case took too long, ({cnt}/{SLOW_COUNT_LIMIT}):{duration:.2f}s") + print(f" Detected slow case ({cnt}/{SLOW_COUNT_LIMIT}): {duration:.2f}s | {item.nodeid}") if cnt >= SLOW_COUNT_LIMIT: - print(f"\n The number of timeout test cases {file_path} ≥{SLOW_COUNT_LIMIT}\n") - _current_file = file_path + print(f"\n Timeout cases in {file_path} ≥ {SLOW_COUNT_LIMIT}\n") + _current_file = file_path def pytest_runtest_call(item): if _current_file == item.fspath: - print(f"CASE SKIP:{item.nodeid}") - pytest.skip(f"The use case takes too long.") - - -@pytest.hookimpl(tryfirst=True, hookwrapper=True) -def pytest_runtest_makereport(item, call): - """Hook to add timestamp to test reports""" - start_time = datetime.now().strftime("[%H:%M:%S]") - - outcome = yield - - report = outcome.get_result() - - if report.when == 'call': - - print(f"{start_time}") \ No newline at end of file + print(f"CASE SKIP: {item.nodeid}") + pytest.skip("The use case takes too long.")