You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2021/07/28 07:34:10 UTC
[camel-quarkus] branch main updated: AWS2 ddb-streams integration
tests failures #2860
This is an automated email from the ASF dual-hosted git repository.
aldettinger 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 7624028 AWS2 ddb-streams integration tests failures #2860
7624028 is described below
commit 76240287e50c276ff2f8b84bf32e7705e422e530
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Tue Jul 27 10:17:11 2021 +0200
AWS2 ddb-streams integration tests failures #2860
---
.../quarkus/component/aws2/ddb/it/Aws2DdbTest.java | 47 ++++++++++++++++++++--
1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/integration-test-groups/aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java b/integration-test-groups/aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
index 46890c4..ad62d1d 100644
--- a/integration-test-groups/aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
+++ b/integration-test-groups/aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
@@ -16,9 +16,11 @@
*/
package org.apache.camel.quarkus.component.aws2.ddb.it;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
@@ -40,9 +42,44 @@ class Aws2DdbTest {
@Test
public void crud() {
-
final String key = "key" + UUID.randomUUID().toString().replace("-", "");
final String msg = "val" + UUID.randomUUID().toString().replace("-", "");
+ final String initKeyPrefix = "initKey";
+ final String initMsg = "val";
+
+ /* Wait for the consumer to start. Test event has to be created periodically to ensure consumer reception */
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body("")
+ .post("/aws2-ddb/item/" + initKeyPrefix + UUID.randomUUID().toString().replace("-", ""))
+ .then()
+ .statusCode(201);
+
+ /* Periodically check that init event is received and if nothing is received, invoke another one */
+ Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120, TimeUnit.SECONDS).until(
+ () -> {
+ ExtractableResponse<Response> result = RestAssured.get("/aws2-ddbstream/change")
+ .then()
+ .statusCode(200)
+ .extract();
+
+ LOG.info("Expecting at least 1 init event, got " + result.statusCode() + ": " + result.body().asString());
+
+ List<Map> res = result.jsonPath().getList("$", Map.class);
+
+ /* If there is no received event, consumer is still not running. Repeat insert. */
+ if (res.isEmpty()) {
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(initMsg)
+ .post("/aws2-ddb/item/initKey" + UUID.randomUUID().toString().replace("-", ""))
+ .then()
+ .statusCode(201);
+ }
+ return res;
+ },
+ /* If at least one of the init events is recceived, consumer is working */
+ list -> !list.isEmpty());
/* Ensure initially empty */
RestAssured.get("/aws2-ddb/item/" + key)
@@ -110,9 +147,12 @@ class Aws2DdbTest {
.extract();
LOG.info("Expecting 3 events got " + result.statusCode() + ": " + result.body().asString());
- return result.jsonPath().getList("$", Map.class);
+ List<Map> retVal = result.jsonPath().getList("$", Map.class);
+ //remove init events
+ return retVal.stream().filter(m -> !String.valueOf(m.get("key")).startsWith("initKey"))
+ .collect(Collectors.toList());
},
- /* The above actions should trigger the following three change events */
+ /* The above actions should trigger the following three change events (initEvent is also present) */
list -> list.size() == 3
&& key.equals(list.get(0).get("key"))
@@ -124,7 +164,6 @@ class Aws2DdbTest {
&& key.equals(list.get(2).get("key"))
&& newMsg.equals(list.get(2).get("old")));
-
}
}