From c60e7f971c4413d0005d4f08bd12e4f00e129b06 Mon Sep 17 00:00:00 2001 From: Geoff Greer Date: Fri, 22 May 2026 15:22:01 -0700 Subject: [PATCH] Remove journal_mode WAL pragmas from tests. We don't use WAL mode in production anymore, so use the same mode in tests. --- pkg/dotc1z/c1file_test.go | 17 ++++++------ pkg/dotc1z/diff_test.go | 26 +++++++++---------- pkg/dotc1z/grant_stats_groupby_test.go | 1 - pkg/dotc1z/grants_test.go | 4 +-- pkg/dotc1z/session_store_test.go | 22 ++++++++-------- pkg/dotc1z/sql_helpers_test.go | 8 +++--- pkg/dotc1z/sync_runs_test.go | 2 +- pkg/synccompactor/attached/attached_test.go | 1 - .../attached/comprehensive_test.go | 1 - pkg/synccompactor/attached/timestamp_test.go | 2 -- pkg/synccompactor/compactor_test.go | 3 --- 11 files changed, 39 insertions(+), 48 deletions(-) diff --git a/pkg/dotc1z/c1file_test.go b/pkg/dotc1z/c1file_test.go index c52278083..6510f1149 100644 --- a/pkg/dotc1z/c1file_test.go +++ b/pkg/dotc1z/c1file_test.go @@ -76,7 +76,6 @@ func TestC1Z(t *testing.T) { testFilePath := filepath.Join(c1zTests.workingDir, "test.c1z") var opts []C1ZOption - opts = append(opts, WithPragma("journal_mode", "WAL")) // Open file f, err := NewC1ZFile(ctx, testFilePath, opts...) @@ -164,7 +163,7 @@ func TestC1ZDecoder(t *testing.T) { testFilePath := filepath.Join(c1zTests.workingDir, "test-decoder.c1z") // Open file - f, err := NewC1ZFile(ctx, testFilePath, WithPragma("journal_mode", "WAL")) + f, err := NewC1ZFile(ctx, testFilePath) require.NoError(t, err) // Start a new sync @@ -268,7 +267,7 @@ func TestCurrentDBSizeBytes(t *testing.T) { ctx := t.Context() testFilePath := filepath.Join(c1zTests.workingDir, "test-currentdbsize.c1z") - f, err := NewC1ZFile(ctx, testFilePath, WithPragma("journal_mode", "WAL")) + f, err := NewC1ZFile(ctx, testFilePath) require.NoError(t, err) defer func() { _ = f.Close(ctx) }() @@ -354,7 +353,7 @@ func TestC1ZInvalidFile(t *testing.T) { err = f.Close() require.NoError(t, err) - _, err = NewC1ZFile(ctx, testFilePath, WithPragma("journal_mode", "WAL")) + _, err = NewC1ZFile(ctx, testFilePath) require.ErrorIs(t, err, ErrInvalidFile) } @@ -362,7 +361,7 @@ func TestC1ZStats(t *testing.T) { ctx := t.Context() testFilePath := filepath.Join(c1zTests.workingDir, "test-stats.c1z") - f, err := NewC1ZFile(ctx, testFilePath, WithPragma("journal_mode", "WAL")) + f, err := NewC1ZFile(ctx, testFilePath) require.NoError(t, err) syncID, err := f.StartNewSync(ctx, connectorstore.SyncTypeFull, "") @@ -413,7 +412,7 @@ func TestC1ZStatsPartialSync(t *testing.T) { ctx := t.Context() testFilePath := filepath.Join(c1zTests.workingDir, "test-stats-partial-sync.c1z") - f, err := NewC1ZFile(ctx, testFilePath, WithPragma("journal_mode", "WAL")) + f, err := NewC1ZFile(ctx, testFilePath) require.NoError(t, err) syncID, err := f.StartNewSync(ctx, connectorstore.SyncTypePartial, "") @@ -453,7 +452,7 @@ func TestC1ZStatsResourcesOnlySync(t *testing.T) { ctx := t.Context() testFilePath := filepath.Join(c1zTests.workingDir, "test-stats-resources-only-sync.c1z") - f, err := NewC1ZFile(ctx, testFilePath, WithPragma("journal_mode", "WAL")) + f, err := NewC1ZFile(ctx, testFilePath) require.NoError(t, err) syncID, err := f.StartNewSync(ctx, connectorstore.SyncTypeResourcesOnly, "") @@ -509,7 +508,7 @@ func TestC1ZGrantStatsSync(t *testing.T) { testFilePath := filepath.Join(c1zTests.workingDir, "test-grant-stats-sync.c1z") - f, err := NewC1ZFile(ctx, testFilePath, WithPragma("journal_mode", "WAL")) + f, err := NewC1ZFile(ctx, testFilePath) require.NoError(t, err) syncID, err := f.StartNewSync(ctx, connectorstore.SyncTypePartial, "") @@ -628,7 +627,7 @@ func TestC1ZCachedViewSyncRunInvalidation(t *testing.T) { ctx := t.Context() testFilePath := filepath.Join(c1zTests.workingDir, "test-cached-view-sync-invalidation.c1z") - f, err := NewC1ZFile(ctx, testFilePath, WithPragma("journal_mode", "WAL")) + f, err := NewC1ZFile(ctx, testFilePath) require.NoError(t, err) // Start first sync and add a resource diff --git a/pkg/dotc1z/diff_test.go b/pkg/dotc1z/diff_test.go index da1fff001..d7ca65162 100644 --- a/pkg/dotc1z/diff_test.go +++ b/pkg/dotc1z/diff_test.go @@ -19,7 +19,7 @@ func TestGenerateSyncDiff(t *testing.T) { filePath := filepath.Join(c1zTests.workingDir, "diff_additions.c1z") // Create the base C1Z file - syncFile, err := NewC1ZFile(ctx, filePath, WithPragma("journal_mode", "WAL")) + syncFile, err := NewC1ZFile(ctx, filePath) require.NoError(t, err) defer syncFile.Close(ctx) @@ -112,7 +112,7 @@ func TestGenerateSyncDiffFromFile_Additions(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} // Create the OLD file with one resource. // We're attaching this later, so don't use an exclusive lock. @@ -241,7 +241,7 @@ func TestGenerateSyncDiffFromFile_Deletions(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} // Create the OLD file with two resources oldOpts := append(slices.Clone(opts), WithPragma("locking_mode", "normal")) @@ -345,7 +345,7 @@ func TestGenerateSyncDiffFromFile_Modifications(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} // Create the OLD file with a resource oldOpts := append(slices.Clone(opts), WithPragma("locking_mode", "normal")) @@ -441,7 +441,7 @@ func TestGenerateSyncDiffFromFile_MixedChanges(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with resources A, B, C @@ -574,7 +574,7 @@ func TestGenerateSyncDiffFromFile_NoChanges(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with resource A @@ -668,7 +668,7 @@ func TestGenerateSyncDiffFromFile_EntitlementsOnly(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with entitlement A @@ -777,7 +777,7 @@ func TestGenerateSyncDiffFromFile_GrantsOnly(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with grant A @@ -910,7 +910,7 @@ func TestGenerateSyncDiffFromFile_EmptyBase(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with empty sync (no resources) @@ -1014,7 +1014,7 @@ func TestGenerateSyncDiffFromFile_EmptyNew(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with resources A and B @@ -1118,7 +1118,7 @@ func TestGenerateSyncDiffFromFile_EntitlementsDeletions(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with entitlements A and B @@ -1227,7 +1227,7 @@ func TestGenerateSyncDiffFromFile_EntitlementsModifications(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with entitlement A @@ -1325,7 +1325,7 @@ func TestGenerateSyncDiffFromFile_GrantsDeletions(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} resourceTypeID := testResourceType // Create OLD file with grants A and B diff --git a/pkg/dotc1z/grant_stats_groupby_test.go b/pkg/dotc1z/grant_stats_groupby_test.go index c3c96eccc..b859fad80 100644 --- a/pkg/dotc1z/grant_stats_groupby_test.go +++ b/pkg/dotc1z/grant_stats_groupby_test.go @@ -66,7 +66,6 @@ func runGrantStatsParityCase(t *testing.T, numResourceTypes, grantsPerSync, numS testFilePath := filepath.Join(tempDir, "parity.c1z") f, err := NewC1ZFile(ctx, testFilePath, WithTmpDir(tempDir), - WithPragma("journal_mode", "WAL"), ) require.NoError(t, err) t.Cleanup(func() { _ = f.Close(ctx) }) diff --git a/pkg/dotc1z/grants_test.go b/pkg/dotc1z/grants_test.go index f620d1a18..258ba2a36 100644 --- a/pkg/dotc1z/grants_test.go +++ b/pkg/dotc1z/grants_test.go @@ -262,7 +262,7 @@ func TestDiffDetectsExpansionAnnotationChange(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} groupRT := v2.ResourceType_builder{Id: "group", DisplayName: "Group"}.Build() userRT := v2.ResourceType_builder{Id: "user", DisplayName: "User"}.Build() @@ -354,7 +354,7 @@ func TestDiffDetectsDataOnlyChange(t *testing.T) { defer os.Remove(oldPath) defer os.Remove(newPath) - opts := []C1ZOption{WithPragma("journal_mode", "WAL")} + opts := []C1ZOption{} groupRT := v2.ResourceType_builder{Id: "group", DisplayName: "Group"}.Build() userRT := v2.ResourceType_builder{Id: "user", DisplayName: "User"}.Build() diff --git a/pkg/dotc1z/session_store_test.go b/pkg/dotc1z/session_store_test.go index 97d8ff8d1..b3c37c969 100644 --- a/pkg/dotc1z/session_store_test.go +++ b/pkg/dotc1z/session_store_test.go @@ -18,7 +18,7 @@ func TestC1FileSessionStore_Get(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -76,7 +76,7 @@ func TestC1FileSessionStore_Set(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -144,7 +144,7 @@ func TestC1FileSessionStore_GetMany(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -473,7 +473,7 @@ func TestC1FileSessionStore_SetMany(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -554,7 +554,7 @@ func TestC1FileSessionStore_Delete(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -625,7 +625,7 @@ func TestC1FileSessionStore_Clear(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -766,7 +766,7 @@ func TestC1FileSessionStore_GetAll(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -1742,7 +1742,7 @@ func TestC1FileSessionStore_Isolation(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -1809,7 +1809,7 @@ func TestC1FileSessionStore_ConcurrentAccess(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL"), WithPragma("main.locking_mode", "NORMAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("main.locking_mode", "NORMAL")) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -1862,7 +1862,7 @@ func TestC1FileSessionStore_ErrorHandling(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) @@ -1894,7 +1894,7 @@ func TestC1FileSessionStore_Performance(t *testing.T) { ctx := t.Context() tempDir := filepath.Join(t.TempDir(), "test-session.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer c1zFile.Close(ctx) diff --git a/pkg/dotc1z/sql_helpers_test.go b/pkg/dotc1z/sql_helpers_test.go index b32cccd2c..63106d226 100644 --- a/pkg/dotc1z/sql_helpers_test.go +++ b/pkg/dotc1z/sql_helpers_test.go @@ -58,7 +58,7 @@ func TestPutResources(t *testing.T) { tempDir := filepath.Join(t.TempDir(), "test.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) syncId, err := c1zFile.StartNewSync(ctx, connectorstore.SyncTypeFull, "") @@ -94,7 +94,7 @@ func TestListResources(t *testing.T) { tempDir := filepath.Join(t.TempDir(), "test.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer func() { err := c1zFile.Close(ctx) @@ -183,7 +183,7 @@ func TestListResourcesWithParentFilter(t *testing.T) { tempDir := filepath.Join(t.TempDir(), "test.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(t, err) defer func() { err := c1zFile.Close(ctx) @@ -361,7 +361,7 @@ func BenchmarkPutResources(b *testing.B) { tempDir := filepath.Join(b.TempDir(), "test.c1z") - c1zFile, err := NewC1ZFile(ctx, tempDir, WithPragma("journal_mode", "WAL")) + c1zFile, err := NewC1ZFile(ctx, tempDir) require.NoError(b, err) _, err = c1zFile.StartNewSync(ctx, connectorstore.SyncTypeFull, "") diff --git a/pkg/dotc1z/sync_runs_test.go b/pkg/dotc1z/sync_runs_test.go index c64a5e50c..b296fc435 100644 --- a/pkg/dotc1z/sync_runs_test.go +++ b/pkg/dotc1z/sync_runs_test.go @@ -63,7 +63,7 @@ func TestCleanupVacuumWAL(t *testing.T) { testFilePath := filepath.Join(tmpDir, "test.c1z") - f, err := dotc1z.NewC1ZFile(ctx, testFilePath, dotc1z.WithPragma("journal_mode", "WAL")) + f, err := dotc1z.NewC1ZFile(ctx, testFilePath) require.NoError(t, err) _, err = c1ztest.CreateTestSync(ctx, t, f, c1ztest.C1ZCounts{ diff --git a/pkg/synccompactor/attached/attached_test.go b/pkg/synccompactor/attached/attached_test.go index a1c778325..b823c73f0 100644 --- a/pkg/synccompactor/attached/attached_test.go +++ b/pkg/synccompactor/attached/attached_test.go @@ -244,7 +244,6 @@ func TestAttachedCompactorDoesNotOperateOnDiffSyncTypes(t *testing.T) { tmpDir := t.TempDir() opts := []dotc1z.C1ZOption{ - dotc1z.WithPragma("journal_mode", "WAL"), dotc1z.WithTmpDir(tmpDir), } diff --git a/pkg/synccompactor/attached/comprehensive_test.go b/pkg/synccompactor/attached/comprehensive_test.go index 5541a2b5a..f3c4539ac 100644 --- a/pkg/synccompactor/attached/comprehensive_test.go +++ b/pkg/synccompactor/attached/comprehensive_test.go @@ -332,7 +332,6 @@ func TestCompactionPreservesGrantExpansionColumns(t *testing.T) { tmpDir := t.TempDir() opts := []dotc1z.C1ZOption{ - dotc1z.WithPragma("journal_mode", "WAL"), dotc1z.WithTmpDir(tmpDir), } diff --git a/pkg/synccompactor/attached/timestamp_test.go b/pkg/synccompactor/attached/timestamp_test.go index e621d115a..7ca1d7278 100644 --- a/pkg/synccompactor/attached/timestamp_test.go +++ b/pkg/synccompactor/attached/timestamp_test.go @@ -25,7 +25,6 @@ func TestDiscoveredAtMergeLogic(t *testing.T) { appliedFile := filepath.Join(tmpDir, "applied.c1z") opts := []dotc1z.C1ZOption{ - dotc1z.WithPragma("journal_mode", "WAL"), dotc1z.WithTmpDir(tmpDir), } @@ -104,7 +103,6 @@ func TestDiscoveredAtMergeLogic(t *testing.T) { appliedFile := filepath.Join(tmpDir, "applied.c1z") opts := []dotc1z.C1ZOption{ - dotc1z.WithPragma("journal_mode", "WAL"), dotc1z.WithTmpDir(tmpDir), } diff --git a/pkg/synccompactor/compactor_test.go b/pkg/synccompactor/compactor_test.go index 3f02cf3eb..6c8f069f4 100644 --- a/pkg/synccompactor/compactor_test.go +++ b/pkg/synccompactor/compactor_test.go @@ -55,7 +55,6 @@ func TestAttachedCompactorWithTmpDir(t *testing.T) { func runCompactorTest(t *testing.T, ctx context.Context, inputSyncsDir string, createCompactor func([]*CompactableSync) (*Compactor, func() error, error)) { opts := []dotc1z.C1ZOption{ - dotc1z.WithPragma("journal_mode", "WAL"), dotc1z.WithDecoderOptions(dotc1z.WithDecoderConcurrency(-1)), } @@ -854,7 +853,6 @@ func runSyncTypeTest( expectedSyncType connectorstore.SyncType, ) { opts := []dotc1z.C1ZOption{ - dotc1z.WithPragma("journal_mode", "WAL"), dotc1z.WithDecoderOptions(dotc1z.WithDecoderConcurrency(-1)), } @@ -906,7 +904,6 @@ func TestAttachedCompactorFailsWithNoFullSyncInBase(t *testing.T) { appliedFile := filepath.Join(outputDir, "applied.c1z") opts := []dotc1z.C1ZOption{ - dotc1z.WithPragma("journal_mode", "WAL"), dotc1z.WithTmpDir(tmpDir), }