aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-05-12 14:18:41 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-05-12 14:18:41 +0200
commitc3f190771bfaf1104985bdec74391599956bc66e (patch)
tree195a649e5ae93330765445738e46609ef09f601f /server
parentc701c420ca241c9de6e3a72ce18128c6840fa156 (diff)
downloadsonarqube-c3f190771bfaf1104985bdec74391599956bc66e.tar.gz
sonarqube-c3f190771bfaf1104985bdec74391599956bc66e.zip
Consistent safeguard timeouts in JUnit tests
Diffstat (limited to 'server')
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java4
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/cluster/HazelcastClientWrapperImplTest.java2
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java4
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/application/SchedulerImplTest.java4
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java2
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java2
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/application/process/SQProcessTest.java2
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/application/process/StopRequestWatcherImplTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java7
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java4
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/StopWatcherTest.java2
-rw-r--r--server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImplTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java2
14 files changed, 22 insertions, 19 deletions
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java
index 758c0eaf92d..c2a7f45c965 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java
@@ -27,7 +27,9 @@ import javax.annotation.Nullable;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.DisableOnDebug;
import org.junit.rules.ExpectedException;
+import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.mockito.Mockito;
import org.sonar.ce.ComputeEngine;
@@ -41,7 +43,7 @@ import static org.mockito.Mockito.mock;
public class CeServerTest {
@Rule
- public Timeout timeout = Timeout.seconds(50);
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/cluster/HazelcastClientWrapperImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/cluster/HazelcastClientWrapperImplTest.java
index 75877871fa3..746b31960f6 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/cluster/HazelcastClientWrapperImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/cluster/HazelcastClientWrapperImplTest.java
@@ -60,7 +60,7 @@ public class HazelcastClientWrapperImplTest {
public ExpectedException expectedException = ExpectedException.none();
@Rule
- public TestRule safeGuard = new DisableOnDebug(Timeout.seconds(20));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
private static HazelcastInstance hzCluster;
private static HazelcastClientWrapperImpl hzClient;
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
index 43585cf63d1..355fd1c8267 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
@@ -44,6 +44,8 @@ import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.DisableOnDebug;
+import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.sonar.ce.configuration.CeConfigurationRule;
@@ -64,7 +66,7 @@ public class CeProcessingSchedulerImplTest {
@Rule
// due to risks of infinite chaining of tasks/futures, a timeout is required for safety
- public Timeout timeout = Timeout.seconds(60);
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Rule
public CeConfigurationRule ceConfiguration = new CeConfigurationRule();
// Required to prevent an infinite loop
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/SchedulerImplTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/SchedulerImplTest.java
index 349c5a09e8f..33c4cc2f0b9 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/application/SchedulerImplTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/SchedulerImplTest.java
@@ -58,7 +58,7 @@ public class SchedulerImplTest {
private static final JavaCommand CE_COMMAND = new JavaCommand(COMPUTE_ENGINE);
@Rule
- public TestRule safeGuard = new DisableOnDebug(Timeout.seconds(30));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -187,7 +187,7 @@ public class SchedulerImplTest {
}
// restarting
- verify(appReloader, timeout(10_000)).reload(settings);
+ verify(appReloader, timeout(60_000)).reload(settings);
processLauncher.waitForProcessAlive(ELASTICSEARCH);
processLauncher.waitForProcessAlive(COMPUTE_ENGINE);
processLauncher.waitForProcessAlive(WEB_SERVER);
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java
index 8c89e6593e1..fd0497c4932 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java
@@ -49,7 +49,7 @@ public class AppStateClusterImplTest {
public ExpectedException expectedException = ExpectedException.none();
@Rule
- public TestRule safeGuard = new DisableOnDebug(Timeout.seconds(10));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Test
public void instantiation_throws_ISE_if_cluster_mode_is_disabled() throws Exception {
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java
index 3f7eb072808..cc8a0baab1c 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java
@@ -63,7 +63,7 @@ import static org.sonar.process.cluster.ClusterObjectKeys.SONARQUBE_VERSION;
public class HazelcastClusterTest {
@Rule
- public TestRule safeGuard = new DisableOnDebug(Timeout.seconds(10));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/process/SQProcessTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/process/SQProcessTest.java
index 84433436aa6..c7eb9e26608 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/application/process/SQProcessTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/process/SQProcessTest.java
@@ -44,7 +44,7 @@ public class SQProcessTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
- public TestRule safeGuard = new DisableOnDebug(Timeout.seconds(10));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Test
public void initial_state_is_INIT() {
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/process/StopRequestWatcherImplTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/process/StopRequestWatcherImplTest.java
index 3fbe5f8a52c..2ac305797e4 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/application/process/StopRequestWatcherImplTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/process/StopRequestWatcherImplTest.java
@@ -46,7 +46,7 @@ public class StopRequestWatcherImplTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@Rule
- public TestRule safeGuard = new DisableOnDebug(Timeout.seconds(10));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
private AppSettings settings = mock(AppSettings.class, RETURNS_DEEP_STUBS);
private ProcessCommands commands = mock(ProcessCommands.class);
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
index 3b045b6a0dc..68996625c72 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
@@ -43,13 +43,10 @@ import static org.sonar.process.ProcessEntryPoint.PROPERTY_TERMINATION_TIMEOUT;
public class ProcessEntryPointTest {
- SystemExit exit = mock(SystemExit.class);
+ private SystemExit exit = mock(SystemExit.class);
- /**
- * Safeguard
- */
@Rule
- public TestRule timeout = new DisableOnDebug(Timeout.seconds(60));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Rule
public TemporaryFolder temp = new TemporaryFolder();
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java
index d1f872b904d..b88ca719cd5 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java
@@ -21,6 +21,8 @@ package org.sonar.process;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.DisableOnDebug;
+import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.sonar.test.TestUtils;
@@ -30,7 +32,7 @@ import static org.sonar.process.ProcessUtils.awaitTermination;
public class ProcessUtilsTest {
@Rule
- public Timeout timeout = Timeout.seconds(5);
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Test
public void private_constructor() {
diff --git a/server/sonar-process/src/test/java/org/sonar/process/StopWatcherTest.java b/server/sonar-process/src/test/java/org/sonar/process/StopWatcherTest.java
index 970a1e4bdc9..9938ae1050c 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/StopWatcherTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/StopWatcherTest.java
@@ -33,7 +33,7 @@ import static org.mockito.Mockito.when;
public class StopWatcherTest {
@Rule
- public TestRule safeguard = new DisableOnDebug(Timeout.seconds(10));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Test
public void stop_if_receive_command() throws Exception {
diff --git a/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java b/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java
index 88c1c1960a1..407a99ecc27 100644
--- a/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java
+++ b/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java
@@ -55,7 +55,7 @@ public class SearchServerTest {
private static final String A_NODE_NAME = "a_node";
@Rule
- public TestRule timeout = new DisableOnDebug(Timeout.seconds(60));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
@Rule
public TemporaryFolder temp = new TemporaryFolder();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImplTest.java
index 9160e36eb30..4a7d4d829c3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImplTest.java
@@ -51,7 +51,7 @@ public class WebhookCallerImplTest {
public MockWebServer server = new MockWebServer();
@Rule
- public TestRule timeoutSafeguard = new DisableOnDebug(Timeout.seconds(60));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
private System2 system = new TestSystem2().setNow(NOW);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
index bc59f3d1a8e..c11637b90af 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
@@ -58,7 +58,7 @@ public class EmbeddedDatabaseTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
- public TestRule safeguard = new DisableOnDebug(Timeout.seconds(30));
+ public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
private MapSettings settings = new MapSettings();
private System2 system2 = mock(System2.class);