Skip to content

Commit

Permalink
Cleanup the tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Nov 16, 2023
1 parent 79c80b6 commit 10abf89
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions jetstream/test/ordered_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1412,9 +1412,14 @@ func TestOrderedConsumerNextOrder(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

publishFailed := make(chan error, 1)

go func() {
for i := 0; i < 100_000; i++ {
js.Publish(ctx, "FOO.A", []byte(fmt.Sprintf("%d", 1)))
_, err := js.Publish(ctx, "FOO.A", []byte(fmt.Sprintf("%d", 1)))
if err != nil {
publishFailed <- err
}
}
}()

Expand All @@ -1429,12 +1434,16 @@ func TestOrderedConsumerNextOrder(t *testing.T) {

for i := 0; i < 100_000; i++ {

fmt.Printf("i: %d\n", i)
select {
case err := <-publishFailed:
t.Fatalf("Publish error: %v", err)
default:
}

msg, err := c.Next(jetstream.FetchMaxWait(5 * time.Second))
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
fmt.Println("got some message ", i)
meta, err := msg.Metadata()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
Expand Down

0 comments on commit 10abf89

Please sign in to comment.