From 454932613ec7810bce21d53abee0bcc98fa72d04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Fri, 8 Jan 2016 18:11:09 +0100 Subject: [PATCH] SONAR-7168 support restart in prod mode in ITs in addition, rename IT DevModeTest to RestartTest --- .../src/test/java/it/Category4Suite.java | 4 +-- .../{DevModeTest.java => RestartTest.java} | 30 +++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) rename it/it-tests/src/test/java/it/serverSystem/{DevModeTest.java => RestartTest.java} (69%) diff --git a/it/it-tests/src/test/java/it/Category4Suite.java b/it/it-tests/src/test/java/it/Category4Suite.java index f95e3e0a94f..389a3db0314 100644 --- a/it/it-tests/src/test/java/it/Category4Suite.java +++ b/it/it-tests/src/test/java/it/Category4Suite.java @@ -28,7 +28,7 @@ import it.dbCleaner.PurgeTest; import it.duplication.CrossProjectDuplicationsOnRemoveFileTest; import it.duplication.CrossProjectDuplicationsTest; import it.duplication.DuplicationsTest; -import it.serverSystem.DevModeTest; +import it.serverSystem.RestartTest; import it.serverSystem.HttpsTest; import it.serverSystem.ServerSystemRestartingOrchestrator; import it.serverSystem.ServerSystemTest; @@ -44,7 +44,7 @@ import static util.ItUtils.xooPlugin; @RunWith(Suite.class) @Suite.SuiteClasses({ // server system - DevModeTest.class, + RestartTest.class, HttpsTest.class, ServerSystemTest.class, ServerSystemRestartingOrchestrator.class, diff --git a/it/it-tests/src/test/java/it/serverSystem/DevModeTest.java b/it/it-tests/src/test/java/it/serverSystem/RestartTest.java similarity index 69% rename from it/it-tests/src/test/java/it/serverSystem/DevModeTest.java rename to it/it-tests/src/test/java/it/serverSystem/RestartTest.java index d48f269adf6..d52215d3776 100644 --- a/it/it-tests/src/test/java/it/serverSystem/DevModeTest.java +++ b/it/it-tests/src/test/java/it/serverSystem/RestartTest.java @@ -25,20 +25,25 @@ import org.apache.commons.lang.SystemUtils; 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 static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; /** - * This class start a new orchestrator on each test case + * This class starts a new orchestrator on each test case */ -public class DevModeTest { +public class RestartTest { Orchestrator orchestrator; @Rule public ExpectedException thrown = ExpectedException.none(); + @Rule + public TestRule globalTimeout = new DisableOnDebug(Timeout.seconds(120)); @After public void stop() { @@ -47,22 +52,29 @@ public class DevModeTest { } } - /** - * SONAR-4843 - */ @Test - public void restart_forbidden_if_not_dev_mode() throws Exception { + public void restart_in_prod_mode_requires_admin_privileges_and_restarts_WebServer_and_ES() throws Exception { // server classloader locks Jar files on Windows if (!SystemUtils.IS_OS_WINDOWS) { orchestrator = Orchestrator.builderEnv() + .setOrchestratorProperty("orchestrator.keepWorkspace", "true") .build(); orchestrator.start(); + try { - orchestrator.getServer().adminWsClient().systemClient().restart(); + orchestrator.getServer().wsClient().systemClient().restart(); fail(); } catch (Exception e) { assertThat(e.getMessage()).contains("403"); } + + orchestrator.getServer().adminWsClient().systemClient().restart(); + + // we just wait five seconds, for a lack of a better approach to waiting for the restart process to start in SQ + Thread.sleep(5000); + + assertThat(FileUtils.readFileToString(orchestrator.getServer().getLogs())) + .contains("Requesting SonarQube restart"); } } @@ -80,8 +92,8 @@ public class DevModeTest { orchestrator.getServer().adminWsClient().systemClient().restart(); assertThat(FileUtils.readFileToString(orchestrator.getServer().getLogs())) - .contains("Restart server") - .contains("Server restarted"); + .contains("Fast restarting WebServer...") + .contains("WebServer restarted"); } } } -- 2.39.5