Skip to content

Commit acd0334

Browse files
craig[bot]iskettaneh
andcommitted
Merge #146247
146247: kvserver: deflake TestLossQuorumCauseLeaderlessWatcherToSignalUnavailable r=iskettaneh a=iskettaneh This commit deflakes the test TestLossQuorumCauseLeaderlessWatcherToSignalUnavailable especially for epoch-based leases. It does so by making sure that there is a fully functional quorum before it introduce a temporary unavailability. This deflakes the test because the node that we haven't restarted is guaranteed to not be a learner, and therefore it can campaign and unquiesce the recently restarted node. Fixes: #146188 Release note: None Co-authored-by: Ibrahim Kettaneh <[email protected]>
2 parents 6ff26ae + 224863a commit acd0334

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pkg/kv/kvserver/client_replica_test.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2911,12 +2911,12 @@ func TestChangeReplicasGeneration(t *testing.T) {
29112911
assert.EqualValues(t, repl.Desc().Generation, oldGeneration+3, "\nold: %+v\nnew: %+v", oldDesc, newDesc)
29122912
}
29132913

2914-
// TestLossQuorumCauseLeaderlessWatcherToSignalUnavailable checks that if a range
2915-
// lost its quorum, the remaining replicas in that range will have their
2914+
// TestLossQuorumCauseLeaderlessWatcherToSignalUnavailable checks that if a
2915+
// range lost its quorum, the remaining replicas in that range will have their
29162916
// leaderlessWatcher indicate that the range is unavailable. Also, it checks
29172917
// that when the range regains quorum, the leaderlessWatcher will indicate that
29182918
// the range is available.
2919-
func TestLossQuorumCauseLeaderWatcherToSignalUnavailable(t *testing.T) {
2919+
func TestLossQuorumCauseLeaderlessWatcherToSignalUnavailable(t *testing.T) {
29202920
defer leaktest.AfterTest(t)()
29212921
defer log.Scope(t).Close(t)
29222922

@@ -2947,6 +2947,12 @@ func TestLossQuorumCauseLeaderWatcherToSignalUnavailable(t *testing.T) {
29472947
},
29482948
},
29492949
Knobs: base.TestingKnobs{
2950+
Store: &kvserver.StoreTestingKnobs{
2951+
// Make sure that we don't depend on the consistency queue
2952+
// running. It could cause replicas to attempt to acquire the
2953+
// lease, which might unintentionally unquiesce replicas. See #146188.
2954+
DisableConsistencyQueue: true,
2955+
},
29502956
Server: &server.TestingKnobs{
29512957
StickyVFSRegistry: stickyVFSRegistry,
29522958
},
@@ -2968,6 +2974,16 @@ func TestLossQuorumCauseLeaderWatcherToSignalUnavailable(t *testing.T) {
29682974
desc, err := tc.LookupRange(key)
29692975
require.NoError(t, err)
29702976

2977+
// Make sure that the range is up and functional.
2978+
// Make sure that there is a fully functioning quorum before it introduce a
2979+
// temporary unavailability. This deflakes the test especially for epoch
2980+
// leases because the node that we haven't restarted is guaranteed to not be a
2981+
// learner, and therefore it can campaign and unquiesce the recently restarted
2982+
// node.
2983+
_, pErr := kv.SendWrapped(context.Background(),
2984+
tc.GetFirstStoreFromServer(t, 0).TestSender(), putArgs(key, []byte("init")))
2985+
require.NoError(t, pErr.GoError())
2986+
29712987
// Randomly stop server index 0 or 1.
29722988
stoppedNodeInx := rand.Intn(2)
29732989
aliveNodeIdx := 1 - stoppedNodeInx

0 commit comments

Comments
 (0)