Skip to content

Commit 87d5d1f

Browse files
committed
db: rename TestManualCompaction, organize datadriven files
Over time TestManualCompaction has become a more general test of compaction mechanics in general. This commit renames the test to TestCompaction (renaming the previously-named TestCompaction to the more apt TestAutomaticFlush). It also moves the test's various datadriven files into a common testdata/compaction directory and uses datadriven.Walk to ensure we don't accumulate unused test files like those deleted in the previous commit.
1 parent 27aee9b commit 87d5d1f

File tree

8 files changed

+23
-28
lines changed

8 files changed

+23
-28
lines changed

compaction_test.go

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ func TestPickCompaction(t *testing.T) {
552552
}
553553
}
554554

555-
func TestCompaction(t *testing.T) {
555+
func TestAutomaticFlush(t *testing.T) {
556556
const memTableSize = 10000
557557
// Tuned so that 2 values can reside in the memtable before a flush, but a
558558
// 3rd value will cause a flush. Needs to account for the max skiplist node
@@ -854,7 +854,9 @@ func TestValidateVersionEdit(t *testing.T) {
854854
}
855855
}
856856

857-
func TestManualCompaction(t *testing.T) {
857+
// TestCompaction tests compaction mechanics. It is a datadriven test, with
858+
// multiple datadriven test files in the testdata/compaction directory.
859+
func TestCompaction(t *testing.T) {
858860
var mem vfs.FS
859861
var d *DB
860862
defer func() {
@@ -1200,56 +1202,49 @@ func TestManualCompaction(t *testing.T) {
12001202
})
12011203
}
12021204

1203-
testCases := []struct {
1204-
testData string
1205+
type testConfig struct {
12051206
minVersion FormatMajorVersion // inclusive, FormatMinSupported if unspecified.
12061207
maxVersion FormatMajorVersion // inclusive, internalFormatNewest if unspecified.
12071208
verbose bool
1208-
}{
1209-
{
1210-
testData: "testdata/singledel_manual_compaction_set_with_del",
1211-
},
1212-
{
1213-
testData: "testdata/manual_compaction_range_keys",
1214-
verbose: true,
1215-
},
1216-
{
1217-
testData: "testdata/manual_compaction_file_boundaries_delsized",
1209+
}
1210+
testConfigs := map[string]testConfig{
1211+
"singledel_set_with_del": {},
1212+
"range_keys": {verbose: true},
1213+
"file_boundaries_delsized": {
12181214
minVersion: FormatDeleteSizedAndObsolete,
12191215
maxVersion: FormatFlushableIngestExcises,
12201216
},
1221-
{
1222-
testData: "testdata/manual_compaction_set_with_del_sstable_Pebblev4",
1217+
"set_with_del_sstable_Pebblev4": {
12231218
minVersion: FormatDeleteSizedAndObsolete,
12241219
maxVersion: FormatFlushableIngestExcises,
12251220
},
1226-
{
1227-
testData: "testdata/manual_compaction_multilevel",
1228-
},
1229-
{
1230-
testData: "testdata/manual_compaction_set_with_del_sstable_Pebblev5",
1221+
"multilevel": {},
1222+
"set_with_del_sstable_Pebblev5": {
12311223
minVersion: FormatColumnarBlocks,
12321224
maxVersion: FormatColumnarBlocks,
12331225
},
1234-
{
1235-
testData: "testdata/manual_compaction_set_with_del_sstable_Pebblev6",
1226+
"set_with_del_sstable_Pebblev6": {
12361227
minVersion: FormatTableFormatV6,
12371228
maxVersion: FormatTableFormatV6,
12381229
},
12391230
}
1240-
1241-
for _, tc := range testCases {
1242-
t.Run(tc.testData, func(t *testing.T) {
1231+
datadriven.Walk(t, "testdata/compaction", func(t *testing.T, path string) {
1232+
filename := filepath.Base(path)
1233+
tc, ok := testConfigs[filename]
1234+
if !ok {
1235+
t.Fatalf("unknown test config: %s", filename)
1236+
}
1237+
t.Run(filename, func(t *testing.T) {
12431238
minVersion, maxVersion := tc.minVersion, tc.maxVersion
12441239
if minVersion == 0 {
12451240
minVersion = FormatMinSupported
12461241
}
12471242
if maxVersion == 0 {
12481243
maxVersion = internalFormatNewest
12491244
}
1250-
runTest(t, tc.testData, minVersion, maxVersion, tc.verbose)
1245+
runTest(t, path, minVersion, maxVersion, tc.verbose)
12511246
})
1252-
}
1247+
})
12531248
}
12541249

12551250
func TestCompactionOutputLevel(t *testing.T) {
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)