Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thorfour committed Feb 12, 2024
1 parent 8d7d330 commit f8115cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
17 changes: 14 additions & 3 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1456,9 +1456,9 @@ func TestDBRecover(t *testing.T) {
require.NoError(t, err)
snapshotTxns = append(snapshotTxns, tx)
}
expectedSnapshots := []uint64{2, 3}
expectedSnapshots := []uint64{3, 5}
if blockRotation {
expectedSnapshots = append(expectedSnapshots, 6)
expectedSnapshots = append(expectedSnapshots, 8)
}
require.Equal(t, expectedSnapshots, snapshotTxns)
return dir
Expand Down Expand Up @@ -2975,7 +2975,7 @@ func Test_DB_SnapshotNewerData(t *testing.T) {
}

// Get a snapshot tx
tx := db.beginRead()
tx, _, commit := db.begin()

// Insert another write, and force compaction
samples := dynparquet.GenerateTestSamples(3)
Expand All @@ -2986,7 +2986,18 @@ func Test_DB_SnapshotNewerData(t *testing.T) {
require.NoError(t, table.EnsureCompaction())

// Now perform the snapshot
db.Wait(tx - 1)
err = db.wal.Log(
tx,
&walpb.Record{
Entry: &walpb.Entry{
EntryType: &walpb.Entry_Snapshot_{Snapshot: &walpb.Entry_Snapshot{Tx: tx}},
},
},
)
require.NoError(t, err)
require.NoError(t, db.snapshotAtTX(ctx, tx, db.offlineSnapshotWriter(tx)))
commit()
require.NoError(t, db.wal.Truncate(tx))
time.Sleep(1 * time.Second) // wal flushes every 50ms

Expand Down
10 changes: 5 additions & 5 deletions index/lsm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func Test_LSM_Basic(t *testing.T) {
{Level: L1, MaxSize: 1024 * 1024 * 1024, Type: CompactionTypeParquetMemory, Compact: compactParts},
{Level: L2, MaxSize: 1024 * 1024 * 1024},
},
func(uint64) {},
func() uint64 { return math.MaxUint64 },
)
require.NoError(t, err)

Expand Down Expand Up @@ -131,7 +131,7 @@ func Test_LSM_DuplicateSentinel(t *testing.T) {
{Level: L1, MaxSize: 1024 * 1024 * 1024, Type: CompactionTypeParquetMemory, Compact: compactParts},
{Level: L2, MaxSize: 1024 * 1024 * 1024},
},
func(uint64) {},
func() uint64 { return math.MaxUint64 },
)
require.NoError(t, err)

Expand All @@ -155,7 +155,7 @@ func Test_LSM_Compaction(t *testing.T) {
{Level: L0, MaxSize: 1, Type: CompactionTypeParquetMemory, Compact: compactParts},
{Level: L1, MaxSize: 1024 * 1024 * 1024},
},
func(uint64) {},
func() uint64 { return math.MaxUint64 },
)
require.NoError(t, err)

Expand All @@ -178,7 +178,7 @@ func Test_LSM_CascadeCompaction(t *testing.T) {
{Level: 3, MaxSize: 2281, Type: CompactionTypeParquetMemory, Compact: compactParts},
{Level: 4, MaxSize: 2281},
},
func(uint64) {},
func() uint64 { return math.MaxUint64 },
)
require.NoError(t, err)

Expand Down Expand Up @@ -211,7 +211,7 @@ func Test_LSM_InOrderInsert(t *testing.T) {
{Level: L1, MaxSize: 1024 * 1024 * 1024, Type: CompactionTypeParquetMemory, Compact: compactParts},
{Level: L2, MaxSize: 1024 * 1024 * 1024},
},
func(uint64) {},
func() uint64 { return math.MaxUint64 },
)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func WriteSnapshot(ctx context.Context, tx uint64, db *DB, w io.Writer, offline
},
}

if err := block.Index().Snapshot(func(p parts.Part) error {
if err := block.Index().Snapshot(tx, func(p parts.Part) error {
granuleMeta := &snapshotpb.Granule{}
partMeta := &snapshotpb.Part{
StartOffset: int64(offW.offset),
Expand Down

0 comments on commit f8115cb

Please sign in to comment.