Skip to content

Commit 244df91

Browse files
derekcollisonMauriceVanVeen
authored andcommitted
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]>
1 parent 7b0b08c commit 244df91

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
@@ -6238,8 +6238,12 @@ func TestJetStreamClusterStreamResetOnExpirationDuringPeerDownAndRestartWithLead
62386238

62396239
// Wait for all messages to expire.
62406240
checkFor(t, 5*time.Second, time.Second, func() error {
6241-
si, err := js.StreamInfo("TEST")
6242-
require_NoError(t, err)
6241+
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
6242+
defer cancel()
6243+
si, err := js.StreamInfo("TEST", nats.Context(ctx))
6244+
if err != nil {
6245+
return err
6246+
}
62436247
if si.State.Msgs == 0 {
62446248
return nil
62456249
}
@@ -6277,9 +6281,11 @@ func TestJetStreamClusterStreamResetOnExpirationDuringPeerDownAndRestartWithLead
62776281
}
62786282

62796283
// Now move the leader there and double check, but above test is sufficient.
6280-
checkFor(t, 10*time.Second, 250*time.Millisecond, func() error {
6284+
checkFor(t, 30*time.Second, 250*time.Millisecond, func() error {
62816285
_, err = nc.Request(fmt.Sprintf(JSApiStreamLeaderStepDownT, "TEST"), nil, time.Second)
6282-
require_NoError(t, err)
6286+
if err != nil {
6287+
return err
6288+
}
62836289
c.waitOnStreamLeader("$G", "TEST")
62846290
if c.streamLeader("$G", "TEST") == nsl {
62856291
return nil

0 commit comments

Comments
 (0)