tests: remove unnecessary barriers from parallel checks
This commit is contained in:
1 parent
69a99c7860
commit
8de64174bb
2 files changed
+29
-9
No files matched your search
+8
-7
@@ -11,11 +11,9 @@ import sys
|
||||
import time
|
||||
|
||||
|
||||
# Эти тесты измеряют скорость/нагрузку CPU; autosocket проверяем отдельно с sudo.
|
||||
# Проверки точных порогов CPU/wall-time выполняем после общего пула.
|
||||
EXCLUSIVE = frozenset({
|
||||
"bench_timeout_heap", "bench_uasync_timeouts", "test_u_async_performance",
|
||||
"test_intensive_memory_pool", "test_media_async", "test_bbr_integration",
|
||||
"test_uasync_load", "test_auto_socket_dynamic",
|
||||
"test_media_async", "test_uasync_load",
|
||||
})
|
||||
EXCLUSIVE |= {name + ".exe" for name in EXCLUSIVE}
|
||||
|
||||
@@ -95,6 +93,7 @@ def run_tests(args, requested_signals):
|
||||
failed = []
|
||||
running = []
|
||||
index = 0
|
||||
tests = [name for name in args.tests if name not in EXCLUSIVE] + [name for name in args.tests if name in EXCLUSIVE]
|
||||
use_sudo = ("test_auto_socket_dynamic" in args.tests and hasattr(os, "geteuid") and os.geteuid() != 0
|
||||
and shutil.which("sudo") and subprocess.run(["sudo", "-n", "true"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0)
|
||||
@@ -108,13 +107,13 @@ def run_tests(args, requested_signals):
|
||||
|
||||
print(f"[INFO] test runner: jobs={args.jobs} available_cpus={available_cpus()} timeout={args.timeout}s", flush=True)
|
||||
try:
|
||||
while index < len(args.tests) or running:
|
||||
while index < len(tests) or running:
|
||||
if requested_signals:
|
||||
raise InterruptedRun(requested_signals[0])
|
||||
while index < len(args.tests) and len(running) < args.jobs:
|
||||
while index < len(tests) and len(running) < args.jobs:
|
||||
if requested_signals:
|
||||
break
|
||||
name = args.tests[index]
|
||||
name = tests[index]
|
||||
if running and (name in EXCLUSIVE or running[0][0] in EXCLUSIVE):
|
||||
break
|
||||
index += 1
|
||||
@@ -122,6 +121,8 @@ def run_tests(args, requested_signals):
|
||||
report(name, "SKIP", 0, "not built")
|
||||
continue
|
||||
command = [str(Path(name).resolve())]
|
||||
if name in EXCLUSIVE:
|
||||
print(f"[INFO] {name}: running alone to check CPU/wall-time limits", flush=True)
|
||||
if name == "test_auto_socket_dynamic" and use_sudo:
|
||||
command = ["sudo", "-n", "--"] + command
|
||||
print(f"[INFO] {name}: running as root via sudo -n", flush=True)
|
||||
|
||||
+21
-2
@@ -63,7 +63,7 @@ event('start')
|
||||
self.assertEqual(result.returncode, 2, result.stdout)
|
||||
self.assertIn("expected a positive integer", result.stdout)
|
||||
|
||||
def test_parallel_limit_and_exclusive_barrier(self):
|
||||
def test_parallel_limit_and_measurements_after_pool(self):
|
||||
for name, pair in (("first_a", "first"), ("first_b", "first"), ("last_a", "last"), ("last_b", "last")):
|
||||
self.fixture(name, f"""
|
||||
Path(name + '.ready').touch()
|
||||
@@ -88,7 +88,26 @@ time.sleep(0.05)
|
||||
self.assertFalse(active)
|
||||
self.assertEqual(maximum, 2)
|
||||
self.assertEqual({name for name, _ in events[:2]}, {"first_a", "first_b"})
|
||||
self.assertEqual(events[4:6], [["test_media_async", "start"], ["test_media_async", "end"]])
|
||||
self.assertEqual(events[-2:], [["test_media_async", "start"], ["test_media_async", "end"]])
|
||||
self.assertIn("test_media_async: running alone to check CPU/wall-time limits", result.stdout)
|
||||
|
||||
def test_long_network_tests_share_pool(self):
|
||||
names = ["test_bbr_integration", "test_auto_socket_dynamic"]
|
||||
for name in names:
|
||||
self.fixture(name, """
|
||||
Path(name + '.ready').touch()
|
||||
deadline = time.monotonic() + 5
|
||||
while len(list(Path('.').glob('*.ready'))) < 2:
|
||||
if time.monotonic() > deadline: sys.exit(9)
|
||||
time.sleep(0.01)
|
||||
time.sleep(0.05)
|
||||
""")
|
||||
# У фиктивного autosocket нет требований root: не вызываем sudo в этой регрессии.
|
||||
result = self.run_runner(names, environment=dict(os.environ, TEST_JOBS="2", PATH=str(self.root)))
|
||||
self.assertEqual(result.returncode, 0, result.stdout)
|
||||
events = [json.loads(line) for line in (self.root / "events").read_text().splitlines()]
|
||||
self.assertEqual({name for name, _ in events[:2]}, set(names))
|
||||
self.assertEqual([state for _, state in events], ["start", "start", "end", "end"])
|
||||
|
||||
def test_exit_codes_and_separate_logs(self):
|
||||
self.fixture("ok")
|
||||
|
||||
Reference in new issue
Block a user