Skip to content

Commit

Permalink
Merge #103724
Browse files Browse the repository at this point in the history
103724: kvnemesis: update outdated signatures or repro.go r=nvanbenschoten a=aliher1911

Signatures for Split/Merge/LeaseTransfer were out of date in generated knvemesis code. This made repro.go non compilable. This PR fixes strings used to generate repro code for test failures.

Epic: none

Release note: None

Co-authored-by: Oleg Afanasyev <[email protected]>
  • Loading branch information
craig[bot] and aliher1911 committed Jun 1, 2023
2 parents fdf0690 + 7a56aca commit 121a345
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
10 changes: 9 additions & 1 deletion pkg/kv/kvnemesis/applier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/concurrency/isolation"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
Expand All @@ -39,7 +40,11 @@ func TestApplier(t *testing.T) {
defer log.Scope(t).Close(t)

ctx := context.Background()
tc := testcluster.StartTestCluster(t, 1, base.TestClusterArgs{})
tc := testcluster.StartTestCluster(t, 1, base.TestClusterArgs{
// Disable replication to avoid AdminChangeReplicas complaining about
// replication queues being active.
ReplicationMode: base.ReplicationManual,
})
defer tc.Stopper().Stop(ctx)
db := tc.Server(0).DB()
sqlDB := tc.ServerConn(0)
Expand Down Expand Up @@ -188,6 +193,9 @@ func TestApplier(t *testing.T) {
{
"addsstable", step(addSSTable(sstFile.Data(), sstSpan, sstTS, sstValueHeader.KVNemesisSeq.Get(), true)),
},
{
"change-replicas", step(changeReplicas(k1, kvpb.ReplicationChange{ChangeType: roachpb.ADD_VOTER, Target: roachpb.ReplicationTarget{NodeID: 1, StoreID: 1}})),
},
}

w := echotest.NewWalker(t, datapathutils.TestDataPath(t, t.Name()))
Expand Down
12 changes: 9 additions & 3 deletions pkg/kv/kvnemesis/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (op AddSSTableOperation) format(w *strings.Builder, fctx formatCtx) {
}

func (op SplitOperation) format(w *strings.Builder, fctx formatCtx) {
fmt.Fprintf(w, `%s.AdminSplit(ctx, %s)`, fctx.receiver, fmtKey(op.Key))
fmt.Fprintf(w, `%s.AdminSplit(ctx, %s, hlc.MaxTimestamp)`, fctx.receiver, fmtKey(op.Key))
op.Result.format(w)
}

Expand All @@ -333,12 +333,18 @@ func (op BatchOperation) format(w *strings.Builder, fctx formatCtx) {
}

func (op ChangeReplicasOperation) format(w *strings.Builder, fctx formatCtx) {
fmt.Fprintf(w, `%s.AdminChangeReplicas(ctx, %s, %s)`, fctx.receiver, fmtKey(op.Key), op.Changes)
changes := make([]string, len(op.Changes))
for i, c := range op.Changes {
changes[i] = fmt.Sprintf("kvpb.ReplicationChange{ChangeType: roachpb.%s, Target: roachpb.ReplicationTarget{NodeID: %d, StoreID: %d}}",
c.ChangeType, c.Target.NodeID, c.Target.StoreID)
}
fmt.Fprintf(w, `%s.AdminChangeReplicas(ctx, %s, getRangeDesc(ctx, %s, %s), %s)`, fctx.receiver,
fmtKey(op.Key), fmtKey(op.Key), fctx.receiver, strings.Join(changes, ", "))
op.Result.format(w)
}

func (op TransferLeaseOperation) format(w *strings.Builder, fctx formatCtx) {
fmt.Fprintf(w, `%s.TransferLeaseOperation(ctx, %s, %d)`, fctx.receiver, fmtKey(op.Key), op.Target)
fmt.Fprintf(w, `%s.AdminTransferLease(ctx, %s, %d)`, fctx.receiver, fmtKey(op.Key), op.Target)
op.Result.format(w)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/kv/kvnemesis/testdata/TestApplier/change-replicas
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
echo
----
db0.AdminChangeReplicas(ctx, tk(1), getRangeDesc(ctx, tk(1), db0), kvpb.ReplicationChange{ChangeType: roachpb.ADD_VOTER, Target: roachpb.ReplicationTarget{NodeID: 1, StoreID: 1}}) // trying to add a voter to a store that already has a VOTER_FULL
2 changes: 1 addition & 1 deletion pkg/kv/kvnemesis/testdata/TestApplier/split
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
echo
----
db1.AdminSplit(ctx, tk(2)) // <nil>
db1.AdminSplit(ctx, tk(2), hlc.MaxTimestamp) // <nil>
2 changes: 1 addition & 1 deletion pkg/kv/kvnemesis/testdata/TestApplier/split-again
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
echo
----
db1.AdminSplit(ctx, tk(2)) // context canceled
db1.AdminSplit(ctx, tk(2), hlc.MaxTimestamp) // context canceled
2 changes: 1 addition & 1 deletion pkg/kv/kvnemesis/testdata/TestApplier/transfer
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
echo
----
db1.TransferLeaseOperation(ctx, tk(6), 1) // <nil>
db1.AdminTransferLease(ctx, tk(6), 1) // <nil>
2 changes: 1 addition & 1 deletion pkg/kv/kvnemesis/testdata/TestApplier/transfer-again
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
echo
----
db0.TransferLeaseOperation(ctx, tk(6), 1) // context canceled
db0.AdminTransferLease(ctx, tk(6), 1) // context canceled

0 comments on commit 121a345

Please sign in to comment.