Skip to content

Commit

Permalink
Merge pull request #3932 from nats-io/flapper2
Browse files Browse the repository at this point in the history
Fixed flapping test since we have two streams and order in slice not guaranteed.
  • Loading branch information
wallyqs committed Mar 1, 2023
2 parents ca19377 + deddf8f commit 4e3b983
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions server/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4181,7 +4181,7 @@ func TestMonitorJsz(t *testing.T) {
_, err = js.Publish("foo", nil)
require_NoError(t, err)
// Wait for mirror replication
time.Sleep(100 * time.Millisecond)
time.Sleep(200 * time.Millisecond)

monUrl1 := fmt.Sprintf("http://127.0.0.1:%d/jsz", 7501)
monUrl2 := fmt.Sprintf("http://127.0.0.1:%d/jsz", 5501)
Expand Down Expand Up @@ -4408,17 +4408,25 @@ func TestMonitorJsz(t *testing.T) {
if len(info.AccountDetails) != 1 {
t.Fatalf("expected account ACC to be returned by %s but got %v", url, info)
}
if len(info.AccountDetails[0].Streams[0].Consumer) == 0 {

// We will have two streams and order is not guaranteed. So grab the one we want.
var si StreamDetail
if info.AccountDetails[0].Streams[0].Name == "my-stream-replicated" {
si = info.AccountDetails[0].Streams[0]
} else {
si = info.AccountDetails[0].Streams[1]
}

if len(si.Consumer) == 0 {
t.Fatalf("expected consumers to be returned by %s but got %v", url, info)
}
if len(info.AccountDetails[0].Streams[0].ConsumerRaftGroups) == 0 {
if len(si.ConsumerRaftGroups) == 0 {
t.Fatalf("expected consumer raft groups to be returned by %s but got %v", url, info)
}
srgroup := info.AccountDetails[0].Streams[0].RaftGroup
if len(srgroup) == 0 {
if len(si.RaftGroup) == 0 {
t.Fatal("expected stream raft group info to be included")
}
crgroup := info.AccountDetails[0].Streams[0].ConsumerRaftGroups[0]
crgroup := si.ConsumerRaftGroups[0]
if crgroup.Name != "my-consumer-replicated" {
t.Fatalf("expected consumer name to be included in raft group info, got: %v", crgroup.Name)
}
Expand Down

0 comments on commit 4e3b983

Please sign in to comment.