Skip to content

Commit

Permalink
De-flake StreamResetOnExpirationDuringPeerDownAndRestartWithLeaderCha…
Browse files Browse the repository at this point in the history
…nge (#6332)

Calling `require_NoError` in a `checkFor` immediately fails the test and
doesn't allow for retries. Also up the max timeout when doing stepdowns,
as that might sometimes take longer as well.

Signed-off-by: Maurice van Veen <[email protected]>
  • Loading branch information
derekcollison authored Jan 6, 2025
2 parents 399bc01 + eb89b87 commit 0449bb7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions server/jetstream_cluster_2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6319,8 +6319,12 @@ func TestJetStreamClusterStreamResetOnExpirationDuringPeerDownAndRestartWithLead

// Wait for all messages to expire.
checkFor(t, 5*time.Second, time.Second, func() error {
si, err := js.StreamInfo("TEST")
require_NoError(t, err)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
si, err := js.StreamInfo("TEST", nats.Context(ctx))
if err != nil {
return err
}
if si.State.Msgs == 0 {
return nil
}
Expand Down Expand Up @@ -6358,9 +6362,11 @@ func TestJetStreamClusterStreamResetOnExpirationDuringPeerDownAndRestartWithLead
}

// Now move the leader there and double check, but above test is sufficient.
checkFor(t, 10*time.Second, 250*time.Millisecond, func() error {
checkFor(t, 30*time.Second, 250*time.Millisecond, func() error {
_, err = nc.Request(fmt.Sprintf(JSApiStreamLeaderStepDownT, "TEST"), nil, time.Second)
require_NoError(t, err)
if err != nil {
return err
}
c.waitOnStreamLeader("$G", "TEST")
if c.streamLeader("$G", "TEST") == nsl {
return nil
Expand Down

0 comments on commit 0449bb7

Please sign in to comment.