Skip to content

Commit

Permalink
Adjust test timeouts for error visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdnk committed Oct 24, 2024
1 parent cf36b16 commit bbd92e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/configs/.rr-sqs-error-visibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
wait_time_seconds: 0
queue: default-error-timeout
retain_failed_jobs: true
error_visibility_timeout: 90 # takes ~60s to get consistent metadata from queue for test
error_visibility_timeout: 120 # takes ~60s to get consistent metadata from queue for test, so we need a long timeout
12 changes: 6 additions & 6 deletions tests/jobs_sqs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,21 +688,21 @@ func TestSQSErrorVisibilityTimeout(t *testing.T) {
// Stop consuming messages
t.Run("PausePipeline", helpers.PausePipelines(address, pipe))

// Sleep for 70 seconds; wait for queue metadata to update (10+70)
// This takes at least 60 seconds.
// Sleep for another 110 seconds; wait for queue metadata to update (10+110 = 120s)
// Updating queue metadata takes "at least 60 seconds", so 120s is hopefully always enough.
// See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_GetQueueAttributes.html
time.Sleep(time.Second * 70)
time.Sleep(time.Second * 110)

// Check that the queue has 4 messages and that they're all "reserved" ("in flight" on AWS SQS)
// During this, no messages are "active"
// During this, no messages are "active", as we are still within the 180s error timeout
out := &jobState.State{}
t.Run("StatsBeforeErrorVisibilityTimeout", helpers.Stats(address, out))
assert.Equal(t, int64(0), out.Active, "No messages must be available on the queue")
assert.Equal(t, int64(4), out.Reserved, "4 messages must be reserved on the queue")

// Sleep for another 40 seconds (visibility error delay is 90 in this test, so 70 + 10 + 40 == 120s)
// Sleep for another 90 seconds (visibility error delay is 180s in this test, so 10 + 110 + 90 == 210s or 1.5m)
// Sometimes these tests fail if we don't have large enough margins on delays
time.Sleep(time.Second * 40)
time.Sleep(time.Second * 90)
// Now the jobs should be visible again; check metadata for available (pipeline paused, so jobs are not consumed)
t.Run("StatsAfterErrorVisibilityTimeout", helpers.Stats(address, out))
assert.Equal(t, int64(4), out.Active, "4 messages must be available on the queue")
Expand Down

0 comments on commit bbd92e1

Please sign in to comment.