@@ -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
12551250func TestCompactionOutputLevel (t * testing.T ) {
0 commit comments