Skip to content

Commit

Permalink
kvserver: fix TestBadRequest
Browse files Browse the repository at this point in the history
Fixes #51795

This test was originally written when the test infra started up with a
single range. This commit updates the logic to work with any config.
To make the last error fire, we need to contain the delete span to
a single range that starts at KeyMin.

Release note: None
  • Loading branch information
lunevalex committed Feb 22, 2021
1 parent 23a4e63 commit 697fa61
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/kv/kvclient/kvcoord/dist_sender_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/kvclientutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand Down Expand Up @@ -1496,9 +1495,7 @@ func TestReverseScanWithSplitAndMerge(t *testing.T) {
func TestBadRequest(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
skip.WithIssue(t, 51795, "TODO(andreimatei): This last assertion in this test was broken by #33150. "+
"I suspect the reason is that there is no longer a single Range "+
"that spans [KeyMin, z), so we're not hitting the error.")

s, db := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.Background())
ctx := context.Background()
Expand All @@ -1520,8 +1517,13 @@ func TestBadRequest(t *testing.T) {
t.Fatalf("unexpected error on deletion on [x, a): %v", err)
}

if err := db.DelRange(ctx, "", "z"); !testutils.IsError(err, "must be greater than LocalMax") {
t.Fatalf("unexpected error on deletion on [KeyMin, z): %v", err)
// To make the last check fail we need to search the replica that starts at
// KeyMin i.e. typically it's Range(1).
store, err := s.GetStores().(*kvserver.Stores).GetStore(s.GetFirstStoreID())
require.NoError(t, err)
repl := store.LookupReplica(roachpb.RKeyMin)
if err := db.DelRange(ctx, "", repl.Desc().EndKey); !testutils.IsError(err, "must be greater than LocalMax") {
t.Fatalf("unexpected error on deletion on [KeyMin, %s): %v", repl.Desc().EndKey, err)
}
}

Expand Down

0 comments on commit 697fa61

Please sign in to comment.