Skip to content

Commit 14f7727

Browse files
committed
tests: use colon separator for KVs
The vast majority of tests that specify a KV use the `key:value` format. The parsing code also supports using a `=` separator and a handful of tests use that format. For the sake of consistency, remove this alternate format and fix up the relevant tests.
1 parent ae56f6d commit 14f7727

File tree

7 files changed

+126
-124
lines changed

7 files changed

+126
-124
lines changed

replay/testdata/corpus/simple_ingest

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ build:
1212
marker.manifest.000001.MANIFEST-000001
1313

1414
build-sst foo.sst
15-
a#0,SET = a
16-
b#0,SET = byaya
17-
c#0,SET = cyuumi
18-
d#0,SET = d
15+
a#0,SET:a
16+
b#0,SET:byaya
17+
c#0,SET:cyuumi
18+
d#0,SET:d
1919
----
2020

2121
ingest foo.sst
2222
----
2323
ingested
2424

2525
build-sst f.sst
26-
p#0,SET = p
27-
q#0,SET = q
26+
p#0,SET:p
27+
q#0,SET:q
2828
----
2929

3030
ingest-and-excise f.sst excise=a-d
@@ -64,16 +64,16 @@ simple_ingest/checkpoint:
6464
marker.manifest.000001.MANIFEST-000001
6565

6666
build-sst loo.sst
67-
x#0,SET = x
68-
y#0,SET = y
67+
x#0,SET:x
68+
y#0,SET:y
6969
----
7070

7171
ingest loo.sst
7272
----
7373
ingested
7474

7575
build-sst l.sst
76-
z#0,SET = z
76+
z#0,SET:z
7777
----
7878

7979
ingest-and-excise l.sst excise=d-p

sstable/test_utils.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,25 @@ func (kv ParsedKVOrSpan) String() string {
130130
return fmt.Sprintf("%s%s = blob:%s attr=%d", prefix, kv.Key, kv.BlobHandle, kv.Attr)
131131
}
132132

