host stage test: prove the skip by key, not by a copy count compaction decides
Under load litestream compacted the replica to three objects before the seal, and the seal's three copies of new files failed a count check that assumed more. The test now requires at least one pre-copied object to survive unchanged to the seal, and none of those to be copied again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+13
−3
internal/host/movesoffline_stage_test.go+13 −3
CI cancelled — superseded by a newer push — run details
CI log
=== gate === cd launchctx && go vet ./... && go test ./... -count=1 ok amadan.net/carlos/platform.git/launchctx 0.011s ? amadan.net/carlos/platform.git/launchctx/controlname [no test files] ? amadan.net/carlos/platform.git/launchctx/wireid [no test files] go vet ./... gofmt -l .: clean go test ./... -count=1 -timeout 30m amadan: job cancelled — a newer push superseded it
diff --git a/internal/host/movesoffline_stage_test.go b/internal/host/movesoffline_stage_test.go| index 6cd1f98ba..047efc554 100644 |
| --- a/internal/host/movesoffline_stage_test.go |
| +++ b/internal/host/movesoffline_stage_test.go |
| @@ -232,10 +232,20 @@ func TestOfflineStageThenStartThenSealSkipsThePreCopy(t *testing.T) { |
| t.Fatalf("state %s, want sealed", st) |
| } |
| sealCopies := spy.take() |
| - if len(sealCopies) >= len(preReplica) { |
| - t.Fatalf("the seal made %d copies of a %d-object replica the stage had copied", len(sealCopies), len(preReplica)) |
| + // Litestream's compaction decides how many files the checkpoint adds, |
| + // so the count of the seal's copies is not fixed. What is: at least one |
| + // object the stage copied is still in the replica, unchanged, and the |
| + // seal copied none of those (the loop below). |
| + kept := 0 |
| + for rel, o := range sw.replicaRel() { |
| + if s, ok := preStaged[rel]; ok && s.Size == o.Size && preReplica[rel].ETag == o.ETag { |
| + kept++ |
| + } |
| + } |
| + if kept == 0 { |
| + t.Fatal("fixture: no pre-copied object survived to the seal, so nothing shows a skip") |
| } |
| - t.Logf("the seal copied %d of %d objects", len(sealCopies), len(sw.replicaRel())) |
| + t.Logf("the seal copied %d of %d objects; %d were pre-copied and skipped", len(sealCopies), len(sw.replicaRel()), kept) |
| for _, k := range sealCopies { |
| rel := strings.TrimPrefix(k, sealPrefix+"/"+offHost+"/") |
| s, staged := preStaged[rel] |