aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-12-09 12:41:42 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-12-11 21:30:02 +0100
commit28bf1b05baa7b1e1c9619ce21ac40b9d0d3fe7f5 (patch)
tree9b37db6c23c277a60dca58e641061d697d967136 /tests
parent0ae9b2c4cd8023b8d61911a15769445e91a50aff (diff)
downloadsonarqube-28bf1b05baa7b1e1c9619ce21ac40b9d0d3fe7f5.tar.gz
sonarqube-28bf1b05baa7b1e1c9619ce21ac40b9d0d3fe7f5.zip
Use local SonarQube ZIP in performance and upgrade tests
Diffstat (limited to 'tests')
-rw-r--r--tests/perf/pom.xml1
-rw-r--r--tests/pom.xml46
-rw-r--r--tests/upgrade/pom.xml4
-rw-r--r--tests/upgrade/src/test/java/org/sonarsource/sonarqube/upgrade/UpgradeTest.java99
4 files changed, 98 insertions, 52 deletions
diff --git a/tests/perf/pom.xml b/tests/perf/pom.xml
index 65accd26741..7ef689fdb72 100644
--- a/tests/perf/pom.xml
+++ b/tests/perf/pom.xml
@@ -14,6 +14,7 @@
<properties>
<category>*</category>
+ <sqZipDir>../../sonar-application/target</sqZipDir>
</properties>
<build>
diff --git a/tests/pom.xml b/tests/pom.xml
index 9144214c587..6f4440b9187 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -17,6 +18,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
<source.skip>true</source.skip>
<enforcer.skip>true</enforcer.skip>
+ <sqZipDir>../sonar-application/target</sqZipDir>
</properties>
<modules>
@@ -24,4 +26,46 @@
<module>upgrade</module>
</modules>
+ <profiles>
+ <profile>
+ <id>qa</id>
+ <activation>
+ <property>
+ <name>env.SONARSOURCE_QA</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-sonarqube-zip</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sonar-application</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${sqZipDir}</outputDirectory>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/tests/upgrade/pom.xml b/tests/upgrade/pom.xml
index 6c22dec4c96..7c1f0c5ae5e 100644
--- a/tests/upgrade/pom.xml
+++ b/tests/upgrade/pom.xml
@@ -12,6 +12,10 @@
<artifactId>upgrade</artifactId>
<name>SonarQube :: Upgrade Tests</name>
+ <properties>
+ <sqZipDir>../../sonar-application/target</sqZipDir>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
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 2f68a43c89f..bad5a01d7f7 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
@@ -24,7 +24,6 @@ import com.codeborne.selenide.WebDriverRunner;
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.OrchestratorBuilder;
import com.sonar.orchestrator.build.MavenBuild;
-import com.sonar.orchestrator.config.Configuration;
import com.sonar.orchestrator.container.Server;
import com.sonar.orchestrator.locator.FileLocation;
import com.sonar.orchestrator.version.Version;
@@ -33,7 +32,6 @@ import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
-import java.util.stream.Stream;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Test;
@@ -51,7 +49,6 @@ import static org.assertj.core.api.Assertions.assertThat;
public class UpgradeTest {
private static final String PROJECT_KEY = "org.apache.struts:struts-parent";
- private static final String SQ_VERSION_DEV = "DEV";
private static final String LATEST_JAVA_RELEASE = "LATEST_RELEASE";
private Orchestrator orchestrator;
@@ -66,40 +63,56 @@ public class UpgradeTest {
@Test
public void test_upgrade_from_5_6_1() {
- testDatabaseUpgrade("3.14", Version.create("5.6.1"));
+ testDatabaseUpgrade(Version.create("5.6.1"));
}
@Test
public void test_upgrade_from_5_2_via_5_6() {
- testDatabaseUpgrade("3.14", Version.create("5.2"), Version.create("5.6"));
+ testDatabaseUpgrade(Version.create("5.2"), Version.create("5.6"));
}
- private void testDatabaseUpgrade(String javaVersion, Version fromVersion, Version... intermediaryVersions) {
- startOldServer(fromVersion, javaVersion);
+ @Test
+ public void test_upgrade_from_6_0() {
+ testDatabaseUpgrade(Version.create("6.0"));
+ }
+
+ @Test
+ public void test_upgrade_from_6_1() {
+ testDatabaseUpgrade(Version.create("6.1"));
+ }
+
+ private void testDatabaseUpgrade(Version fromVersion, Version... intermediaryVersions) {
+ startOldVersionServer(fromVersion, false);
scanProject();
int files = countFiles(PROJECT_KEY);
assertThat(files).isGreaterThan(0);
stopServer();
- Stream.concat(Arrays.stream(intermediaryVersions).map(Version::toString), Stream.of(SQ_VERSION_DEV))
- .forEach((sqVersion) -> {
- upgradeTo(sqVersion, javaVersion);
+ Arrays.stream(intermediaryVersions).forEach((sqVersion) -> {
+ startOldVersionServer(sqVersion, true);
+ upgrade();
+ verifyAnalysis(files);
+ stopServer();
+ });
- assertThat(countFiles(PROJECT_KEY)).isEqualTo(files);
- scanProject();
- assertThat(countFiles(PROJECT_KEY)).isEqualTo(files);
- browseWebapp();
+ startDevServer();
+ upgrade();
+ verifyAnalysis(files);
+ stopServer();
+ }
- stopServer();
- });
+ private void verifyAnalysis(int expectedNumberOfFiles) {
+ assertThat(countFiles(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles);
+ scanProject();
+ assertThat(countFiles(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles);
+ browseWebapp();
}
- private void upgradeTo(String sqVersion, String javaVersion) {
- startNewServer(sqVersion, SQ_VERSION_DEV.equals(sqVersion) ? LATEST_JAVA_RELEASE : javaVersion);
+ private void upgrade() {
checkSystemStatus(ServerStatusResponse.Status.DB_MIGRATION_NEEDED);
- checkUrlsBeforeUpgrade(sqVersion);
-
- upgrade();
+ checkUrlsBeforeUpgrade();
+ ServerMigrationResponse serverMigrationResponse = new ServerMigrationCall(orchestrator).callAndWait();
+ assertThat(serverMigrationResponse.getStatus()).isEqualTo(ServerMigrationResponse.Status.MIGRATION_SUCCEEDED);
checkSystemStatus(ServerStatusResponse.Status.UP);
checkUrlsAfterUpgrade();
}
@@ -110,7 +123,7 @@ public class UpgradeTest {
assertThat(serverStatusResponse.getStatus()).isEqualTo(serverStatus);
}
- private void checkUrlsBeforeUpgrade(String sqVersion) {
+ private void checkUrlsBeforeUpgrade() {
// These urls should be available when system requires a migration
checkUrlIsReturningOk("/api/system/status");
checkUrlIsReturningOk("/api/system/db_migration_status");
@@ -159,32 +172,25 @@ public class UpgradeTest {
testUrl("/profiles");
}
- private void upgrade() {
- ServerMigrationResponse serverMigrationResponse = new ServerMigrationCall(orchestrator).callAndWait();
-
- assertThat(serverMigrationResponse.getStatus()).isEqualTo(ServerMigrationResponse.Status.MIGRATION_SUCCEEDED);
- }
-
- private void startOldServer(Version sqVersion, String javaVersion) {
- String jdbcUrl = MssqlConfig.fixUrl(Configuration.createEnv(), sqVersion);
- orchestrator = Orchestrator.builderEnv()
- .setOrchestratorProperty("sonar.jdbc.url", jdbcUrl)
+ private void startOldVersionServer(Version sqVersion, boolean keepDatabase) {
+ OrchestratorBuilder builder = Orchestrator.builderEnv()
.setSonarVersion(sqVersion.toString())
- .setOrchestratorProperty("orchestrator.keepDatabase", "false")
- .restoreProfileAtStartup(FileLocation.ofClasspath("/sonar-way-5.1.xml"))
- .setOrchestratorProperty("javaVersion", javaVersion)
- .addPlugin("java").build();
+ .setOrchestratorProperty("orchestrator.keepDatabase", String.valueOf(keepDatabase))
+ .setOrchestratorProperty("javaVersion", "3.14")
+ .addPlugin("java")
+ .setStartupLogWatcher(log -> log.contains("Process[web] is up"));
+ orchestrator = builder.build();
orchestrator.start();
initSelenide(orchestrator);
}
- private void startNewServer(String sqVersion, String javaVersion) {
+ private void startDevServer() {
OrchestratorBuilder builder = Orchestrator.builderEnv()
- .setSonarVersion(sqVersion)
+ .setZipFile(FileLocation.byWildcardMavenFilename(new File("../../sonar-application/target"), "sonar*.zip").getFile())
.setOrchestratorProperty("orchestrator.keepDatabase", "true")
- .setOrchestratorProperty("javaVersion", javaVersion)
- .setStartupLogWatcher(log -> log.contains("Process[web] is up"))
- .addPlugin("java");
+ .setOrchestratorProperty("javaVersion", LATEST_JAVA_RELEASE)
+ .addPlugin("java")
+ .setStartupLogWatcher(log -> log.contains("Process[web] is up"));
orchestrator = builder.build();
orchestrator.start();
initSelenide(orchestrator);
@@ -201,8 +207,7 @@ public class UpgradeTest {
.setCleanSonarGoals()
.setProperty("sonar.dynamicAnalysis", "false")
.setProperty("sonar.scm.disabled", "true")
- .setProperty("sonar.cpd.cross_project", "true")
- .setProperty("sonar.profile", "sonar-way-5.1");
+ .setProperty("sonar.cpd.cross_project", "true");
orchestrator.executeBuild(build);
}
@@ -238,14 +243,6 @@ public class UpgradeTest {
newWsClient(orchestrator).wsConnector().call(new GetRequest(url)).failIfNotSuccessful();
}
- // Some urls are available during migration only recently
- private void checkUrlIsReturningOkOnlyForDevVersion(String url, String sqVersion) {
- if (sqVersion.equals(SQ_VERSION_DEV)) {
- WsResponse wsResponse = newWsClient(orchestrator).wsConnector().call(new GetRequest(url));
- assertThat(wsResponse.isSuccessful()).as("SQ version %s", sqVersion).isTrue();
- }
- }
-
private void checkUrlIsReturningNotFound(String url) {
WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest(url));
assertThat(response.code()).isEqualTo(HttpURLConnection.HTTP_NOT_FOUND);