Skip to content

Commit ba2a5d4

Browse files
committed
kvstorage: add dd test for RangeTombstone assert
Epic: none Release note: none
1 parent 6a65017 commit ba2a5d4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pkg/kv/kvserver/kvstorage/datadriven_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/cockroachdb/cockroach/pkg/clusterversion"
1717
"github.com/cockroachdb/cockroach/pkg/keys"
18+
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb"
1819
"github.com/cockroachdb/cockroach/pkg/raft/raftpb"
1920
"github.com/cockroachdb/cockroach/pkg/roachpb"
2021
"github.com/cockroachdb/cockroach/pkg/storage"
@@ -94,6 +95,14 @@ func (e *env) handleNewReplica(
9495
return desc
9596
}
9697

98+
func (e *env) handleRangeTombstone(
99+
t *testing.T, ctx context.Context, rangeID roachpb.RangeID, next roachpb.ReplicaID,
100+
) {
101+
require.NoError(t, MakeStateLoader(rangeID).SetRangeTombstone(
102+
ctx, e.eng, kvserverpb.RangeTombstone{NextReplicaID: next},
103+
))
104+
}
105+
97106
func TestDataDriven(t *testing.T) {
98107
defer leaktest.AfterTest(t)()
99108

@@ -146,6 +155,12 @@ func TestDataDriven(t *testing.T) {
146155
); desc != nil {
147156
fmt.Fprintln(&buf, desc)
148157
}
158+
159+
case "range-tombstone":
160+
rangeID := dd.ScanArg[roachpb.RangeID](t, d, "range-id")
161+
nextID := dd.ScanArg[roachpb.ReplicaID](t, d, "next-replica-id")
162+
e.handleRangeTombstone(t, ctx, rangeID, nextID)
163+
149164
case "load-and-reconcile":
150165
replicas, err := LoadAndReconcileReplicas(ctx, e.eng)
151166
if err != nil {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# A replica with a ReplicaID older than RangeTombstone should error.
2+
new-replica range-id=5 replica-id=50 k=a ek=c
3+
----
4+
r5:{a-c} [(n1,s1):50, next=51, gen=0]
5+
6+
range-tombstone range-id=5 next-replica-id=100
7+
----
8+
ok
9+
10+
load-and-reconcile trace=true
11+
----
12+
r5: RaftReplicaID 50 survived RangeTombstone {NextReplicaID:100}
13+
beginning range descriptor iteration
14+
range descriptor iteration done: 1 range descriptors, 0 intents, 0 tombstones; stats: <redacted>
15+
loaded state for 1/1 replicas
16+
loaded 1 replicas

0 commit comments

Comments
 (0)