diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-02-20 16:33:09 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-02-24 20:27:07 +0100 |
commit | 7f1f3c49505c6e75a7edf10f59dec9596899e845 (patch) | |
tree | bd182ab3dbbed4908f821f2a3bc04b3a4882cee1 /tests | |
parent | 3c222970eafeac95fdd40f2857a500ac5c6bae55 (diff) | |
download | sonarqube-7f1f3c49505c6e75a7edf10f59dec9596899e845.tar.gz sonarqube-7f1f3c49505c6e75a7edf10f59dec9596899e845.zip |
SONAR-8435 run level3, 4 and startup in background thread in safemode
Diffstat (limited to 'tests')
3 files changed, 27 insertions, 16 deletions
diff --git a/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/ServerStatusCall.java b/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/ServerStatusCall.java index a99a2c46235..c42c1187e4b 100644 --- a/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/ServerStatusCall.java +++ b/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/ServerStatusCall.java @@ -40,6 +40,7 @@ public class ServerStatusCall extends WsCallAndWait<ServerStatusResponse> { @Override protected boolean shouldWait(ServerStatusResponse serverStatusResponse) { - return false; + ServerStatusResponse.Status status = serverStatusResponse.getStatus(); + return status == ServerStatusResponse.Status.STARTING || status == ServerStatusResponse.Status.DB_MIGRATION_RUNNING; } } diff --git a/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/ServerStatusResponse.java b/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/ServerStatusResponse.java index b45ea599a04..3ab7ecb8801 100644 --- a/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/ServerStatusResponse.java +++ b/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/ServerStatusResponse.java @@ -42,7 +42,7 @@ public class ServerStatusResponse { return status; } - public static enum Status { - UP, DOWN, DB_MIGRATION_NEEDED, DB_MIGRATION_RUNNING + public enum Status { + UP, DOWN, STARTING, DB_MIGRATION_NEEDED, DB_MIGRATION_RUNNING } } diff --git a/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/UpgradeTest.java b/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/UpgradeTest.java index 52255c69288..29f7c0899e7 100644 --- a/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/UpgradeTest.java +++ b/tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/UpgradeTest.java @@ -54,6 +54,12 @@ public class UpgradeTest { private static final String PROJECT_KEY = "org.apache.struts:struts-parent"; private static final String LATEST_JAVA_RELEASE = "LATEST_RELEASE"; + private static final Version VERSION_5_2 = Version.create("5.2"); + private static final Version VERSION_5_6_1 = Version.create("5.6.1"); + private static final Version VERSION_5_6 = Version.create("5.6"); + private static final Version VERSION_6_0 = Version.create("6.0"); + private static final Version VERSION_6_1 = Version.create("6.1"); + private static final Version VERSION_CURRENT = Version.create("DEV"); private Orchestrator orchestrator; @@ -67,22 +73,22 @@ public class UpgradeTest { @Test public void test_upgrade_from_5_6_1() { - testDatabaseUpgrade(Version.create("5.6.1")); + testDatabaseUpgrade(VERSION_5_6_1); } @Test public void test_upgrade_from_5_2_via_5_6() { - testDatabaseUpgrade(Version.create("5.2"), Version.create("5.6")); + testDatabaseUpgrade(VERSION_5_2, VERSION_5_6); } @Test public void test_upgrade_from_6_0() { - testDatabaseUpgrade(Version.create("6.0")); + testDatabaseUpgrade(VERSION_6_0); } @Test public void test_upgrade_from_6_1() { - testDatabaseUpgrade(Version.create("6.1")); + testDatabaseUpgrade(VERSION_6_1); } private void testDatabaseUpgrade(Version fromVersion, Version... intermediaryVersions) { @@ -94,13 +100,13 @@ public class UpgradeTest { Arrays.stream(intermediaryVersions).forEach((sqVersion) -> { startOldVersionServer(sqVersion, true); - upgrade(); + upgrade(sqVersion); verifyAnalysis(files); stopServer(); }); startDevServer(); - upgrade(); + upgrade(VERSION_CURRENT); verifyAnalysis(files); stopServer(); } @@ -112,19 +118,23 @@ public class UpgradeTest { browseWebapp(); } - private void upgrade() { - checkSystemStatus(ServerStatusResponse.Status.DB_MIGRATION_NEEDED); + private void upgrade(Version sqVersion) { + checkSystemStatus(sqVersion, ServerStatusResponse.Status.DB_MIGRATION_NEEDED); checkUrlsBeforeUpgrade(); ServerMigrationResponse serverMigrationResponse = new ServerMigrationCall(orchestrator).callAndWait(); - assertThat(serverMigrationResponse.getStatus()).isEqualTo(ServerMigrationResponse.Status.MIGRATION_SUCCEEDED); - checkSystemStatus(ServerStatusResponse.Status.UP); + assertThat(serverMigrationResponse.getStatus()) + .describedAs("Migration status of version " + sqVersion + " should be MIGRATION_SUCCEEDED") + .isEqualTo(ServerMigrationResponse.Status.MIGRATION_SUCCEEDED); + checkSystemStatus(sqVersion, ServerStatusResponse.Status.UP); checkUrlsAfterUpgrade(); } - private void checkSystemStatus(ServerStatusResponse.Status serverStatus) { - ServerStatusResponse serverStatusResponse = new ServerStatusCall(orchestrator).call(); + private void checkSystemStatus(Version sqVersion, ServerStatusResponse.Status serverStatus) { + ServerStatusResponse serverStatusResponse = new ServerStatusCall(orchestrator).callAndWait(); - assertThat(serverStatusResponse.getStatus()).isEqualTo(serverStatus); + assertThat(serverStatusResponse.getStatus()) + .describedAs("Server status of version " + sqVersion + " should be " + serverStatus) + .isEqualTo(serverStatus); } private void checkUrlsBeforeUpgrade() { |