Skip to content

Commit 31a32ca

Browse files
committed
Add timeout factor to test runner
1 parent df101e5 commit 31a32ca

File tree

1 file changed

+18
-10
lines changed
  • graalpython/com.oracle.graal.python.test/src

1 file changed

+18
-10
lines changed

graalpython/com.oracle.graal.python.test/src/runner.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,12 @@ def interrupt_process(process: subprocess.Popen):
488488

489489

490490
class ParallelTestRunner(TestRunner):
491-
def __init__(self, *, num_processes, subprocess_args, separate_workers, **kwargs):
491+
def __init__(self, *, num_processes, subprocess_args, separate_workers, timeout_factor, **kwargs):
492492
super().__init__(**kwargs)
493493
self.num_processes = num_processes
494494
self.subprocess_args = subprocess_args
495495
self.separate_workers = separate_workers
496+
self.timeout_factor = timeout_factor
496497
self.stop_event = threading.Event()
497498
self.crashes = []
498499
self.default_test_timeout = 600
@@ -741,10 +742,13 @@ def run_in_subprocess_and_watch(self):
741742
break
742743
if self.last_started_test_id:
743744
last_started_test = self.tests_by_id.get(self.last_started_test_id)
744-
timeout = last_started_test.test_file.test_config.per_test_timeout
745+
timeout = (
746+
last_started_test.test_file.test_config.per_test_timeout
747+
or self.runner.default_test_timeout
748+
)
745749
else:
746750
timeout = self.runner.default_test_timeout
747-
751+
timeout *= self.runner.timeout_factor
748752
if time.time() - self.last_started_time >= timeout:
749753
interrupt_process(self.process)
750754
timed_out = timeout
@@ -789,6 +793,7 @@ def run_in_subprocess_and_watch(self):
789793
status=TestStatus.ERROR,
790794
param=message,
791795
output=output,
796+
duration=(time.time() - self.last_started_time),
792797
))
793798
if blame_id is not self.last_started_test_id:
794799
# If we're here, it means we didn't know exactly which test we were executing, we were
@@ -804,7 +809,7 @@ def run_in_subprocess_and_watch(self):
804809
del self.remaining_test_ids[0]
805810
self.last_started_test_id = None
806811
if last_remaining_count == len(self.remaining_test_ids):
807-
raise RuntimeError("Worker is not making progress")
812+
log(f"Worker is not making progress, remaining: {self.remaining_test_ids}")
808813

809814

810815
def platform_keys_match(items: typing.Iterable[str]):
@@ -813,9 +818,9 @@ def platform_keys_match(items: typing.Iterable[str]):
813818

814819
@dataclass
815820
class TestFileConfig:
816-
serial: bool = False
817-
partial_splits: bool = False
818-
per_test_timeout: float = 300
821+
serial: bool | None = None
822+
partial_splits: bool | None = None
823+
per_test_timeout: float | None = None
819824
exclude: bool = False
820825

821826
@classmethod
@@ -829,9 +834,9 @@ def from_dict(cls, config: dict):
829834

830835
def combine(self, other: 'TestFileConfig'):
831836
return TestFileConfig(
832-
serial=self.serial or other.serial,
833-
partial_splits=self.partial_splits or other.partial_splits,
834-
per_test_timeout=max(self.per_test_timeout, other.per_test_timeout),
837+
serial=(self.serial if other.serial is None else other.serial),
838+
partial_splits=(self.partial_splits if other.partial_splits is None else other.partial_splits),
839+
per_test_timeout=(self.per_test_timeout if other.per_test_timeout is None else other.per_test_timeout),
835840
exclude=self.exclude or other.exclude,
836841
)
837842

@@ -1211,6 +1216,8 @@ def main():
12111216
help="Produce a json report file in format expected by mx_gate.make_test_report")
12121217
parser.add_argument('--untag-unmatched', action='store_true',
12131218
help="Remove tests that were not collected from tags. Useful for pruning removed tests")
1219+
parser.add_argument('--timeout-factor', type=float, default=1.0,
1220+
help="Multiply all timeouts by this number")
12141221
parser.add_argument(
12151222
'--subprocess-args',
12161223
type=shlex.split,
@@ -1315,6 +1322,7 @@ def main():
13151322
num_processes=args.num_processes,
13161323
subprocess_args=args.subprocess_args,
13171324
separate_workers=args.separate_workers,
1325+
timeout_factor=args.timeout_factor,
13181326
)
13191327

13201328
runner.run_tests(tests)

0 commit comments

Comments
 (0)