This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 4d49e7140c [closes #4028] Fix sqsAutoCreateDelayedQueue test
4d49e7140c is described below
commit 4d49e7140c0155007bf806f10ea59a4e16a2c7d0
Author: Lukas Lowinger <[email protected]>
AuthorDate: Tue Aug 23 17:04:30 2022 +0200
[closes #4028] Fix sqsAutoCreateDelayedQueue test
---
.../quarkus/component/aws2/sqs/it/Aws2SqsTest.java | 28 ++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git
a/integration-test-groups/aws2/aws2-sqs/src/test/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsTest.java
b/integration-test-groups/aws2/aws2-sqs/src/test/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsTest.java
index 32f1fd85c9..72a8c40103 100644
---
a/integration-test-groups/aws2/aws2-sqs/src/test/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsTest.java
+++
b/integration-test-groups/aws2/aws2-sqs/src/test/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsTest.java
@@ -37,6 +37,7 @@ import
org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
import org.apache.commons.lang3.RandomStringUtils;
import org.awaitility.Awaitility;
import org.eclipse.microprofile.config.ConfigProvider;
+import org.jboss.logging.Logger;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -48,6 +49,8 @@ import static org.hamcrest.Matchers.is;
@QuarkusTestResource(Aws2TestResource.class)
class Aws2SqsTest {
+ private static final Logger LOG = Logger.getLogger(Aws2SqsTest.class);
+
@Aws2LocalStack
private boolean localStack;
@@ -63,6 +66,15 @@ class Aws2SqsTest {
return ConfigProvider.getConfig().getValue("aws-sqs.deadletter-name",
String.class);
}
+ private Integer getPollIntervalSendToDelayQueueInSecs() {
+ return
ConfigProvider.getConfig().getOptionalValue("aws-sqs.delayed-queue.poll-interval-secs",
Integer.class)
+ .orElse(10);
+ }
+
+ private Integer getTimeoutSendToDelayQueueInMins() {
+ return
ConfigProvider.getConfig().getOptionalValue("aws-sqs.delayed-queue.timeout-mins",
Integer.class).orElse(5);
+ }
+
@AfterEach
void purgeQueueAndWait() {
String qName = getPredefinedQueueName();
@@ -165,8 +177,20 @@ class Aws2SqsTest {
try {
createDelayQueueAndVerifyExistence(qName, delay);
Instant start = Instant.now();
- final String msgSent = sendSingleMessageToQueue(qName);
- awaitMessageWithExpectedContentFromQueue(msgSent, qName);
+ final String[] msgSent = new String[1];
+ // verifying existence is not enough, as the queue can be in not
Ready state, so we just keep trying to send messages
+
Awaitility.await().pollInterval(getPollIntervalSendToDelayQueueInSecs(),
TimeUnit.SECONDS)
+ .atMost(getTimeoutSendToDelayQueueInMins(),
TimeUnit.MINUTES)
+ .until(() -> {
+ try {
+ msgSent[0] = sendSingleMessageToQueue(qName);
+ } catch (Throwable e) {
+ LOG.debug("Expected exception", e);
+ return false;
+ }
+ return true;
+ });
+ awaitMessageWithExpectedContentFromQueue(msgSent[0], qName);
Assertions.assertTrue(Duration.between(start,
Instant.now()).getSeconds() >= delay);
} catch (AssertionError e) {
e.printStackTrace();