diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index 46ba1d3f6..c5b980800 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -25,7 +25,7 @@ jobs: go-version: ${{ matrix.go-version }} - name: Run tests - run: go test -v -race ./... + run: go test -race ./... test-aws-mysql: runs-on: ubuntu-latest @@ -54,4 +54,4 @@ jobs: persist-credentials: false - name: Test with Go # Parallel tests are disabled for the MySQL test database to always be in a known state. - run: go test -p=1 -v -race ./storage/aws/... -is_mysql_test_optional=false + run: go test -p=1 -race ./storage/aws/... -is_mysql_test_optional=false diff --git a/internal/mirror/gateway/mirror_gateway_test.go b/internal/mirror/gateway/mirror_gateway_test.go index 0ff57af0b..191226da1 100644 --- a/internal/mirror/gateway/mirror_gateway_test.go +++ b/internal/mirror/gateway/mirror_gateway_test.go @@ -56,8 +56,7 @@ func TestGateway(t *testing.T) { } { t.Run(tc.name, func(t *testing.T) { opts := tessera.NewAppendOptions(). - WithCheckpointInterval(100 * time.Millisecond). - WithCheckpointRepublishInterval(100 * time.Millisecond) + WithCheckpointInterval(100 * time.Millisecond) testLog, shutdown := testonly.NewTestLog(t, opts) defer func() { diff --git a/storage/posix/files_test.go b/storage/posix/files_test.go index 2960d982a..9711de44c 100644 --- a/storage/posix/files_test.go +++ b/storage/posix/files_test.go @@ -38,6 +38,8 @@ import ( func TestGarbageCollect(t *testing.T) { ctx := t.Context() + appCtx, cancel := context.WithCancel(ctx) + defer cancel() batchSize := uint64(60000) integrateEvery := uint64(31343) @@ -59,7 +61,7 @@ func TestGarbageCollect(t *testing.T) { s: s, entriesPath: opts.EntriesPath(), } - appender, lr, err := s.newAppender(ctx, logStorage, opts) + appender, lr, err := s.newAppender(appCtx, logStorage, opts) if err != nil { t.Fatalf("Appender: %v", err) } @@ -113,6 +115,9 @@ func TestGarbageCollect(t *testing.T) { } } + // Stop background appender jobs before running fsck and TempDir cleanup. + cancel() + // And finally, for good measure, assert that all the resources implied by the log's checkpoint // are present. f := fsck.New(vk.Name(), vk, lr, defaultMerkleLeafHasher, fsck.Opts{N: 1}) @@ -149,6 +154,8 @@ func TestGarbageCollectOption(t *testing.T) { } { t.Run(test.name, func(t *testing.T) { ctx := t.Context() + appCtx, cancel := context.WithCancel(ctx) + defer cancel() s := &Storage{ cfg: Config{ @@ -172,7 +179,7 @@ func TestGarbageCollectOption(t *testing.T) { s: s, entriesPath: opts.EntriesPath(), } - appender, lr, err := s.newAppender(ctx, logStorage, opts) + appender, lr, err := s.newAppender(appCtx, logStorage, opts) if err != nil { t.Fatalf("Appender: %v", err) } @@ -240,6 +247,9 @@ func TestGarbageCollectOption(t *testing.T) { } } + // Stop background appender jobs before running fsck and TempDir cleanup. + cancel() + // And finally, for good measure, assert that all the resources implied by the log's checkpoint // are present. f := fsck.New(vk.Name(), vk, lr, defaultMerkleLeafHasher, fsck.Opts{N: 1}) diff --git a/testonly/testlog.go b/testonly/testlog.go index 06830eb25..88f852bb8 100644 --- a/testonly/testlog.go +++ b/testonly/testlog.go @@ -46,13 +46,16 @@ func NewTestLog(t *testing.T, opts *tessera.AppendOptions) (*TestLog, func(conte } root := t.TempDir() - driver, err := posix.New(t.Context(), posix.Config{Path: root}) + ctx, cancel := context.WithCancel(t.Context()) + t.Cleanup(cancel) + + driver, err := posix.New(ctx, posix.Config{Path: root}) if err != nil { t.Fatalf("posix.New: %v", err) } opts.WithCheckpointSigner(s) - a, shutdown, lr, err := tessera.NewAppender(t.Context(), driver, opts) + a, shutdown, lr, err := tessera.NewAppender(ctx, driver, opts) if err != nil { t.Fatalf("NewAppender: %v", err) } @@ -64,7 +67,10 @@ func NewTestLog(t *testing.T, opts *tessera.AppendOptions) (*TestLog, func(conte Appender: a, } - return r, shutdown + return r, func(sCtx context.Context) error { + defer cancel() + return shutdown(sCtx) + } } // TestLog represents an ephemeral POSIX log instance intended for use in tests.