diff --git a/seaweed-block/core/storage/chunk_cut_logging_test.go b/seaweed-block/core/storage/chunk_cut_logging_test.go index ab9a3558ec..555ccc6232 100644 --- a/seaweed-block/core/storage/chunk_cut_logging_test.go +++ b/seaweed-block/core/storage/chunk_cut_logging_test.go @@ -140,3 +140,35 @@ func TestCutTimingPendingRecoveryIsOnlyInTheAttemptTotal(t *testing.T) { } assertEveryHeadIsPrefixImage(t, remote, writes) } + +func TestAbortedCutLogsEachCompletedCompareAndUpload(t *testing.T) { + old, flags := log.Writer(), log.Flags() + t.Cleanup(func() { _ = logging.Configure("info"); log.SetOutput(old); log.SetFlags(flags) }) + _, _, layer, _ := precopyLayer(t, 1024, 5) + layer.cfg.UploadConcurrency = 1 + ctx, cancel := context.WithCancel(ctTimeout(t)) + defer cancel() + const n = 3 + compared := 0 + layer.testAfterCompareHook = func(uint64) { + compared++ + if compared == n { + cancel() + } + } + var out bytes.Buffer + log.SetOutput(&out) + _ = logging.Configure("info") + if _, err := layer.Cut(ctx); err == nil { + t.Fatal("cutoff attempt published") + } + if compared != n { + t.Fatalf("compared=%d want%d", compared, n) + } + line := out.String() + for _, field := range []string{"level=INFO", "noop=false", "candidates=5", "compared=3", "uploaded=3", "staged=0"} { + if !strings.Contains(line, field) { + t.Fatalf("lost completed work %s: %s", field, line) + } + } +}