Fix flapper test where no messages to receive at end

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2020-05-28 13:22:32 -07:00
parent b51bae5bde
commit 625129f20a
2 changed files with 7 additions and 2 deletions

2
go.mod
View File

@@ -1,5 +1,7 @@
module github.com/nats-io/nats-server/v2
go 1.14
require (
github.com/minio/highwayhash v1.0.0
github.com/nats-io/jwt v0.3.3-0.20200519195258-f2bf5ce574c7

View File

@@ -2699,7 +2699,8 @@ func TestJetStreamSnapshots(t *testing.T) {
nc := clientConnectToServer(t, s)
defer nc.Close()
toSend := rand.Intn(100) + 1
// Make sure we send some as floor.
toSend := rand.Intn(200) + 22
for i := 1; i <= toSend; i++ {
msg := fmt.Sprintf("Hello World %d", i)
subj := subjects[rand.Intn(len(subjects))]
@@ -2716,7 +2717,7 @@ func TestJetStreamSnapshots(t *testing.T) {
t.Fatalf("Unexpected error: %v", err)
}
// Now grab some messages.
toReceive := rand.Intn(toSend) + 1
toReceive := rand.Intn(toSend/2) + 1
for r := 0; r < toReceive; r++ {
resp, err := nc.Request(o.RequestNextMsgSubject(), nil, time.Second)
if err != nil {
@@ -2728,6 +2729,8 @@ func TestJetStreamSnapshots(t *testing.T) {
}
obs = append(obs, obsi{o.Config(), toReceive})
}
nc.Flush()
// Snapshot state of the stream and consumers.
info := info{mset.Config(), mset.State(), obs}