aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject aurora git commit: Fix flaky WebhookTest
Date Sun, 10 Dec 2017 11:06:56 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 47c689956 -> ef24c2ce3


Fix flaky WebhookTest

I opted for a minimal patch that stays close to the style of the other
tests. There is a remaining risk of a race condition if the OS re-uses
the same port between stopping jetty and triggering the webhooks, but
it should be very unlikely.

Reviewed at https://reviews.apache.org/r/64482/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/ef24c2ce
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/ef24c2ce
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/ef24c2ce

Branch: refs/heads/master
Commit: ef24c2ce355e857c4fcce531b4f16028a6c6e75d
Parents: 47c6899
Author: Stephan Erb <serb@apache.org>
Authored: Sun Dec 10 12:06:39 2017 +0100
Committer: Stephan Erb <serb@apache.org>
Committed: Sun Dec 10 12:06:39 2017 +0100

----------------------------------------------------------------------
 .../aurora/scheduler/events/WebhookTest.java     | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/ef24c2ce/src/test/java/org/apache/aurora/scheduler/events/WebhookTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/events/WebhookTest.java b/src/test/java/org/apache/aurora/scheduler/events/WebhookTest.java
index adeff89..1b5d2d0 100644
--- a/src/test/java/org/apache/aurora/scheduler/events/WebhookTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/events/WebhookTest.java
@@ -19,7 +19,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -181,26 +180,12 @@ public class WebhookTest {
 
   @Test
   public void testTaskChangedWithOldStateError() throws Exception {
-    // We have a special handler here to trigger `onThrowable` on the client.
-    jettyServer.setHandler(new AbstractHandler() {
-      @Override
-      public void handle(String target, Request baseRequest, HttpServletRequest request,
-                         HttpServletResponse response) throws IOException, ServletException
{
-
-        Stream.of(jettyServer.getConnectors())
-            .forEach(c -> {
-              try {
-                c.stop();
-              } catch (Exception e) {
-                throw new RuntimeException(e);
-              }
-            });
-      }
-    });
     jettyServer.start();
     WebhookInfo webhookInfo = buildWebhookInfoWithJettyPort(WEBHOOK_INFO_BUILDER);
     Webhook webhook = new Webhook(httpClient, webhookInfo, statsProvider);
 
+    // Send the event to a stopped server to trigger `onThrowable` of the client.
+    jettyServer.stop();
     webhook.taskChangedState(CHANGE_OLD_STATE);
 
     assertEquals(1, statsProvider.getLongValue(Webhook.ATTEMPTS_STAT_NAME));


Mime
View raw message