MCPcopy
hub / github.com/benbjohnson/litestream / TestCompactor_CompactClosesPipeOnWriteError

Function TestCompactor_CompactClosesPipeOnWriteError

compactor_test.go:91–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestCompactor_CompactClosesPipeOnWriteError(t *testing.T) {
92 client := newEarlyReturnCompactionClient(t.TempDir())
93 compactor := litestream.NewCompactor(client, slog.Default())
94
95 createTestLTXFile(t, client, 0, 1, 1)
96 createTestLTXFile(t, client, 0, 2, 2)
97 client.failWrites = true
98
99 before := countCompactorPipeWriters()
100 if _, err := compactor.Compact(context.Background(), 1); err == nil {
101 t.Fatal("expected error")
102 } else if !strings.Contains(err.Error(), "write ltx file: early write failure") {
103 t.Fatalf("unexpected error: %v", err)
104 }
105
106 deadline := time.NewTimer(time.Second)
107 defer deadline.Stop()
108 ticker := time.NewTicker(10 * time.Millisecond)
109 defer ticker.Stop()
110 for {
111 if got := countCompactorPipeWriters(); got <= before {
112 break
113 }
114 select {
115 case <-deadline.C:
116 t.Fatalf("compactor goroutine leaked: got %d, want <= %d", countCompactorPipeWriters(), before)
117 case <-ticker.C:
118 }
119 }
120}
121
122func TestCompactor_MaxLTXFileInfo(t *testing.T) {
123 t.Run("WithFiles", func(t *testing.T) {

Callers

nothing calls this directly

Calls 7

CompactMethod · 0.95
NewCompactorFunction · 0.92
StopMethod · 0.80
createTestLTXFileFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected