@@ -10,6 +10,7 @@ import (
10
10
"testing"
11
11
12
12
"github.com/cockroachdb/pebble/sstable"
13
+ "github.com/cockroachdb/pebble/sstable/blob"
13
14
"github.com/cockroachdb/pebble/vfs"
14
15
"github.com/cockroachdb/pebble/vfs/atomicfs"
15
16
"github.com/stretchr/testify/require"
@@ -32,12 +33,13 @@ func TestFormatMajorVersionStableValues(t *testing.T) {
32
33
require .Equal (t , formatDeprecatedExperimentalValueSeparation , FormatMajorVersion (22 ))
33
34
require .Equal (t , formatFooterAttributes , FormatMajorVersion (23 ))
34
35
require .Equal (t , FormatValueSeparation , FormatMajorVersion (24 ))
35
-
36
- // When we add a new version, we should add a check for the new version in
37
- // addition to updating these expected values.
38
- require .Equal (t , FormatNewest , FormatMajorVersion (25 ))
39
- require .Equal (t , internalFormatNewest , FormatMajorVersion (25 ))
40
36
require .Equal (t , FormatExciseBoundsRecord , FormatMajorVersion (25 ))
37
+ require .Equal (t , FormatV2BlobFiles , FormatMajorVersion (26 ))
38
+
39
+ // When we add a new version, we should add a check for the new version above
40
+ // in addition to updating the expected values below.
41
+ require .Equal (t , FormatNewest , FormatMajorVersion (26 ))
42
+ require .Equal (t , internalFormatNewest , FormatMajorVersion (26 ))
41
43
}
42
44
43
45
func TestFormatMajorVersion_MigrationDefined (t * testing.T ) {
@@ -55,36 +57,18 @@ func TestRatchetFormat(t *testing.T) {
55
57
d , err := Open ("" , opts )
56
58
require .NoError (t , err )
57
59
require .NoError (t , d .Set ([]byte ("foo" ), []byte ("bar" ), Sync ))
58
- require .Equal (t , FormatFlushableIngest , d .FormatMajorVersion ())
59
- require .NoError (t , d .RatchetFormatMajorVersion (FormatPrePebblev1MarkedCompacted ))
60
- require .Equal (t , FormatPrePebblev1MarkedCompacted , d .FormatMajorVersion ())
61
- require .NoError (t , d .RatchetFormatMajorVersion (FormatDeleteSizedAndObsolete ))
62
- require .Equal (t , FormatDeleteSizedAndObsolete , d .FormatMajorVersion ())
63
- require .NoError (t , d .RatchetFormatMajorVersion (FormatVirtualSSTables ))
64
- require .Equal (t , FormatVirtualSSTables , d .FormatMajorVersion ())
65
- require .NoError (t , d .RatchetFormatMajorVersion (FormatSyntheticPrefixSuffix ))
66
- require .Equal (t , FormatSyntheticPrefixSuffix , d .FormatMajorVersion ())
67
- require .NoError (t , d .RatchetFormatMajorVersion (FormatFlushableIngestExcises ))
68
- require .Equal (t , FormatFlushableIngestExcises , d .FormatMajorVersion ())
69
- require .NoError (t , d .RatchetFormatMajorVersion (FormatColumnarBlocks ))
70
- require .Equal (t , FormatColumnarBlocks , d .FormatMajorVersion ())
71
- require .NoError (t , d .RatchetFormatMajorVersion (FormatWALSyncChunks ))
72
- require .Equal (t , FormatWALSyncChunks , d .FormatMajorVersion ())
73
- require .NoError (t , d .RatchetFormatMajorVersion (FormatTableFormatV6 ))
74
- require .Equal (t , FormatTableFormatV6 , d .FormatMajorVersion ())
75
- require .NoError (t , d .RatchetFormatMajorVersion (formatDeprecatedExperimentalValueSeparation ))
76
- require .Equal (t , formatDeprecatedExperimentalValueSeparation , d .FormatMajorVersion ())
77
- require .NoError (t , d .RatchetFormatMajorVersion (formatFooterAttributes ))
78
- require .Equal (t , formatFooterAttributes , d .FormatMajorVersion ())
79
- require .NoError (t , d .RatchetFormatMajorVersion (FormatValueSeparation ))
80
- require .Equal (t , FormatValueSeparation , d .FormatMajorVersion ())
81
- require .NoError (t , d .RatchetFormatMajorVersion (FormatExciseBoundsRecord ))
82
- require .Equal (t , FormatExciseBoundsRecord , d .FormatMajorVersion ())
60
+
61
+ // Ratchet through all supported versions.
62
+ require .Equal (t , FormatMinSupported , d .FormatMajorVersion ())
63
+ for v := FormatMinSupported + 1 ; v <= internalFormatNewest ; v ++ {
64
+ require .NoError (t , d .RatchetFormatMajorVersion (v ))
65
+ require .Equal (t , v , d .FormatMajorVersion ())
66
+ }
83
67
84
68
require .NoError (t , d .Close ())
85
69
86
70
// If we Open the database again, leaving the default format, the
87
- // database should Open using the persisted FormatNewest .
71
+ // database should Open using the persisted internalFormatNewest .
88
72
opts = & Options {FS : fs , Logger : testLogger {t }}
89
73
opts .WithFSDefaults ()
90
74
d , err = Open ("" , opts )
@@ -243,6 +227,7 @@ func TestFormatMajorVersions_TableFormat(t *testing.T) {
243
227
formatFooterAttributes : {sstable .TableFormatPebblev1 , sstable .TableFormatPebblev7 },
244
228
FormatValueSeparation : {sstable .TableFormatPebblev1 , sstable .TableFormatPebblev7 },
245
229
FormatExciseBoundsRecord : {sstable .TableFormatPebblev1 , sstable .TableFormatPebblev7 },
230
+ FormatV2BlobFiles : {sstable .TableFormatPebblev1 , sstable .TableFormatPebblev7 },
246
231
}
247
232
248
233
// Valid versions.
@@ -258,6 +243,29 @@ func TestFormatMajorVersions_TableFormat(t *testing.T) {
258
243
require .Panics (t , func () { _ = fmv .MinTableFormat () })
259
244
}
260
245
246
+ func TestFormatMajorVersions_BlobFileFormat (t * testing.T ) {
247
+ // NB: This test is intended to validate the mapping between every
248
+ // FormatMajorVersion and blob.FileFormat exhaustively. This serves as a
249
+ // sanity check that new versions have a corresponding mapping. The test
250
+ // fixture is intentionally verbose.
251
+
252
+ m := map [FormatMajorVersion ]blob.FileFormat {
253
+ FormatValueSeparation : blob .FileFormatV1 ,
254
+ FormatExciseBoundsRecord : blob .FileFormatV1 ,
255
+ FormatV2BlobFiles : blob .FileFormatV2 ,
256
+ }
257
+
258
+ // Valid versions.
259
+ for fmv := FormatValueSeparation ; fmv <= internalFormatNewest ; fmv ++ {
260
+ got := fmv .MaxBlobFileFormat ()
261
+ require .Equalf (t , m [fmv ], got , "got %s; want %s" , got , m [fmv ])
262
+ }
263
+
264
+ // Invalid versions.
265
+ require .Panics (t , func () { _ = (internalFormatNewest + 1 ).MaxBlobFileFormat () })
266
+ require .Panics (t , func () { _ = (FormatValueSeparation - 1 ).MaxBlobFileFormat () })
267
+ }
268
+
261
269
// TestFormatMajorVersions_ColumnarBlocks ensures that
262
270
// Experimental.EnableColumnarBlocks is respected on recent format major
263
271
// versions.
0 commit comments