Skip to content

Commit

Permalink
testdata: regenerate db-stage-x at more recent format
Browse files Browse the repository at this point in the history
In preparation for deprecating all formats older than
`FormatFlushableIngest`, we regenerate these test databases at this
format. We replace the C++ program that used RocksDB with a Go program
which uses Pebble.
  • Loading branch information
RaduBerinde committed Dec 4, 2023
1 parent 51fca96 commit 785907b
Show file tree
Hide file tree
Showing 60 changed files with 449 additions and 2,236 deletions.
2 changes: 1 addition & 1 deletion internal/base/filenames_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestMustExist(t *testing.T) {
MustExist(fs, filename, &buf, err)
require.Equal(t, `000000.sst:
file does not exist
directory contains 10 files, 3 unknown, 1 tables, 1 logs, 1 manifests`, buf.buf.String())
directory contains 9 files, 2 unknown, 1 tables, 1 logs, 2 manifests`, buf.buf.String())
}

func TestRedactFileNum(t *testing.T) {
Expand Down
45 changes: 26 additions & 19 deletions internal/manifest/version_edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,19 @@ func TestVersionEditRoundTrip(t *testing.T) {
}

func TestVersionEditDecode(t *testing.T) {
// TODO(radu): these should be datadriven tests that output the encoded and
// decoded edits.
cmp := base.DefaultComparer.Compare
m := (&FileMetadata{
FileNum: 4,
Size: 986,
SmallestSeqNum: 3,
LargestSeqNum: 5,
Size: 709,
SmallestSeqNum: 12,
LargestSeqNum: 14,
CreationTime: 1701712644,
}).ExtendPointKeyBounds(
cmp,
base.MakeInternalKey([]byte("bar"), 5, base.InternalKeyKindDelete),
base.MakeInternalKey([]byte("foo"), 4, base.InternalKeyKindSet),
base.MakeInternalKey([]byte("bar"), 14, base.InternalKeyKindDelete),
base.MakeInternalKey([]byte("foo"), 13, base.InternalKeyKindSet),
)
m.InitPhysicalBacking()

Expand All @@ -272,34 +275,38 @@ func TestVersionEditDecode(t *testing.T) {
{
filename: "db-stage-1/MANIFEST-000001",
encodedEdits: []string{
"\x02\x00\x03\x02\x04\x00",
"\x01\x1aleveldb.BytewiseComparator\x03\x02\x04\x00",
"\x02\x02\x03\x03\x04\t",
},
edits: []VersionEdit{
{
NextFileNum: 2,
ComparerName: "leveldb.BytewiseComparator",
NextFileNum: 2,
},
{
MinUnflushedLogNum: 0x2,
NextFileNum: 0x3,
LastSeqNum: 0x9,
},
},
},
// db-stage-3 and db-stage-4 have the same manifest.
{
filename: "db-stage-3/MANIFEST-000005",
filename: "db-stage-3/MANIFEST-000006",
encodedEdits: []string{
"\x01\x1aleveldb.BytewiseComparator",
"\x02\x00",
"\x02\x04\t\x00\x03\x06\x04\x05d\x00\x04\xda\a\vbar" +
"\x00\x05\x00\x00\x00\x00\x00\x00\vfoo\x01\x04\x00" +
"\x00\x00\x00\x00\x00\x03\x05",
"\x01\x1aleveldb.BytewiseComparator\x02\x02\x03\a\x04\x00",
"\x02\x05\x03\x06\x04\x0eg\x00\x04\xc5\x05\vbar\x00\x0e\x00\x00\x00\x00\x00\x00\vfoo\x01\r\x00\x00\x00\x00\x00\x00\f\x0e\x06\x05\x84\xa6\xb8\xab\x06\x01",
},
edits: []VersionEdit{
{
ComparerName: "leveldb.BytewiseComparator",
ComparerName: "leveldb.BytewiseComparator",
MinUnflushedLogNum: 0x2,
NextFileNum: 0x7,
},
{},
{
MinUnflushedLogNum: 4,
ObsoletePrevLogNum: 0,
NextFileNum: 6,
LastSeqNum: 5,
MinUnflushedLogNum: 0x5,
NextFileNum: 0x6,
LastSeqNum: 0xe,
NewFiles: []NewFileEntry{
{
Level: 0,
Expand Down
13 changes: 5 additions & 8 deletions testdata/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
all: rebuild

.PHONY: rebuild
rebuild: make-db
rm -fr db-stage-1 && ./make-db 1
rm -fr db-stage-2 && ./make-db 2
rm -fr db-stage-3 && ./make-db 3
rm -fr db-stage-4 && ./make-db 4

make-db: make-db.cc
g++ -std=c++14 -o make-db make-db.cc -lrocksdb
rebuild: make-db.go
for stage in 1 2 3 4; do \
rm -fr db-stage-$$stage && \
go run make-db.go $$stage; \
done
Binary file added testdata/db-stage-1/000002.log
Binary file not shown.
2 changes: 1 addition & 1 deletion testdata/db-stage-1/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000001
MANIFEST-000000
1 change: 0 additions & 1 deletion testdata/db-stage-1/IDENTITY

This file was deleted.

178 changes: 0 additions & 178 deletions testdata/db-stage-1/LOG

This file was deleted.

Binary file modified testdata/db-stage-1/MANIFEST-000001
Binary file not shown.
48 changes: 48 additions & 0 deletions testdata/db-stage-1/OPTIONS-000003
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[Version]
pebble_version=0.1

[Options]
bytes_per_sync=524288
cache_size=8388608
cleaner=delete
compaction_debt_concurrency=1073741824
comparer=leveldb.BytewiseComparator
disable_wal=false
flush_delay_delete_range=0s
flush_delay_range_key=0s
flush_split_bytes=4194304
format_major_version=13
l0_compaction_concurrency=10
l0_compaction_file_threshold=500
l0_compaction_threshold=4
l0_stop_writes_threshold=12
lbase_max_bytes=67108864
max_concurrent_compactions=1
max_manifest_file_size=134217728
max_open_files=1000
mem_table_size=4194304
mem_table_stop_writes_threshold=2
min_deletion_rate=0
merger=pebble.concatenate
read_compaction_rate=16000
read_sampling_multiplier=16
strict_wal_tail=true
table_cache_shards=10
table_property_collectors=[]
validate_on_ingest=false
wal_dir=
wal_bytes_per_sync=0
max_writer_concurrency=0
force_writer_parallelism=false
secondary_cache_size_bytes=0
create_on_shared=0

[Level "0"]
block_restart_interval=16
block_size=4096
block_size_threshold=90
compression=Snappy
filter_policy=none
filter_type=table
index_block_size=4096
target_file_size=2097152
Loading

0 comments on commit 785907b

Please sign in to comment.