Skip to content

Commit

Permalink
Report correct consumer count in paged list response (#4339)
Browse files Browse the repository at this point in the history
Previously the Total in paged responses would always equal the size of
the first response this would stall paged clients after the first page.

Now correctly sets the total so paging continues, improves the test to
verify these aspects of the report
  • Loading branch information
derekcollison committed Jul 27, 2023
2 parents 45beab1 + 60e67ff commit 865f12f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/jetstream_cluster.go
Expand Up @@ -6524,7 +6524,7 @@ LOOP:
})
}

resp.Total = len(resp.Consumers)
resp.Total = ocnt
resp.Limit = JSApiListLimit
resp.Offset = offset
resp.Missing = missingNames
Expand Down
10 changes: 10 additions & 0 deletions server/norace_test.go
Expand Up @@ -5387,6 +5387,9 @@ func TestNoRaceJetStreamClusterConsumerListPaging(t *testing.T) {
if resp.Limit < len(resp.Consumers) {
t.Fatalf("Expected total limited to %d but got %d", resp.Limit, len(resp.Consumers))
}
if resp.Total != numConsumers {
t.Fatalf("Invalid total response: expected %d got %d", numConsumers, resp.Total)
}
return resp.Consumers
}

Expand Down Expand Up @@ -5416,6 +5419,9 @@ func TestNoRaceJetStreamClusterConsumerListPaging(t *testing.T) {
if resp.Limit < len(resp.Consumers) {
t.Fatalf("Expected total limited to %d but got %d", resp.Limit, len(resp.Consumers))
}
if resp.Total != numConsumers {
t.Fatalf("Invalid total response: expected %d got %d", numConsumers, resp.Total)
}
return resp.Consumers
}

Expand All @@ -5432,6 +5438,10 @@ func TestNoRaceJetStreamClusterConsumerListPaging(t *testing.T) {
results[name] = true
}
}

if len(results) != numConsumers {
t.Fatalf("Received %d / %d consumers", len(results), numConsumers)
}
}

func TestNoRaceJetStreamFileStoreLargeKVAccessTiming(t *testing.T) {
Expand Down

0 comments on commit 865f12f

Please sign in to comment.