aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-11-09 17:26:54 +0100
committerEric Hartmann <hartmann.eric@gmail.Com>2017-11-14 13:10:17 +0100
commitc0be4a24b1cf4f3f0fe8314e9e7c70d4cdc61b3c (patch)
tree5acab282e0da3d925cc39662e7bcc029b191673b
parent8e505e94aa625637f306cec663f89ea737fc9782 (diff)
downloadsonarqube-c0be4a24b1cf4f3f0fe8314e9e7c70d4cdc61b3c.tar.gz
sonarqube-c0be4a24b1cf4f3f0fe8314e9e7c70d4cdc61b3c.zip
Add upgrade test from 6.7 LTS
-rw-r--r--tests/src/test/java/org/sonarqube/tests/upgrade/MssqlConfig.java47
-rw-r--r--tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java57
2 files changed, 19 insertions, 85 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/upgrade/MssqlConfig.java b/tests/src/test/java/org/sonarqube/tests/upgrade/MssqlConfig.java
deleted file mode 100644
index 2d22485ef43..00000000000
--- a/tests/src/test/java/org/sonarqube/tests/upgrade/MssqlConfig.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.tests.upgrade;
-
-import com.sonar.orchestrator.config.Configuration;
-import com.sonar.orchestrator.version.Version;
-import org.apache.commons.lang.StringUtils;
-
-import static java.util.Objects.requireNonNull;
-
-public class MssqlConfig {
-
- /**
- * Versions prior to 5.2 support only jTDS driver. Versions greater than or equal to 5.2
- * support only MS driver. The problem is that the test is configured with only
- * the MS URL, so it must be changed at runtime for versions < 5.2.
- */
- public static String fixUrl(Configuration conf, Version sqVersion) {
- String jdbcUrl = requireNonNull(conf.getString("sonar.jdbc.url"), "No JDBC url configured");
- if (jdbcUrl.startsWith("jdbc:sqlserver:") && !sqVersion.isGreaterThanOrEquals("5.2")) {
- // Job is configured with the new Microsoft driver, which is not supported by old versions of SQ
- String host = StringUtils.substringBetween(jdbcUrl, "jdbc:sqlserver://", ";databaseName=");
- String db = StringUtils.substringAfter(jdbcUrl, "databaseName=");
- jdbcUrl = "jdbc:jtds:sqlserver://" + host + "/" + db;
- System.out.println("Replaced JDBC url to: " + jdbcUrl);
- return jdbcUrl;
- }
- return jdbcUrl;
- }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java b/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java
index e27eb56cbc7..ee704f8cb6f 100644
--- a/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java
@@ -31,12 +31,10 @@ import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.util.Arrays;
import java.util.Collections;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Test;
-import org.sonar.wsclient.services.ResourceQuery;
import org.sonarqube.qa.util.SelenideConfig;
import org.sonarqube.ws.WsMeasures.Measure;
import org.sonarqube.ws.client.GetRequest;
@@ -55,9 +53,7 @@ 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_CURRENT = Version.create("DEV");
+ private static final Version DEV_VERSION = Version.create("DEV");
private Orchestrator orchestrator;
@@ -71,30 +67,22 @@ public class UpgradeTest {
@Test
public void test_upgrade_from_5_6_1() {
- testDatabaseUpgrade(VERSION_5_6_1);
+ testDatabaseUpgrade(Version.create("5.6.1"));
}
@Test
- public void test_upgrade_from_5_2_via_5_6_1() {
- testDatabaseUpgrade(VERSION_5_2, VERSION_5_6_1);
+ public void test_upgrade_from_6_7() {
+ testDatabaseUpgrade(Version.create("6.7"));
}
- private void testDatabaseUpgrade(Version fromVersion, Version... intermediaryVersions) {
+ private void testDatabaseUpgrade(Version fromVersion) {
startOldVersionServer(fromVersion, false);
scanProject();
int files = countFiles(PROJECT_KEY);
assertThat(files).isGreaterThan(0);
stopServer();
- Arrays.stream(intermediaryVersions).forEach((sqVersion) -> {
- startOldVersionServer(sqVersion, true);
- upgrade(sqVersion);
- verifyAnalysis(files);
- stopServer();
- });
-
- startDevServer();
- upgrade(VERSION_CURRENT);
+ startAndUpgradeDevServer();
verifyAnalysis(files);
stopServer();
}
@@ -106,19 +94,6 @@ public class UpgradeTest {
browseWebapp();
}
- private void upgrade(Version sqVersion) {
- checkSystemStatus(sqVersion, ServerStatusResponse.Status.DB_MIGRATION_NEEDED);
- if (sqVersion.equals(VERSION_CURRENT)) {
- checkUrlsBeforeUpgrade();
- }
- ServerMigrationResponse serverMigrationResponse = new ServerMigrationCall(orchestrator).callAndWait();
- 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(Version sqVersion, ServerStatusResponse.Status serverStatus) {
ServerStatusResponse serverStatusResponse = new ServerStatusCall(orchestrator).callAndWait();
@@ -186,7 +161,7 @@ public class UpgradeTest {
initSelenide(orchestrator);
}
- private void startDevServer() {
+ private void startAndUpgradeDevServer() {
OrchestratorBuilder builder = Orchestrator.builderEnv()
.setZipFile(FileLocation.byWildcardMavenFilename(new File("../sonar-application/target"), "sonar*.zip").getFile())
.setOrchestratorProperty("orchestrator.keepDatabase", "true")
@@ -196,6 +171,15 @@ public class UpgradeTest {
orchestrator = builder.build();
orchestrator.start();
initSelenide(orchestrator);
+
+ checkSystemStatus(DEV_VERSION, ServerStatusResponse.Status.DB_MIGRATION_NEEDED);
+ checkUrlsBeforeUpgrade();
+ ServerMigrationResponse serverMigrationResponse = new ServerMigrationCall(orchestrator).callAndWait();
+ assertThat(serverMigrationResponse.getStatus())
+ .describedAs("Migration status should be MIGRATION_SUCCEEDED")
+ .isEqualTo(ServerMigrationResponse.Status.MIGRATION_SUCCEEDED);
+ checkSystemStatus(DEV_VERSION, ServerStatusResponse.Status.UP);
+ checkUrlsAfterUpgrade();
}
private void stopServer() {
@@ -217,12 +201,9 @@ public class UpgradeTest {
}
private int countFiles(String key) {
- if (orchestrator.getConfiguration().getSonarVersion().isGreaterThanOrEquals("5.4")) {
- Measure measure = newWsClient(orchestrator).measures().component(new ComponentWsRequest().setComponentKey(key).setMetricKeys(Collections.singletonList("files")))
- .getComponent().getMeasures(0);
- return parseInt(measure.getValue());
- }
- return orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(key, "files")).getMeasureIntValue("files");
+ Measure measure = newWsClient(orchestrator).measures().component(new ComponentWsRequest().setComponentKey(key).setMetricKeys(Collections.singletonList("files")))
+ .getComponent().getMeasures(0);
+ return parseInt(measure.getValue());
}
private void testUrl(String path) {