From 1b49281f6b00a8fc159203868dd859e9c467c2e9 Mon Sep 17 00:00:00 2001 From: Austin Macdonald Date: Tue, 14 Jan 2025 11:56:06 -0600 Subject: [PATCH] dont assume that all processes will be collected in a single sample --- test/test_e2e.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/test/test_e2e.py b/test/test_e2e.py index d524df5..ff75450 100644 --- a/test/test_e2e.py +++ b/test/test_e2e.py @@ -2,7 +2,6 @@ import json from pathlib import Path import subprocess -from typing import Dict import pytest ABANDONING_PARENT = str(Path(__file__).with_name("data") / "abandoning_parent.sh") @@ -13,26 +12,19 @@ def test_sanity(temp_output_dir: str) -> None: subprocess.check_output(command, shell=True) -@pytest.mark.parametrize("num_children", [3, 5, 10, 20]) +@pytest.mark.parametrize("num_children", [1, 10, 25, 101]) def test_abandoning_parent(temp_output_dir: str, num_children: int) -> None: duct_prefix = f"{temp_output_dir}log_" - command = f"duct --s-i 0.01 --r-i 0.02 -p {duct_prefix} {ABANDONING_PARENT} {num_children} sleep 0.1" + command = f"duct --s-i 0.001 --r-i 0.01 -p {duct_prefix} {ABANDONING_PARENT} {num_children} sleep 0.1" subprocess.check_output(command, shell=True) with open(f"{duct_prefix}usage.json") as usage_file: all_samples = [json.loads(line) for line in usage_file] - max_processes_sample: Dict[str, Dict] = {"processes": {}} + all_processes = {} for sample in all_samples: - if len(max_processes_sample) < len(sample.get("processes")): - max_processes_sample = sample - - cmds = [proc["cmd"] for _pid, proc in max_processes_sample["processes"].items()] - - # DEBUG - from pprint import pprint - - pprint(cmds) + for pid, proc in sample["processes"].items(): + all_processes[pid] = proc # 1 for each child, 1 for pstree, 1 for parent - assert len(max_processes_sample["processes"]) == num_children + 2 + assert len(all_processes) == num_children + 2