133-
// ParseTestKVsAndSpans parses a multi-line string that defines SSTable contents.
133+
// ParseTestKVsAndSpans parses a multi-line string that defines SSTable
134+
// contents.
134135
//
135-
// The blobtest.Values argument can be nil if there are no blob references in the input.
136+
// The blobtest.Values argument can be nil if there are no blob references in
137+
// the input.
136138
//
137139
// Each input line can be either a key-value pair or a key spans Sample input
138140
// showing the format:
139141
//
140-
// a#1,SET = a
141-
// force-obsolete: d#2,SET = d
142-
// f#3,SET = blob{fileNum=1 blockNum=2 offset=110 valueLen=200}attr=7
142+
// a#1,SET:a
143+
// force-obsolete: d#2,SET:d
144+
// f#3,SET:blob{fileNum=1 blockNum=2 offset=110 valueLen=200}attr=7
143145
// Span: d-e:{(#4,RANGEDEL)}
144146
// Span: a-d:{(#11,RANGEKEYSET,@10,foo)}
145147
// Span: g-l:{(#5,RANGEDEL)}
146148
// Span: y-z:{(#12,RANGEKEYSET,@11,foo)}
147149
//
148-
// Note that the older KV format "<user-key>.<kind>.<seq-num> : <value>" is also supported
149-
// (for now).
150+
// Note that the older key format "<user-key>.<kind>.<seq-num>" is also
151+
// supported (for now).
150152
func ParseTestKVsAndSpans(input string, bv *blobtest.Values) (_ []ParsedKVOrSpan, err error) {
151153
defer func() {
152154
if r := recover(); r != nil {
@@ -163,10 +165,10 @@ func ParseTestKVsAndSpans(input string, bv *blobtest.Values) (_ []ParsedKVOrSpan
163165

164166
var kv ParsedKVOrSpan
165167
line, kv.ForceObsolete = strings.CutPrefix(line, "force-obsolete:")
166-
// Cut the key at the first ":" or "=".
167-
sepIdx := strings.IndexAny(line, "=:")
168+
// Cut the key at the first ":".
169+
sepIdx := strings.Index(line, ":")
168170
if sepIdx == -1 {
169-
return nil, errors.Newf("KV format is [force-obsolete:] <key>=<value> (or <key>:<value>): %q", line)
171+
return nil, errors.Newf("KV format is \"[force-obsolete:] <key>:<value>\": %q", line)
170172
}
171173
keyStr := strings.TrimSpace(line[:sepIdx])
172174
valStr := strings.TrimSpace(line[sepIdx+1:])

testdata/compaction_corruption

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build-remote file-not-there
2-
d#0,SET = dvalue
3-
q#0,SET = qvalue
4-
w#0,SET = wvalue
2+
d#0,SET:dvalue
3+
q#0,SET:qvalue
4+
w#0,SET:wvalue
55
----
66

77
ingest-external
@@ -31,9 +31,9 @@ wait-for-no-external-files workload=(d,w)
3131
----
3232

3333
build-remote file2-not-there
34-
a#0,SET = avalue
35-
u#0,SET = uvalue
36-
z#0,SET = zvalue
34+
a#0,SET:avalue
35+
u#0,SET:uvalue
36+
z#0,SET:zvalue
3737
----
3838

3939
ingest-external

testdata/disk_usage

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ total: 1358, remote: 0, external: 0
9292

9393
# Test with remote files and external files
9494
build-remote ext2 block-size=10 index-block-size=10
95-
k#0,SET = foo
96-
l#0,SET = foo
97-
m#0,SET = foo
98-
n#0,SET = foo
99-
o#0,SET = foo
95+
k#0,SET:foo
96+
l#0,SET:foo
97+
m#0,SET:foo
98+
n#0,SET:foo
99+
o#0,SET:foo
100100
----
101101

102102
estimate-disk-usage-by-backing-type a z

testdata/excise

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,9 @@ L6:
737737
# We set the block size to prevent randomization of block sizes (which affects
738738
# the size).
739739
build-remote remote1 block-size=1024 index-block-size=1024
740-
g#0,SET = foo
741-
h#0,SET = bar
742-
i#0,SET = foobar
740+
g#0,SET:foo
741+
h#0,SET:bar
742+
i#0,SET:foobar
743743
----
744744

745745
ingest-external
@@ -776,9 +776,9 @@ L6:
776776
# Non-local tables are excised without data access.
777777

778778
build-remote remote2
779-
u#0,SET = foo
780-
v#0,SET = bar
781-
w#0,SET = foobar
779+
u#0,SET:foo
780+
v#0,SET:bar
781+
w#0,SET:foobar
782782
----
783783

784784
ingest-external

testdata/excise_bounds

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
build-sst
2-
b#1,SET = b
3-
c#1,SET = c
4-
d#1,SET = d
5-
e#1,SET = e
2+
b#1,SET:b
3+
c#1,SET:c
4+
d#1,SET:d
5+
e#1,SET:e
66
----
77
Bounds:
88
overall: b#1,SET - e#1,SET
@@ -135,9 +135,9 @@ Right table bounds (loose):
135135

136136
# Test with a RANGEDEL.
137137
build-sst
138-
b#1,SET = b
139-
cc#1,SET = cc
140-
e#1,SET = e
138+
b#1,SET:b
139+
cc#1,SET:cc
140+
e#1,SET:e
141141
Span: c-d:{(#2,RANGEDEL)}
142142
----
143143
Bounds:
@@ -198,9 +198,9 @@ Left table bounds (loose):
198198
# Test with range keys.
199199

200200
build-sst
201-
b#1,SET = b
202-
cc#1,SET = cc
203-
e#1,SET = e
201+
b#1,SET:b
202+
cc#1,SET:cc
203+
e#1,SET:e
204204
Span: c-d:{(#2,RANGEKEYSET,@10,foo)}
205205
----
206206
Bounds:

0 commit comments

Comments
 (0)