You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by ni...@apache.org on 2019/09/13 15:10:44 UTC

[metron] branch master updated: METRON-2254 Intermittent Test Failure in RestFunctionsIntegrationTest (nickwallen) closes apache/metron#1510

This is an automated email from the ASF dual-hosted git repository.

nickallen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/metron.git


The following commit(s) were added to refs/heads/master by this push:
     new b1536d7  METRON-2254 Intermittent Test Failure in RestFunctionsIntegrationTest (nickwallen) closes apache/metron#1510
b1536d7 is described below

commit b1536d73fd33707357f0b0274443d63f9487454c
Author: nickwallen <ni...@nickallen.org>
AuthorDate: Fri Sep 13 11:10:20 2019 -0400

    METRON-2254 Intermittent Test Failure in RestFunctionsIntegrationTest (nickwallen) closes apache/metron#1510
---
 .../dsl/functions/RestFunctionsIntegrationTest.java    | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/RestFunctionsIntegrationTest.java b/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/RestFunctionsIntegrationTest.java
index 865453e..27225f4 100644
--- a/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/RestFunctionsIntegrationTest.java
+++ b/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/RestFunctionsIntegrationTest.java
@@ -38,6 +38,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import static org.apache.metron.stellar.common.utils.StellarProcessorUtils.run;
 import static org.apache.metron.stellar.dsl.functions.RestConfig.*;
@@ -240,17 +241,17 @@ public class RestFunctionsIntegrationTest {
   @SuppressWarnings("unchecked")
   public void restGetShouldTimeout() {
     String uri = String.format("http://localhost:%d/get", mockServerRule.getPort());
-
     mockServerClient.when(
             request()
                     .withMethod("GET")
                     .withPath("/get"))
             .respond(response()
+                    .withDelay(TimeUnit.MILLISECONDS, 1000)
                     .withBody("{\"get\":\"success\"}"));
 
     Map<String, Object> globalConfig = new HashMap<String, Object>() {{
       put(STELLAR_REST_SETTINGS, new HashMap<String, Object>() {{
-        put(TIMEOUT, 1);
+        put(TIMEOUT, 10);
       }});
     }};
 
@@ -262,7 +263,7 @@ public class RestFunctionsIntegrationTest {
 
   /**
    * {
-   * "timeout": 1
+   * "timeout": 10
    * }
    */
   @Multiline
@@ -274,7 +275,16 @@ public class RestFunctionsIntegrationTest {
   @Test
   @SuppressWarnings("unchecked")
   public void restGetShouldTimeoutWithSuppliedTimeout() {
-    String expression = String.format("REST_GET('%s', %s)", getUri, timeoutConfig);
+    String uri = String.format("http://localhost:%d/get", mockServerRule.getPort());
+    mockServerClient.when(
+            request()
+                    .withMethod("GET")
+                    .withPath("/get"))
+            .respond(response()
+                    .withDelay(TimeUnit.MILLISECONDS, 1000)
+                    .withBody("{\"get\":\"success\"}"));
+
+    String expression = String.format("REST_GET('%s', %s)", uri, timeoutConfig);
     Map<String, Object> actual = (Map<String, Object>) run(expression, context);
     assertNull(actual);
   }