Skip to content

Commit

Permalink
Fix flapper
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
  • Loading branch information
kozlovic committed May 27, 2020
1 parent 5fe5cac commit c8737f4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions test/sub_test.go
Expand Up @@ -1172,17 +1172,19 @@ func TestAsyncSubscriptionPendingDrain(t *testing.T) {
nc.Flush()

// Wait for all delivered.
for d, _ := sub.Delivered(); d != int64(total); d, _ = sub.Delivered() {
time.Sleep(10 * time.Millisecond)
}

m, b, _ := sub.Pending()
if m != 0 {
t.Fatalf("Expected msgs of 0, got %d", m)
}
if b != 0 {
t.Fatalf("Expected bytes of 0, got %d", b)
}
waitFor(t, 2*time.Second, 15*time.Millisecond, func() error {
if d, _ := sub.Delivered(); d != int64(total) {
return fmt.Errorf("Wrong delivered count: %v vs %v", d, total)
}
m, b, _ := sub.Pending()
if m != 0 {
return fmt.Errorf("Expected msgs of 0, got %d", m)
}
if b != 0 {
return fmt.Errorf("Expected bytes of 0, got %d", b)
}
return nil
})

sub.Unsubscribe()
if _, err := sub.Delivered(); err == nil {
Expand Down

0 comments on commit c8737f4

Please sign in to comment.