Skip to content

Commit 093cd31

Browse files
committed
Fix DLQ test timing and receive count logic
- Increase receive attempts from 2 to 3 to ensure maxReceiveCount is exceeded - Adjust visibility timeout wait from 3s to 2.5s to match queue config - Increase DLQ receive wait time from 2s to 5s for better reliability - Add extra 1s wait after failure simulation for DLQ processing
1 parent 617d57f commit 093cd31

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/SourceFlow.Cloud.AWS.Tests/Integration/AwsDeadLetterQueueProcessingTests.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,29 @@ public async Task DeadLetterProcessing_ShouldCaptureCompleteMetadata()
145145

146146
Assert.NotNull(sendResponse.MessageId);
147147

148-
// Act - Simulate processing failures
149-
for (int attempt = 1; attempt <= 2; attempt++)
148+
// Act - Simulate processing failures by receiving without deleting
149+
// The message will be moved to DLQ after maxReceiveCount (2) attempts
150+
for (int attempt = 1; attempt <= 3; attempt++)
150151
{
151152
var receiveResponse = await _localStack.SqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
152153
{
153154
QueueUrl = mainQueueUrl,
154155
MaxNumberOfMessages = 1,
155156
MessageAttributeNames = new List<string> { "All" },
156157
AttributeNames = new List<string> { "All" },
157-
WaitTimeSeconds = 1
158+
WaitTimeSeconds = 2
158159
});
159160

160161
if (receiveResponse.Messages.Any())
161162
{
162163
// Don't delete - simulate failure
163-
await Task.Delay(3000);
164+
// Wait for visibility timeout to expire so message becomes available again
165+
await Task.Delay(2500); // Slightly longer than VisibilityTimeout (2s)
164166
}
165167
}
166168

167-
// Wait for DLQ processing
168-
await Task.Delay(2000);
169+
// Wait a bit more for DLQ processing to complete
170+
await Task.Delay(1000);
169171

170172
// Act - Retrieve from DLQ and process
171173
var dlqReceiveResponse = await _localStack.SqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
@@ -174,7 +176,7 @@ public async Task DeadLetterProcessing_ShouldCaptureCompleteMetadata()
174176
MaxNumberOfMessages = 1,
175177
MessageAttributeNames = new List<string> { "All" },
176178
AttributeNames = new List<string> { "All" },
177-
WaitTimeSeconds = 2
179+
WaitTimeSeconds = 5
178180
});
179181

180182
// Assert - Message should be in DLQ

0 commit comments

Comments
 (0)