From 67f3f6ad801ebb28cf637ee668668a1e7b47155f Mon Sep 17 00:00:00 2001 From: "lei.chen" Date: Wed, 5 Aug 2026 09:41:06 +0000 Subject: [PATCH] fix(controller-tests): clean /tmp/xce_* scratch dirs to stop 28G disk fill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test fixtures create WAL/snapshot scratch dirs via mkdtemp (/tmp/xce_e2e_ckpt_*, /tmp/xce_ucaf61_*, /tmp/xce_ts_*) but their teardown only frees the persist_t — the dir is never removed. persist_init preallocates a 64MB WAL segment per init, so a full controller_unit_test run leaves ~28G in /tmp in under a minute, filling the root filesystem. Remove only xce_* DIRECTORIES at suite start (stale leftovers) and via atexit (this run). Files are untouched: the user's /tmp/xce-mcp binary and the suite's own /tmp/xce_test.log survive the -type d filter. --- src/controller/testsuite/test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/controller/testsuite/test.c b/src/controller/testsuite/test.c index 013fe1e7..88da3bac 100644 --- a/src/controller/testsuite/test.c +++ b/src/controller/testsuite/test.c @@ -3757,6 +3757,22 @@ static int worker_house_keeping(void* arg) return rc; } +/* bug-XXXX (disk fill): the persist_* / config_repl / HA test fixtures create + * their WAL/snapshot scratch dirs via mkdtemp("/tmp/xce_..._XXXXXX") but their + * teardown only frees the persist_t — the directory is never removed. A full + * controller_unit_test run therefore leaves ~28G behind in /tmp in under a + * minute, filling a 62G root filesystem. Remove only xce_* DIRECTORIES (never + * files — the user's /tmp/xce-mcp binary and the suite's own /tmp/xce_test.log + * must survive). Run at suite start (stale leftovers from prior runs) and on + * exit via atexit (this run). */ +static void clean_test_scratch_dirs(void) +{ + if (system("find /tmp -maxdepth 1 -type d -name 'xce_*' " + "-exec rm -rf {} + 2>/dev/null") != 0) { + /* non-zero only if find is unavailable; cleanup is best-effort */ + } +} + int main(int argc, char* argv[]) { struct arguments arguments; @@ -3769,6 +3785,11 @@ int main(int argc, char* argv[]) memset(&arguments, 0x0, sizeof(arguments)); argp_parse(&argp, argc, argv, 0, 0, &arguments); + /* Bug-XXXX: remove stale test scratch dirs from prior runs, then ensure + * this run's scratch dirs are cleaned on exit. */ + clean_test_scratch_dirs(); + atexit(clean_test_scratch_dirs); + if (arguments.verbose != 0) { loglevel = verbose_to_loglevel(arguments.verbose); }