Skip to content

Commit

Permalink
kvclient: make TestTxnCommitterElideEndTxn realistic
Browse files Browse the repository at this point in the history
Previously, this test was constructing (and testing) an unrealistic
scenario. We should never be eliding EndTxn requests if there is a Put
in the batch; but, because we weren't correctly populating lock spans,
we ended up asserting that we were eliding the request. We now switch to
using a ScanRequest in here instead.

Epic: none

Release note: None
  • Loading branch information
arulajmani committed Mar 25, 2024
1 parent 7674256 commit 4c299d1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/kv/kvclient/kvcoord/txn_interceptor_committer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestTxnCommitterElideEndTxn(t *testing.T) {

txn := makeTxnProto()
keyA := roachpb.Key("a")
keyB := roachpb.Key("b")

// Test with both commits and rollbacks.
testutils.RunTrueAndFalse(t, "commit", func(t *testing.T, commit bool) {
Expand All @@ -65,7 +66,7 @@ func TestTxnCommitterElideEndTxn(t *testing.T) {
ba := &kvpb.BatchRequest{}
ba.Header = kvpb.Header{Txn: &txn}
ba.Add(&kvpb.GetRequest{RequestHeader: kvpb.RequestHeader{Key: keyA}})
ba.Add(&kvpb.PutRequest{RequestHeader: kvpb.RequestHeader{Key: keyA}})
ba.Add(&kvpb.ScanRequest{RequestHeader: kvpb.RequestHeader{Key: keyA, EndKey: keyB}})
ba.Add(&kvpb.EndTxnRequest{Commit: commit, LockSpans: nil})

mockSender.MockSend(func(ba *kvpb.BatchRequest) (*kvpb.BatchResponse, *kvpb.Error) {
Expand Down

0 comments on commit 4c299d1

Please sign in to comment.