Skip to content

Commit 0449bb7

Browse files
De-flake StreamResetOnExpirationDuringPeerDownAndRestartWithLeaderChange (#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]>
2 parents 399bc01 + eb89b87 commit 0449bb7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

server/jetstream_cluster_2_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6319,8 +6319,12 @@ func TestJetStreamClusterStreamResetOnExpirationDuringPeerDownAndRestartWithLead
63196319

63206320
// Wait for all messages to expire.
63216321
checkFor(t, 5*time.Second, time.Second, func() error {
6322-
si, err := js.StreamInfo("TEST")
6323-
require_NoError(t, err)
6322+
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
6323+
defer cancel()
6324+
si, err := js.StreamInfo("TEST", nats.Context(ctx))
6325+
if err != nil {
6326+
return err
6327+
}
63246328
if si.State.Msgs == 0 {
63256329
return nil
63266330
}
@@ -6358,9 +6362,11 @@ func TestJetStreamClusterStreamResetOnExpirationDuringPeerDownAndRestartWithLead
63586362
}
63596363

63606364
// Now move the leader there and double check, but above test is sufficient.
6361-
checkFor(t, 10*time.Second, 250*time.Millisecond, func() error {
6365+
checkFor(t, 30*time.Second, 250*time.Millisecond, func() error {
63626366
_, err = nc.Request(fmt.Sprintf(JSApiStreamLeaderStepDownT, "TEST"), nil, time.Second)
6363-
require_NoError(t, err)
6367+
if err != nil {
6368+
return err
6369+
}
63646370
c.waitOnStreamLeader("$G", "TEST")
63656371
if c.streamLeader("$G", "TEST") == nsl {
63666372
return nil

0 commit comments

Comments
 (0)