Skip to content

Commit 07eb426

Browse files
committed
test(watcher): wait for the 14th reindex attempt in the sustained-failure test
watcher_sustained_failure_logs_once_issue2015 failed on macos-14 CI with `failing_index_calls == 13, expected 14`. Its loop ran exactly 14 touch+poll rounds and assumed each one reached the index callback. A poll whose git probe fails transiently (spawn refused under runner load) is a fail-closed no-op by design (DeusData#937): the baseline stays uncommitted and the next poll retries. So one refused spawn costs one attempt, and the count ends at 13. This is the same test race as watcher_unwatch_drains_pending_free, not a production defect. Holding one exhausted spawn mid-loop with cbm_subprocess_force_spawn_eagain_for_testing reproduces the CI line exactly. The loop now polls until the 14th failed attempt instead of counting polls. Each poll runs at most one attempt for the single project, so it stops at exactly 14. A watcher that never reindexes hangs, and the runner reports that as a failure, never a pass. The log-once contract means the same thing as before: watcher.index.sustained_failure is emitted only on a failed index attempt when the streak equals the threshold, so extra no-op polls cannot add lines. An `==` to `>=` mutation in watcher.c still turns it red (`sustained_log_hits == 5, expected 1`). The change is now a dirty worktree instead of a commit. If the baseline poll itself failed, the old commit would be adopted as the baseline HEAD and never reindexed, so the wait would never end. The baseline keeps the dirty signature at "clean known", so a dirty change is seen whenever the baseline lands. With spawns forced to fail at the baseline poll and again mid-loop, the test passes after 16 polls for 14 attempts. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 5a9c72d commit 07eb426

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

‎tests/test_watcher.c‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,21 +2121,34 @@ TEST(watcher_sustained_failure_logs_once_issue2015) {
21212121
failing_index_calls = 0;
21222122
failing_index_fail_first_n = 100; /* never succeeds */
21232123

2124-
cbm_watcher_poll_once(w); /* baseline */
2124+
/* Baseline poll. Its outcome is not asserted: if a git probe fails here,
2125+
* the first loop poll takes the baseline instead. */
2126+
cbm_watcher_poll_once(w);
21252127

2128+
/* The change is a DIRTY worktree, not a commit. The baseline leaves the
2129+
* dirty signature at "clean known", so this change is seen whenever the
2130+
* baseline lands. A commit made before a late (or HEAD-less) baseline
2131+
* would be adopted as the baseline HEAD and never reindexed. */
21262132
{
21272133
char p[300];
21282134
th_append_file(wt_path(p, sizeof(p), tmpdir, "file.txt"), "world\n");
21292135
}
2130-
wt_git(tmpdir, "add file.txt");
2131-
wt_git(tmpdir, "commit -q -m add-world");
21322136

21332137
sustained_log_hits = 0;
21342138
cbm_log_set_sink(sustained_log_sink);
21352139

2136-
/* Drive well past the threshold (10). touch clears the deadline each time
2137-
* so every iteration actually attempts a reindex. */
2138-
for (int i = 0; i < 14; i++) {
2140+
/* Drive well past the threshold (10): poll until the 14th failed reindex.
2141+
* A poll does not always reach the index callback: when one of its git
2142+
* probes fails transiently (spawn refused under runner load) it is a
2143+
* fail-closed no-op by design (#937) and the next poll retries. So the
2144+
* loop waits for the attempt count instead of assuming one per poll;
2145+
* touch clears the backoff deadline each time. Each poll runs at most one
2146+
* attempt for this single project, so the loop stops at exactly 14. A
2147+
* watcher that never reindexes hangs here, which the runner reports as a
2148+
* failure, never a pass. No-op polls cannot add log lines to the count:
2149+
* sustained_failure is emitted only on a failed index attempt, when the
2150+
* streak EQUALS the threshold. */
2151+
while (failing_index_calls < 14) {
21392152
cbm_watcher_touch(w, "sust-repo");
21402153
cbm_watcher_poll_once(w);
21412154
}

0 commit comments

Comments
 (0)