You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2023/10/02 13:46:07 UTC
[camel-quarkus] branch 3.2.x updated: Improve implementation of GooglePubsubTest.testOrdering
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch 3.2.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/3.2.x by this push:
new 7a03993caf Improve implementation of GooglePubsubTest.testOrdering
7a03993caf is described below
commit 7a03993caf175ce0934f24d60d1155116e8e2145
Author: James Netherton <ja...@gmail.com>
AuthorDate: Wed Sep 20 10:21:40 2023 +0100
Improve implementation of GooglePubsubTest.testOrdering
Fixes #3944
---
.../google/pubsub/it/GooglePubSubRoutes.java | 4 +
.../google/pubsub/it/GooglePubsubResource.java | 11 ++-
.../google/pubsub/it/GooglePubsubTest.java | 91 ++++------------------
3 files changed, 26 insertions(+), 80 deletions(-)
diff --git a/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubSubRoutes.java b/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubSubRoutes.java
index de0220b979..52362d633b 100644
--- a/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubSubRoutes.java
+++ b/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubSubRoutes.java
@@ -31,6 +31,7 @@ public class GooglePubSubRoutes extends RouteBuilder {
public static final String ORDERING_DIRECT_IN = "direct:ordering_in";
public static final String ACK_DIRECT_IN = "direct:ack_in";
public static final String ACK_MOCK_RESULT = "mock:ack_result";
+ public static final String ORDERING_MOCK_RESULT = "mock:ordering_result";
@Produces
@Named("ackFailing")
@@ -60,6 +61,9 @@ public class GooglePubSubRoutes extends RouteBuilder {
throw new Exception("fail");
}
}).to(ACK_MOCK_RESULT);
+
+ from("google-pubsub:{{project.id}}:{{google-pubsub.ordering-subscription-name}}?synchronousPull=true")
+ .to(ORDERING_MOCK_RESULT);
}
static class AcKFailing {
diff --git a/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java b/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java
index b0fc91f65c..86367bac71 100644
--- a/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java
+++ b/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java
@@ -39,6 +39,8 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.google.pubsub.GooglePubsubConstants;
import org.apache.camel.component.mock.MockEndpoint;
+import static org.apache.camel.quarkus.component.google.pubsub.it.GooglePubSubRoutes.ORDERING_MOCK_RESULT;
+
@Path("/google-pubsub")
public class GooglePubsubResource {
@@ -123,9 +125,12 @@ public class GooglePubsubResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String receiveFromSubscriptionOrdered(@PathParam("subscriptionName") String subscriptionName) throws Exception {
-
- return consumeEndpoint(subscriptionName,
- "&messageOrderingEnabled=true&pubsubEndpoint=pubsub.googleapis.com:443");
+ MockEndpoint endpoint = context.getEndpoint(ORDERING_MOCK_RESULT, MockEndpoint.class);
+ return endpoint.getExchanges()
+ .stream()
+ .map(Exchange::getMessage)
+ .map(message -> message.getBody(String.class))
+ .collect(Collectors.joining(","));
}
private String consumeEndpoint(String subscriptionName, String parameters) {
diff --git a/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java b/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java
index 10df7cce8f..3ad2948224 100644
--- a/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java
+++ b/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java
@@ -113,92 +113,29 @@ class GooglePubsubTest {
//Disabled on real account because of https://issues.apache.org/jira/browse/CAMEL-18277
@DisabledIfEnvironmentVariable(named = "GOOGLE_APPLICATION_CREDENTIALS", matches = ".+")
- // https://github.com/apache/camel-quarkus/issues/3944
- @DisabledIfEnvironmentVariable(named = "CI", matches = "true")
@Test
public void testOrdering() throws Exception {
LOG.info("Start of the ordering test");
- RestAssured.given()
- .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN)
- .body("1")
- .post("/google-pubsub/sendToEndpoint")
- .then()
- .statusCode(201);
- RestAssured.given()
- .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN)
- .body("2")
- .post("/google-pubsub/sendToEndpoint")
- .then()
- .statusCode(201);
- RestAssured.given()
- .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN)
- .body("3")
- .post("/google-pubsub/sendToEndpoint")
- .then()
- .statusCode(201);
- RestAssured.given()
- .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN)
- .body("4")
- .post("/google-pubsub/sendToEndpoint")
- .then()
- .statusCode(201);
- RestAssured.given()
- .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN)
- .body("5")
- .post("/google-pubsub/sendToEndpoint")
- .then()
- .statusCode(201);
- RestAssured.given()
- .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN)
- .body("6")
- .post("/google-pubsub/sendToEndpoint")
- .then()
- .statusCode(201);
+
+ String messages = "1,2,3,4,5,6";
+
+ for (String message : messages.split(",")) {
+ RestAssured.given()
+ .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN)
+ .body(message)
+ .post("/google-pubsub/sendToEndpoint")
+ .then()
+ .statusCode(201);
+ }
+
LOG.info("All messages were sent");
- await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given()
+ await().atMost(10, TimeUnit.SECONDS).until(() -> RestAssured.given()
.get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name")
.then()
.statusCode(200)
.extract().asString(),
- Matchers.is("1"));
- LOG.info("Message \"1\" received.");
- await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given()
- .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name")
- .then()
- .statusCode(200)
- .extract().asString(),
- Matchers.is("2"));
- LOG.info("Message \"2\" received.");
- await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given()
- .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name")
- .then()
- .statusCode(200)
- .extract().asString(),
- Matchers.is("3"));
- LOG.info("Message \"3\" received.");
- await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given()
- .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name")
- .then()
- .statusCode(200)
- .extract().asString(),
- Matchers.is("4"));
- LOG.info("Message \"4\" received.");
- await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given()
- .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name")
- .then()
- .statusCode(200)
- .extract().asString(),
- Matchers.is("5"));
- LOG.info("Message \"5\" received.");
- await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given()
- .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name")
- .then()
- .statusCode(200)
- .extract().asString(),
- Matchers.is("6"));
- LOG.info("Message \"6\" received.");
-
+ Matchers.is(messages));
}
@Test