From 4c299d102be3993611ef03dd5f95a8f2ed5396ce Mon Sep 17 00:00:00 2001 From: Arul Ajmani Date: Tue, 5 Mar 2024 18:43:22 -0500 Subject: [PATCH] kvclient: make TestTxnCommitterElideEndTxn realistic 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 --- pkg/kv/kvclient/kvcoord/txn_interceptor_committer_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/kv/kvclient/kvcoord/txn_interceptor_committer_test.go b/pkg/kv/kvclient/kvcoord/txn_interceptor_committer_test.go index e15cc0255eb9..b388777b7dbc 100644 --- a/pkg/kv/kvclient/kvcoord/txn_interceptor_committer_test.go +++ b/pkg/kv/kvclient/kvcoord/txn_interceptor_committer_test.go @@ -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) { @@ -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) {