From c7b2c639f32136e4c6a01b48546da6d30c61efa0 Mon Sep 17 00:00:00 2001
From: Sergii Leshchenko <sleshche@redhat.com>
Date: Wed, 30 Oct 2019 17:30:06 +0200
Subject: [PATCH] Increate test timeouts for ServersCheckerTest (#15032)

Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
---
 .../server/hc/ServerCheckerTest.java          |  3 +--
 .../server/hc/ServersCheckerTest.java         | 22 +++++--------------
 2 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/ServerCheckerTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/ServerCheckerTest.java
index 66fbb65e9e..55503dcbce 100644
--- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/ServerCheckerTest.java
+++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/ServerCheckerTest.java
@@ -12,7 +12,6 @@
 package org.eclipse.che.api.workspace.server.hc;
 
 import static java.lang.String.format;
-import static org.mockito.Mockito.timeout;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
@@ -34,7 +33,7 @@ public class ServerCheckerTest {
   private static final String SERVER_REF = "ref1";
   private static final long PERIOD_MS = 10;
   private static final long CHECKER_TIMEOUT_MS = 5000;
-  private static final long TEST_TIMEOUT_MS = CHECKER_TIMEOUT_MS + 1000;
+  private static final long TEST_TIMEOUT_MS = CHECKER_TIMEOUT_MS + 5000;
   private static final int SUCCESS_THRESHOLD = 1;
 
   private Timer timer;
diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/ServersCheckerTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/ServersCheckerTest.java
index ea7b33b853..3b73b2f660 100644
--- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/ServersCheckerTest.java
+++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/ServersCheckerTest.java
@@ -37,7 +37,6 @@ import org.eclipse.che.api.workspace.server.token.MachineTokenProvider;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.testng.MockitoTestNGListener;
-import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
@@ -65,7 +64,6 @@ public class ServersCheckerTest {
   @Mock private RuntimeIdentity runtimeIdentity;
   private Map<String, ServerImpl> servers;
 
-  private CompletableFuture<String> compFuture;
   private ServersChecker checker;
 
   @BeforeMethod
@@ -77,7 +75,7 @@ public class ServersCheckerTest {
             EXEC_AGENT_HTTP_SERVER, new ServerImpl().withUrl("http://localhost/exec-agent/process"),
             TERMINAL_SERVER, new ServerImpl().withUrl("http://localhost/terminal/pty")));
 
-    compFuture = new CompletableFuture<>();
+    CompletableFuture<String> compFuture = new CompletableFuture<>();
 
     when(connectionChecker.getReportCompFuture()).thenReturn(compFuture);
 
@@ -99,15 +97,7 @@ public class ServersCheckerTest {
     when(machineTokenProvider.getToken(anyString(), anyString())).thenReturn(MACHINE_TOKEN);
   }
 
-  @AfterMethod(timeOut = 1000)
-  public void tearDown() throws Exception {
-    try {
-      checker.await();
-    } catch (Exception ignored) {
-    }
-  }
-
-  @Test(timeOut = 1000)
+  @Test(timeOut = 5000)
   public void shouldUseMachineTokenWhenCallChecker() throws Exception {
     servers.clear();
     servers.put("wsagent/http", new ServerImpl().withUrl("http://localhost"));
@@ -123,7 +113,7 @@ public class ServersCheckerTest {
     assertEquals(tokenCaptor.getValue(), MACHINE_TOKEN);
   }
 
-  @Test(timeOut = 1000)
+  @Test(timeOut = 5000)
   public void shouldNotifyReadinessHandlerAboutEachServerReadiness() throws Exception {
     checker.startAsync(readinessHandler);
 
@@ -134,7 +124,7 @@ public class ServersCheckerTest {
     verify(readinessHandler, times(3)).accept("test_ref");
   }
 
-  @Test(timeOut = 1000)
+  @Test(timeOut = 5000)
   public void shouldThrowExceptionIfAServerIsUnavailable() throws Exception {
     checker.startAsync(readinessHandler);
 
@@ -149,7 +139,7 @@ public class ServersCheckerTest {
     }
   }
 
-  @Test(timeOut = 1000)
+  @Test(timeOut = 5000)
   public void shouldNotCheckNotConfiguredServers() throws Exception {
     servers.clear();
     servers.putAll(
@@ -164,7 +154,7 @@ public class ServersCheckerTest {
     verify(readinessHandler).accept("test_ref");
   }
 
-  @Test(timeOut = 1000)
+  @Test(timeOut = 5000)
   public void awaitShouldReturnOnFirstUnavailability() throws Exception {
     CompletableFuture<String> future1 = spy(new CompletableFuture<>());
     CompletableFuture<String> future2 = spy(new CompletableFuture<>());
-- 
GitLab