Skip to content

Commit

Permalink
Reduce messages in chaos tests (#4229)
Browse files Browse the repository at this point in the history
It doesn't really appear as though, for what these tests are trying to
prove, that an excessively large number of messages is required. Instead
let's drop the count a little in the hope that they run a bit faster.

Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
derekcollison committed Jun 9, 2023
2 parents 81154c4 + 7de3568 commit 13b6e26
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions server/jetstream_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ func createStreamForConsumerChaosTest(t *testing.T, c *cluster, replicas, numMes
// Verify ordered delivery despite cluster-wide outages
func TestJetStreamChaosConsumerOrdered(t *testing.T) {

const numMessages = 30_000
const numMessages = 5_000
const numBatch = 500
const maxRetries = 100
const retryDelay = 500 * time.Millisecond
const fetchTimeout = 250 * time.Millisecond
Expand Down Expand Up @@ -407,7 +408,7 @@ func TestJetStreamChaosConsumerOrdered(t *testing.T) {
// Simulate application processing (and gives the monkey some time to brew chaos)
time.Sleep(10 * time.Millisecond)

if i%1000 == 0 {
if i%numBatch == 0 {
t.Logf("Consumed %d/%d", i, numMessages)
}
}
Expand All @@ -416,7 +417,8 @@ func TestJetStreamChaosConsumerOrdered(t *testing.T) {
// Verify ordered delivery despite cluster-wide outages
func TestJetStreamChaosConsumerAsync(t *testing.T) {

const numMessages = 30_000
const numMessages = 5_000
const numBatch = 500
const timeout = 30 * time.Second // No (new) messages for 30s => terminate
const maxRetries = 25
const retryDelay = 500 * time.Millisecond
Expand Down Expand Up @@ -480,7 +482,7 @@ func TestJetStreamChaosConsumerAsync(t *testing.T) {
timeoutTimer.Reset(1 * time.Second)
}

if received.count()%1000 == 0 {
if received.count()%numBatch == 0 {
t.Logf("Consumed %d/%d", received.count(), numMessages)
}

Expand Down Expand Up @@ -535,7 +537,8 @@ func TestJetStreamChaosConsumerAsync(t *testing.T) {
// The consumer connection is also periodically closed, and the consumer 'resumes' on a different one
func TestJetStreamChaosConsumerDurable(t *testing.T) {

const numMessages = 30_000
const numMessages = 5_000
const numBatch = 500
const timeout = 30 * time.Second // No (new) messages for 60s => terminate
const clusterSize = 3
const replicas = 3
Expand Down Expand Up @@ -703,7 +706,7 @@ func TestJetStreamChaosConsumerDurable(t *testing.T) {
}
}

if received.count()%1000 == 0 {
if received.count()%numBatch == 0 {
t.Logf("Consumed %d/%d, duplicate deliveries: %d", received.count(), numMessages, deliveryCount-received.count())
// Close connection and resume consuming on a different one
resetDurableConsumer()
Expand Down Expand Up @@ -740,7 +743,8 @@ func TestJetStreamChaosConsumerDurable(t *testing.T) {

func TestJetStreamChaosConsumerPull(t *testing.T) {

const numMessages = 10_000
const numMessages = 5_000
const numBatch = 500
const maxRetries = 100
const retryDelay = 500 * time.Millisecond
const fetchTimeout = 250 * time.Millisecond
Expand Down Expand Up @@ -845,7 +849,7 @@ func TestJetStreamChaosConsumerPull(t *testing.T) {
}
}

if !isDupe && received.count()%1000 == 0 {
if !isDupe && received.count()%numBatch == 0 {
t.Logf("Consumed %d/%d (duplicates: %d)", received.count(), numMessages, deliveredCount-received.count())
}
}
Expand Down

0 comments on commit 13b6e26

Please sign in to comment.