aldettinger commented on code in PR #3919:
URL: https://github.com/apache/camel-quarkus/pull/3919#discussion_r940128863


##########
integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java:
##########
@@ -64,7 +82,95 @@ public Response sendPojoToTopic(String fruitName) {
     @Produces(MediaType.APPLICATION_JSON)
     public Response consumePojoFromTopic() {
         Object response = consumerTemplate
-                
.receiveBody("google-pubsub:{{project.id}}:{{subscription.name}}?synchronousPull=true",
 5000L);
+                
.receiveBody("google-pubsub:{{project.id}}:{{google-pubsub.subscription-name}}?synchronousPull=false",
 5000L);
         return Response.ok(response).build();
     }
+
+    @Path("/sendToEndpoint")
+    @POST
+    public Response sentToEndpoint(String message,
+            @QueryParam("toEndpoint") String toEndpoint)
+            throws Exception {
+        producerTemplate.sendBody(toEndpoint, message);
+        return 
Response.created(URI.create("https://camel.apache.org";)).build();
+    }
+
+    @Path("/getFromEndpoint")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String getSchedulerResult(@QueryParam("fromEndpoint") String 
fromEndpoint) throws Exception {
+        return consumerTemplate.receiveBody(fromEndpoint, 5000, String.class);
+    }
+
+    @Path("receive/subscription/{subscriptionName}")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String receiveFromSubscription(@PathParam("subscriptionName") 
String subscriptionName) throws Exception {
+        return consumeEndpoint(subscriptionName, null);
+    }
+
+    @Path("receive/subscriptionOrdering/{subscriptionName}")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String 
receiveFromSubscriptionOrdered(@PathParam("subscriptionName") String 
subscriptionName) throws Exception {
+
+        return consumeEndpoint(subscriptionName,
+                
"?messageOrderingEnabled=true&pubsubEndpoint=us-east1-pubsub.googleapis.com:443");
+    }
+
+    private String consumeEndpoint(String subscriptionName, String parameters) 
{
+        String url = "google-pubsub:{{project.id}}:{{" + subscriptionName + 
"}}";
+        if (parameters != null && !"".equals(parameters)) {
+            url = url + parameters;
+        }
+        Exchange ex = consumerTemplate.receive(url, 5000);
+
+        if (ex != null) {
+            return ex.getIn().getBody(String.class);
+        }
+
+        return null;
+    }
+
+    @Path("receive/mock/{mockName}")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String mockReceive(@QueryParam("reset") boolean reset, 
@PathParam("mockName") String mockName)
+            throws Exception {
+        MockEndpoint mock = context.getEndpoint(mockName, MockEndpoint.class);
+
+        List<String> results = mock.getExchanges().stream().map(e -> 
e.getIn().getBody(String.class))
+                .collect(Collectors.toList());
+        if (reset) {
+            mock.reset();

Review Comment:
   I think the flaky issue is there and the probability of occurrence could be 
raised to observe it.
   For instance, locally, I sleep 4s before resetting:
   ```
           if (reset) {
               Thread.sleep(4000L);
               mock.reset();
           }
   ```
   
   And then, in the route, I delay the first message only:
   ```
   static int i = 0;
   ...
   ...
   ...
                   }).process(new Processor() {
                       @Override
                       public void process(Exchange exchange) throws Exception {
                           if (i == 0) {
                               Thread.sleep(1000L);
                           }
                           i++;
                       }
                   }).to(ACK_MOCK_RESULT);
   ```
   
   And then, I hit exception below:
   ```
   Assertion condition defined as a 
org.apache.camel.quarkus.component.google.pubsub.it.GooglePubsubTest 1 
expectation failed.
   Response body doesn't match expectation.
   Expected: is "1"
     Actual: 
    within 5 seconds.
        at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
        at 
org.awaitility.core.AssertionCondition.await(AssertionCondition.java:119)
        at 
org.awaitility.core.AssertionCondition.await(AssertionCondition.java:31)
        at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:985)
        at 
org.awaitility.core.ConditionFactory.untilAsserted(ConditionFactory.java:769)
        at 
org.apache.camel.quarkus.component.google.pubsub.it.GooglePubsubTest.testAck(GooglePubsubTest.java:228)
   ...
   Caused by: java.util.concurrent.TimeoutException
   ...
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to