Skip to content

Commit 70a0f5b

Browse files
authored
[TRTLLM-8580][test] save runtime report periodically (#8312)
Signed-off-by: Ivy Zhang <[email protected]>
1 parent dd06612 commit 70a0f5b

File tree

3 files changed

+409
-1
lines changed

3 files changed

+409
-1
lines changed

tests/integration/defs/conftest.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from .trt_test_alternative import (call, check_output, exists, is_windows,
5050
is_wsl, makedirs, print_info, print_warning,
5151
wsl_to_win_path)
52+
from .utils.periodic_junit import PeriodicJUnitXML
5253

5354
try:
5455
from llm import trt_environment
@@ -2095,6 +2096,33 @@ def pytest_addoption(parser):
20952096
"Specify test model suites separated by semicolons or spaces. Each suite can contain special characters. "
20962097
"Example: --test-model-suites=suite1;suite2;suite3 or --test-model-suites=suite1 suite2 suite3",
20972098
)
2099+
parser.addoption(
2100+
"--periodic-junit",
2101+
action="store_true",
2102+
default=False,
2103+
help=
2104+
"Enable periodic JUnit XML reporter. This reporter leverages pytest's built-in junitxml "
2105+
"for reliable test result handling. Saves progress periodically to prevent data loss on "
2106+
"interruption. Requires --output-dir to be set.",
2107+
)
2108+
parser.addoption(
2109+
"--periodic-interval",
2110+
action="store",
2111+
type=int,
2112+
default=18000,
2113+
help=
2114+
"Time interval in seconds between periodic saves (default: 18000s = 5 hours). "
2115+
"Only used with --periodic-junit.",
2116+
)
2117+
parser.addoption(
2118+
"--periodic-batch-size",
2119+
action="store",
2120+
type=int,
2121+
default=10,
2122+
help=
2123+
"Number of completed tests before triggering a periodic save (default: 10). "
2124+
"Only used with --periodic-junit.",
2125+
)
20982126

20992127

21002128
@pytest.hookimpl(trylast=True)
@@ -2196,6 +2224,40 @@ def pytest_configure(config):
21962224
if config.getoption("--run-ray"):
21972225
os.environ["TLLM_DISABLE_MPI"] = "1"
21982226

2227+
# Initialize PeriodicJUnitXML reporter if enabled
2228+
periodic = config.getoption("--periodic-junit", default=False)
2229+
output_dir = config.getoption("--output-dir", default=None)
2230+
2231+
if periodic and output_dir:
2232+
periodic_interval = config.getoption("--periodic-interval")
2233+
periodic_batch_size = config.getoption("--periodic-batch-size")
2234+
2235+
# Create the reporter with logger
2236+
xmlpath = os.path.join(output_dir, "results.xml")
2237+
reporter = PeriodicJUnitXML(
2238+
xmlpath=xmlpath,
2239+
interval=periodic_interval,
2240+
batch_size=periodic_batch_size,
2241+
logger={
2242+
'info': print_info,
2243+
'warning': print_warning
2244+
},
2245+
)
2246+
2247+
# Configure and register the reporter
2248+
reporter.pytest_configure(config)
2249+
config.pluginmanager.register(reporter, 'periodic_junit')
2250+
2251+
print_info("PeriodicJUnitXML reporter registered")
2252+
print_info(
2253+
f" Interval: {periodic_interval}s ({periodic_interval/60:.1f} min)"
2254+
)
2255+
print_info(f" Batch size: {periodic_batch_size} tests")
2256+
elif periodic and not output_dir:
2257+
print_warning(
2258+
"Warning: --periodic-junit requires --output-dir to be set. "
2259+
"Periodic reporting disabled.")
2260+
21992261

22002262
def deselect_by_test_model_suites(test_model_suites, items, test_prefix,
22012263
config):

tests/integration/defs/utils/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919
boilerplate code.
2020
"""
2121

22+
from .periodic_junit import PeriodicJUnitXML
2223
from .timeout_manager import (TimeoutManager, create_timeout_manager,
2324
with_timeout_management)
2425

2526
__all__ = [
26-
'TimeoutManager', 'with_timeout_management', 'create_timeout_manager'
27+
'PeriodicJUnitXML',
28+
'TimeoutManager',
29+
'with_timeout_management',
30+
'create_timeout_manager',
2731
]

0 commit comments

Comments
 (0)