ci: collect a killed benchmark server without killing it twice

A crash cycle kills the server itself to bracket the kill with time stamps, so it only waits for the container before restarting it. A test covers the idle window's two scrapes.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>
This commit is contained in:
jeremyhi
2026-10-13 08:36:20 +08:00
parent 0251f12976
commit be4514ad7e
2 changed files with 22 additions and 4 deletions
+8 -2
View File
@@ -95,8 +95,14 @@ start_server() {
done
}
# kill sends SIGKILL, killed collects a server the caller already killed, and
# no argument stops it gracefully.
stop_server() {
if [[ "${1:-}" == kill ]]; then docker kill --signal KILL "$cid" >/dev/null; else docker stop -t 120 "$cid" >/dev/null; fi
case "${1:-}" in
kill) docker kill --signal KILL "$cid" >/dev/null ;;
killed) docker wait "$cid" >/dev/null ;;
*) docker stop -t 120 "$cid" >/dev/null ;;
esac
docker logs "$cid" > "$dir/server$phase.log" 2>&1
docker rm -fv "$cid" >/dev/null
cid=
@@ -159,7 +165,7 @@ crash_cycles() {
before=$(now_ns); docker kill --signal KILL "$cid" >/dev/null; after=$(now_ns)
wait "$wpid"
[[ -z "$spid" ]] || { kill "$spid" 2>/dev/null; wait "$spid" 2>/dev/null || true; spid=; }
stop_server kill
stop_server killed
phase=-restart-$cycle started=$(now)
start_server
restart_s=$(elapsed "$started")
+14 -2
View File
@@ -482,14 +482,14 @@ done
class CellLifecycleTest(unittest.TestCase): # the run script against fake docker and curl
def run_cells(self, root, load_rc, metrics_rc=0, restart=False, count=6000):
def run_cells(self, root, load_rc, metrics_rc=0, restart=False, count=6000, groups=""):
bin_dir = root / "bin"
bin_dir.mkdir()
for name, body in (("docker", FAKE_DOCKER), ("curl", FAKE_CURL)):
(bin_dir / name).write_text(body)
(bin_dir / name).chmod(0o755)
plan = bench.build_plan("8", "6000", "1000", "1", smoke=False, configs="D,E", restart=restart,
extra_env="GREPTIMEDB_OSWAL_RECOVERY_CONCURRENCY=2")
extra_env="GREPTIMEDB_OSWAL_RECOVERY_CONCURRENCY=2", groups=groups)
(root / "results").mkdir()
(root / "results" / "plan.json").write_text(json.dumps(plan))
env = os.environ | {
@@ -594,6 +594,18 @@ class CellLifecycleTest(unittest.TestCase): # the run script against fake docke
for name in ("metrics.prom", "metrics-restart.prom", "server.log", "server-restart.log"):
self.assertTrue((cell / name).exists(), name)
def test_an_idle_window_scrapes_before_and_after_it(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
groups = json.dumps([{"name": "idle", "configs": "D", "idle_seconds": 1}])
cells, _, log, _ = self.run_cells(root, load_rc=0, groups=groups)
self.assertEqual(cells.returncode, 0, cells.stdout + cells.stderr)
cell = root / "results" / "cells" / "idle-1-8-D"
self.assertTrue((cell / "metrics-idle.prom").exists())
self.assertTrue((cell / "metrics.prom").exists())
self.assertEqual(log.count("/metrics"), 2)
self.assertIn(f"type=bind,src={root}/corpus/corpus-6000,dst=/work/corpus,readonly", log)
def test_a_restart_that_loses_rows_fails_the_cell(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)