diff --git a/.cirrus.yml b/.cirrus.yml
index 99b71453..96ce6213 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -87,7 +87,7 @@ qa_task:
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *CONTAINER_DEFINITION
- cpu: 2
+ cpu: 6
memory: 4G
env:
matrix:
diff --git a/its/projects/maven/aggregator-inherit-parent-and-bind-to-verify/pom.xml b/its/projects/maven/aggregator-inherit-parent-and-bind-to-verify/pom.xml
index 69320fd8..f4d51a6e 100644
--- a/its/projects/maven/aggregator-inherit-parent-and-bind-to-verify/pom.xml
+++ b/its/projects/maven/aggregator-inherit-parent-and-bind-to-verify/pom.xml
@@ -7,7 +7,7 @@
1.0-SNAPSHOT
parent/pom.xml
- aggregator
+ aggregator-inherit-parent
1.0-SNAPSHOT
pom
diff --git a/its/projects/maven/bootstrap-small-project/pom.xml b/its/projects/maven/bootstrap-small-project/pom.xml
new file mode 100644
index 00000000..9fca131d
--- /dev/null
+++ b/its/projects/maven/bootstrap-small-project/pom.xml
@@ -0,0 +1,13 @@
+
+ 4.0.0
+ org.sonarsource.maven.its
+ bootstrap-small-project
+ 1.0-SNAPSHOT
+
+
+ 22
+ 22
+
+
+
diff --git a/its/projects/project-default-config/pom.xml b/its/projects/project-default-config/pom.xml
index a2ce5327..350aaed8 100644
--- a/its/projects/project-default-config/pom.xml
+++ b/its/projects/project-default-config/pom.xml
@@ -21,8 +21,8 @@
maven-compiler-plugin
3.3
-
- 1.7
+
+ 1.8
diff --git a/its/projects/version/compilerPluginConfig/pom.xml b/its/projects/version/compilerPluginConfig/pom.xml
index bf4d5476..5ae578cf 100644
--- a/its/projects/version/compilerPluginConfig/pom.xml
+++ b/its/projects/version/compilerPluginConfig/pom.xml
@@ -23,7 +23,7 @@
maven-compiler-plugin
3.3
-
+
1.8
diff --git a/its/projects/version/properties/pom.xml b/its/projects/version/properties/pom.xml
index eabe5320..723fd9c8 100644
--- a/its/projects/version/properties/pom.xml
+++ b/its/projects/version/properties/pom.xml
@@ -6,7 +6,7 @@
Sonar :: Integration Tests :: Java Version
- 1.7
+ 1.8
1.8
diff --git a/its/src/test/java/com/sonar/maven/it/suite/AbstractMavenTest.java b/its/src/test/java/com/sonar/maven/it/suite/AbstractMavenTest.java
index cfa3a05d..b082bb63 100644
--- a/its/src/test/java/com/sonar/maven/it/suite/AbstractMavenTest.java
+++ b/its/src/test/java/com/sonar/maven/it/suite/AbstractMavenTest.java
@@ -21,6 +21,7 @@
import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonValue;
+import com.sonar.orchestrator.build.Build;
import com.sonar.orchestrator.build.BuildResult;
import com.sonar.orchestrator.build.MavenBuild;
import com.sonar.orchestrator.container.Server;
@@ -33,6 +34,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
@@ -44,6 +46,9 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonarqube.ws.Ce.TaskStatus;
import org.sonarqube.ws.Components.Component;
import org.sonarqube.ws.Measures;
import org.sonarqube.ws.Measures.Measure;
@@ -51,15 +56,22 @@
import org.sonarqube.ws.client.HttpException;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsClientFactories;
+import org.sonarqube.ws.client.ce.TaskRequest;
import org.sonarqube.ws.client.components.ShowRequest;
import org.sonarqube.ws.client.components.TreeRequest;
import org.sonarqube.ws.client.measures.ComponentRequest;
import static java.util.Collections.singletonList;
+import static org.assertj.core.api.Assertions.assertThat;
public abstract class AbstractMavenTest {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractMavenTest.class);
+
+ public static final int EXEC_SUCCESS = 0;
+ public static final int EXEC_FAILED = 1;
+
private static final Pattern VERSION_REGEX = Pattern.compile("Apache Maven\\s(\\d+\\.\\d+(?:\\.\\d+)?)(?:-\\S+)?\\s");
private static Version mojoVersion;
@@ -94,6 +106,9 @@ public static void setUp() {
public static void tearDown() {
synchronized (AbstractMavenTest.class) {
orchestratorAccessingClassCount--;
+ if (orchestratorAccessingClassCount < 0) {
+ throw new IllegalStateException("tearDown called too many times");
+ }
if (orchestratorAccessingClassCount == 0) {
ORCHESTRATOR.stop();
}
@@ -219,6 +234,13 @@ static WsClient newWsClient() {
.build());
}
+ static WsClient newAuthenticatedWsClient() {
+ return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
+ .url(ORCHESTRATOR.getServer().getUrl())
+ .credentials(Server.ADMIN_LOGIN, Server.ADMIN_PASSWORD)
+ .build());
+ }
+
Version mavenVersion = null;
protected Version getMavenVersion() {
@@ -229,7 +251,7 @@ protected Version getMavenVersion() {
MavenBuild build = MavenBuild.create()
.setGoals("-version");
- BuildResult result = ORCHESTRATOR.executeBuild(build);
+ BuildResult result = assertBuildResultStatuses( ORCHESTRATOR.executeBuild(build), 0);
String logs = result.getLogs();
Matcher matcher = VERSION_REGEX.matcher(logs);
@@ -246,4 +268,84 @@ private static String getSonarVersion() {
return versionProperty != null ? versionProperty : "LATEST_RELEASE";
}
+ public BuildResult executeBuildAndValidateWithCE(Build> build) {
+ return validateBuildWithCE(ORCHESTRATOR.executeBuild(build));
+ }
+
+ public static BuildResult validateBuildWithCE(BuildResult result) {
+ assertBuildResultStatuses(result, 0);
+ List ceTaskIds = extractCETaskIds(result);
+ if (ceTaskIds.isEmpty()) {
+ throw new AssertionError("No CE task id found in logs, can't wait for the CE task to be finished");
+ }
+ for (String ceTaskId : ceTaskIds) {
+ waitForCeTaskToBeFinished(ceTaskId);
+ }
+ return result;
+ }
+
+ public BuildResult executeBuildAndValidateWithoutCE(Build> build) {
+ return validateBuildWithoutCE(ORCHESTRATOR.executeBuild(build));
+ }
+
+ public static BuildResult validateBuildWithoutCE(BuildResult result) {
+ return validateBuildWithoutCE(result, EXEC_SUCCESS);
+ }
+
+ public static BuildResult validateBuildWithoutCE(BuildResult result, int expectedStatus) {
+ assertBuildResultStatuses(result, expectedStatus);
+ assertThat(extractCETaskIds(result))
+ .withFailMessage("The build result contains unexpected CE task ids")
+ .isEmpty();
+ return result;
+ }
+
+ public static BuildResult assertBuildResultStatuses(BuildResult result, int expectedStatus) {
+ for (Integer status : result.getStatuses()) {
+ assertThat(status).isEqualTo(expectedStatus);
+ }
+ return result;
+ }
+
+ // [INFO] More about the report processing at http://127.0.0.1:63532/api/ce/task?id=bedf3100-4d72-497b-8103-68402821e49c
+ private static final Pattern CE_TASK_ID_PATTERN = Pattern.compile("More about the report processing at[^?]++\\?id=([\\w\\-]++)");
+
+ public static final List extractCETaskIds(BuildResult result) {
+ Matcher matcher = CE_TASK_ID_PATTERN.matcher(result.getLogs());
+ List ids = new ArrayList<>();
+ while (matcher.find()) {
+ ids.add(matcher.group(1));
+ }
+ return ids;
+ }
+
+ private static final long POLLING_TIME = 500; // 0.5 second
+ private static final long MAX_WAIT_TIME = 20_000; // 20 seconds
+
+ private static void waitForCeTaskToBeFinished(String ceTaskId) {
+ LOG.info("Waiting for CE task {} to be finished", ceTaskId);
+ try {
+ WsClient wsClient = newAuthenticatedWsClient();
+ long start = System.currentTimeMillis();
+ while (true) {
+ TaskStatus status = wsClient.ce().task(new TaskRequest().setId(ceTaskId)).getTask().getStatus();
+ if (status == TaskStatus.PENDING || status == TaskStatus.IN_PROGRESS) {
+ if (System.currentTimeMillis() - start > MAX_WAIT_TIME) {
+ throw new AssertionError("CE task " + ceTaskId + " did not finish after " + (MAX_WAIT_TIME / 1000) + " seconds");
+ }
+ Thread.sleep(POLLING_TIME);
+ } else if (status == TaskStatus.SUCCESS) {
+ LOG.info("CE task {} succeeded", ceTaskId);
+ return;
+ } else {
+ // FAILED or CANCELED
+ throw new AssertionError("CE task " + ceTaskId + " failed: " + status.name());
+ }
+
+ }
+ } catch (InterruptedException e) {
+ throw new AssertionError("Interrupted while waiting for CE task to be finished", e);
+ }
+ }
+
}
diff --git a/its/src/test/java/com/sonar/maven/it/suite/BootstrapTest.java b/its/src/test/java/com/sonar/maven/it/suite/BootstrapTest.java
index 2582ebe2..22f241f3 100644
--- a/its/src/test/java/com/sonar/maven/it/suite/BootstrapTest.java
+++ b/its/src/test/java/com/sonar/maven/it/suite/BootstrapTest.java
@@ -40,14 +40,14 @@ void test_unsupported_platform() {
String arch = "amd64";
BuildRunner runner = new BuildRunner(ORCHESTRATOR.getConfiguration());
- MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/aggregator-inherit-parent"))
+ MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/bootstrap-small-project"))
.setProperty("sonar.scanner.os", unsupportedOS)
.setProperty("sonar.scanner.arch", arch)
.setProperty("sonar.login", ORCHESTRATOR.getDefaultAdminToken())
.setProperty("sonar.host.url", ORCHESTRATOR.getServer().getUrl())
.setGoals(cleanSonarGoal());
- BuildResult result = runner.runQuietly(null, build);
+ BuildResult result = validateBuildWithoutCE(runner.runQuietly(null, build), EXEC_FAILED);
if (ORCHESTRATOR.getServer().version().isGreaterThanOrEquals(10, 6)) {
assertThat(result.isSuccess()).isFalse();
@@ -63,14 +63,14 @@ void test_unsupported_platform() {
@Test
void test_supported_arch_to_assert_jre_used() throws IOException {
BuildRunner runner = new BuildRunner(ORCHESTRATOR.getConfiguration());
- String projectName = "maven/aggregator-inherit-parent";
+ String projectName = "maven/bootstrap-small-project";
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom(projectName))
.setProperty("sonar.login", ORCHESTRATOR.getDefaultAdminToken())
.setProperty("sonar.host.url", ORCHESTRATOR.getServer().getUrl())
.setGoals(cleanSonarGoal());
- BuildResult result = runner.runQuietly(null, build);
+ BuildResult result = validateBuildWithCE(runner.runQuietly(null, build));
assertThat(result.isSuccess()).isTrue();
Path propertiesFile = ItUtils.locateProjectDir(projectName).toPath().resolve("target/sonar/dumpSensor.system.properties");
Properties props = new Properties();
diff --git a/its/src/test/java/com/sonar/maven/it/suite/JavaTest.java b/its/src/test/java/com/sonar/maven/it/suite/JavaTest.java
index bcf27cac..31c4b583 100644
--- a/its/src/test/java/com/sonar/maven/it/suite/JavaTest.java
+++ b/its/src/test/java/com/sonar/maven/it/suite/JavaTest.java
@@ -58,7 +58,7 @@ void shouldPopulateLibraries() throws IOException {
MavenBuild build = MavenBuild.create(projectPom)
.setGoals(cleanPackageSonarGoal())
.setProperty("sonar.scanner.internal.dumpToFile", outputProps.getAbsolutePath());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithoutCE(build);
Properties generatedProps = getProps(outputProps);
String[] moduleIds = generatedProps.getProperty("sonar.modules").split(",");
@@ -85,14 +85,14 @@ void read_default_from_plugins_config() throws Exception {
MavenBuild build = MavenBuild.create(pom)
.setGoals(cleanPackageSonarGoal())
.setProperty("sonar.scanner.internal.dumpToFile", outputProps.getAbsolutePath());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithoutCE(build);
Properties props = getProps(outputProps);
assertThat(props).contains(
entry("sonar.findbugs.excludeFilters", new File(pom.getParentFile(), "findbugs-filter.xml").toString()),
entry("sonar.junit.reportsPath", new File(pom.getParentFile(), "target/surefire-output").toString()),
entry("sonar.junit.reportPaths", new File(pom.getParentFile(), "target/surefire-output").toString()),
- entry("sonar.java.source", "1.7"));
+ entry("sonar.java.source", "1.8"));
}
@Test
@@ -104,11 +104,11 @@ void setJavaVersionCompilerConfiguration() throws IOException {
MavenBuild build = MavenBuild.create(pom)
.setGoals(cleanPackageSonarGoal())
.setProperty("sonar.scanner.internal.dumpToFile", outputProps.getAbsolutePath());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithoutCE(build);
Properties props = getProps(outputProps);
assertThat(props).contains(
- entry("sonar.java.source", "1.7"),
+ entry("sonar.java.source", "1.8"),
entry("sonar.java.target", "1.8"));
}
@@ -121,11 +121,11 @@ void setJavaVersionProperties() throws IOException {
MavenBuild build = MavenBuild.create(pom)
.setGoals(cleanPackageSonarGoal())
.setProperty("sonar.scanner.internal.dumpToFile", outputProps.getAbsolutePath());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithoutCE(build);
Properties props = getProps(outputProps);
assertThat(props).contains(
- entry("sonar.java.source", "1.7"),
+ entry("sonar.java.source", "1.8"),
entry("sonar.java.target", "1.8"));
}
@@ -138,7 +138,7 @@ void setJdkHomeFromCompilerExecutableConfiguration() throws IOException {
MavenBuild build = MavenBuild.create(pom)
.setGoals(sonarGoal())
.setProperty("sonar.scanner.internal.dumpToFile", outputProps.getAbsolutePath());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithoutCE(build);
Properties props = getProps(outputProps);
String expected = "path/to/java_executable".replace('/', File.separatorChar);
@@ -157,7 +157,7 @@ void setJdkHomeFromGlobalToolchainsPlugin() throws IOException {
.setGoals("toolchains:toolchain " + sonarGoal())
.addArguments("--toolchains", new File(pom.getParent(), "toolchains.xml").getAbsolutePath())
.setProperty("sonar.scanner.internal.dumpToFile", outputProps.getAbsolutePath());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithoutCE(build);
Properties props = getProps(outputProps);
assertThat(props).contains(entry("sonar.java.jdkHome", "fake_jdk_1.5"));
@@ -177,7 +177,7 @@ void setJdkHomeFromCompilerToolchainsConfiguration() throws IOException {
.setGoals(sonarGoal())
.addArguments("--toolchains", new File(pom.getParent(), "toolchains.xml").getAbsolutePath())
.setProperty("sonar.scanner.internal.dumpToFile", outputProps.getAbsolutePath());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithoutCE(build);
Properties props = getProps(outputProps);
assertThat(props).contains(entry("sonar.java.jdkHome", "fake_jdk_1.6"));
@@ -197,7 +197,7 @@ void takeFirstToolchainIfMultipleExecutions() throws IOException {
.setGoals(sonarGoal())
.addArguments("--toolchains", new File(pom.getParent(), "toolchains.xml").getAbsolutePath())
.setProperty("sonar.scanner.internal.dumpToFile", outputProps.getAbsolutePath());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithoutCE(build);
Properties props = getProps(outputProps);
assertThat(props).contains(entry("sonar.java.jdkHome", "fake_jdk_9"));
diff --git a/its/src/test/java/com/sonar/maven/it/suite/LinksTest.java b/its/src/test/java/com/sonar/maven/it/suite/LinksTest.java
index 30c8e908..f1006104 100644
--- a/its/src/test/java/com/sonar/maven/it/suite/LinksTest.java
+++ b/its/src/test/java/com/sonar/maven/it/suite/LinksTest.java
@@ -44,17 +44,14 @@ void shouldUseLinkPropertiesOverPomLinksInMaven() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("batch/links-project"))
.setGoals(cleanPackageSonarGoal())
.setProperty("sonar.scm.disabled", "true");
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
checkLinks();
}
private void checkLinks() {
Server server = ORCHESTRATOR.getServer();
- WsClient client = WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
- .url(server.getUrl())
- .credentials(Server.ADMIN_LOGIN, Server.ADMIN_PASSWORD)
- .build());
+ WsClient client = newAuthenticatedWsClient();
SearchWsResponse response = client.projectLinks().search(new SearchRequest().setProjectKey("com.sonarsource.it.samples:simple-sample"));
if (server.version().isGreaterThanOrEquals(7, 1)) {
// SONAR-10299
diff --git a/its/src/test/java/com/sonar/maven/it/suite/MavenTest.java b/its/src/test/java/com/sonar/maven/it/suite/MavenTest.java
index 0f11f971..573092ff 100644
--- a/its/src/test/java/com/sonar/maven/it/suite/MavenTest.java
+++ b/its/src/test/java/com/sonar/maven/it/suite/MavenTest.java
@@ -24,9 +24,7 @@
import com.sonar.orchestrator.build.BuildRunner;
import com.sonar.orchestrator.build.MavenBuild;
import java.io.File;
-import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.AfterEach;
@@ -88,9 +86,8 @@ void supportSonarHostURLParam() {
.setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org:9000")
.setGoals(cleanSonarGoal());
- BuildResult result = runner.runQuietly(null, build);
+ BuildResult result = validateBuildWithoutCE(runner.runQuietly(null, build), EXEC_FAILED);
- assertThat(result.isSuccess()).isFalse();
assertThat(result.getLogs()).contains("java.net.UnknownHostException: from-env.org");
}
@@ -104,9 +101,7 @@ void supportSonarHostURLParamFromEnvironmentVariable() {
.setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org:9000")
.setGoals(cleanSonarGoal());
- BuildResult result = runner.runQuietly(null, build);
-
- assertThat(result.isSuccess()).isFalse();
+ BuildResult result = validateBuildWithoutCE(runner.runQuietly(null, build), EXEC_FAILED);
assertThat(result.getLogs()).contains("http://from-env.org:9000");
}
@@ -117,7 +112,7 @@ void supportSonarHostURLParamFromEnvironmentVariable() {
void structureWithRelativePaths() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-structure-relative-paths"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
}
/**
@@ -127,14 +122,14 @@ void structureWithRelativePaths() {
void flatStructure() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-flat-layout/parent"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
}
@Test
void aggregatorInheritParent() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/aggregator-inherit-parent"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("org.sonarsource.maven.its:aggregator", "files")).isEqualTo(4); // 4 x pom.xml
}
@@ -143,15 +138,15 @@ void aggregatorInheritParentAndSonarAttachedToPhase() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/aggregator-inherit-parent-and-bind-to-verify"))
.setGoals("clean verify")
.setProperty("sonar.maven.it.mojoVersion", mojoVersion().toString());
- ORCHESTRATOR.executeBuild(build);
- assertThat(getMeasureAsInteger("org.sonarsource.maven.its:aggregator", "files")).isEqualTo(4); // 4 x pom.xml
+ executeBuildAndValidateWithCE(build);
+ assertThat(getMeasureAsInteger("org.sonarsource.maven.its:aggregator-inherit-parent", "files")).isEqualTo(4); // 4 x pom.xml
}
@Test
void shouldSupportJarWithoutSources() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/project-with-module-without-sources"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.project-with-module-without-sources:parent", "files")).isEqualTo(4);
assertThat(getComponent("com.sonarsource.it.samples.project-with-module-without-sources:parent:without-sources")).isNotNull();
@@ -164,7 +159,7 @@ void shouldSupportJarWithoutSources() {
void shouldSupportJeeProjects() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/jee"))
.setGoals(cleanInstallSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
// src/main/webapp is analyzed by web and xml plugin
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.jee:parent", "files")).isEqualTo(9);
@@ -177,7 +172,7 @@ void shouldSupportJeeProjects() {
void shouldSupportMavenExtensions() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-extensions"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:maven-extensions", "files")).isEqualTo(2);
}
@@ -190,7 +185,7 @@ void testBadMavenParameters() {
// should not fail
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-parameters"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.maven-bad-parameters:parent", "files")).isPositive();
}
@@ -199,7 +194,7 @@ void testBadMavenParameters() {
void shouldAnalyzeMultiModules() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/modules-order"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getComponent("org.sonar.tests.modules-order:root").getName()).isEqualTo("Sonar tests - modules order");
@@ -216,7 +211,7 @@ void shouldAnalyzeMultiModules() {
void shouldEvaluateSourceVersionOnEachModule() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/modules-source-versions"))
.setGoals(cleanSonarGoal());
- BuildResult buildResult = ORCHESTRATOR.executeBuild(build);
+ BuildResult buildResult = executeBuildAndValidateWithCE(build);
assertThat(findScanSectionOfModule(buildResult.getLogs(), "higher-version")).contains("Configured Java source version (sonar.java.source): 8");
assertThat(findScanSectionOfModule(buildResult.getLogs(), "same-version")).contains("Configured Java source version (sonar.java.source): 6");
@@ -239,7 +234,7 @@ void shouldAnalyzeMultiModulesAttachedToPhase() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/attach-sonar-to-verify"))
.setGoals("clean verify")
.setProperty("sonar.maven.it.mojoVersion", mojoVersion().toString());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getComponent("com.sonarsource.it.samples:attach-sonar-to-verify")).isNotNull();
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:attach-sonar-to-verify", "files")).isEqualTo(11);
@@ -252,7 +247,7 @@ void shouldAnalyzeMultiModulesAttachedToPhase() {
void shouldSupportDifferentDeclarationsForModules() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/modules-declaration"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getComponent("org.sonar.tests.modules-declaration:root").getName()).isEqualTo("Root");
@@ -288,7 +283,7 @@ void should_support_shade_with_dependency_reduced_pom_with_clean_package_sonar_g
MavenBuild build = MavenBuild.create(projectLocation)
.setGoals(cleanPackageSonarGoal());
- BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
+ BuildResult result = executeBuildAndValidateWithCE(build);
// Test a reduced pom has peen produced as a result of clean package
assertThat(dependencyReducedPom).exists();
@@ -321,7 +316,7 @@ void should_support_shade_with_dependency_reduced_pom_with_clean_package_sonar_g
void maven_project_with_only_test_dir() {
// Need package to have test execution
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-only-test-dir")).setGoals(cleanPackageSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:maven-only-test-dir", "tests")).isEqualTo(1);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:maven-only-test-dir", "files")).isEqualTo(1);
@@ -333,7 +328,7 @@ void maven_project_with_only_test_dir() {
@Test
void override_sources() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-override-sources")).setGoals(sonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:maven-override-sources", "files")).isEqualTo(1);
assertThat(getComponent("com.sonarsource.it.samples:maven-override-sources:src/main/java2/Hello2.java")).isNotNull();
@@ -345,7 +340,7 @@ void override_sources() {
@Test
void override_sources_in_multi_module() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/multi-modules-override-sources")).setGoals(sonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:multi-modules-sample:module_a", "files")).isEqualTo(2);
@@ -358,7 +353,7 @@ void override_sources_in_multi_module() {
void override_sources_in_multi_module_aggregator() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/multi-module-aggregator"))
.setGoals(sonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("edu.marcelo:multi-module-aggregator:module-web/src/main/webapp", "files")).isEqualTo(2);
}
@@ -369,7 +364,7 @@ void override_sources_in_multi_module_aggregator() {
@Test
void inclusions_apply_to_source_dirs() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/inclusions_apply_to_source_dirs")).setGoals(sonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:inclusions_apply_to_source_dirs", "files")).isEqualTo(1);
assertThat(getComponent("com.sonarsource.it.samples:inclusions_apply_to_source_dirs:src/main/java/Hello2.java")).isNotNull();
@@ -381,8 +376,7 @@ void inclusions_apply_to_source_dirs() {
@Test
void fail_if_bad_value_of_sonar_sources_property() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-sources-property")).setGoals(sonarGoal());
- BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
- assertThat(result.getLastStatus()).isNotZero();
+ BuildResult result = validateBuildWithoutCE(ORCHESTRATOR.executeBuildQuietly(build), EXEC_FAILED);
assertThat(result.getLogs()).contains(
"java2' does not exist for Maven module com.sonarsource.it.samples:maven-bad-sources-property:jar:1.0-SNAPSHOT. Please check the property sonar.sources");
}
@@ -393,8 +387,7 @@ void fail_if_bad_value_of_sonar_sources_property() {
@Test
void fail_if_bad_value_of_sonar_tests_property() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-tests-property")).setGoals(sonarGoal());
- BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
- assertThat(result.getLastStatus()).isNotZero();
+ BuildResult result = validateBuildWithoutCE(ORCHESTRATOR.executeBuildQuietly(build), EXEC_FAILED);
assertThat(result.getLogs()).contains(
"java2' does not exist for Maven module com.sonarsource.it.samples:maven-bad-tests-property:jar:1.0-SNAPSHOT. Please check the property sonar.tests");
}
@@ -404,7 +397,7 @@ void fail_if_bad_value_of_sonar_tests_property() {
void shouldSkipModules() {
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("exclusions/skip-one-module"))
.setGoals(cleanSonarGoal());
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
assertThat(getComponent("com.sonarsource.it.samples:multi-modules-sample:module_a/module_a1")).isNull();
assertThat(getComponent("com.sonarsource.it.samples:multi-modules-sample:module_a/module_a2").getName()).isEqualTo("module_a2");
@@ -418,8 +411,9 @@ void shouldSkipWithEnvVar() {
.setGoals(cleanSonarGoal())
.setProperties("sonar.host.url", "invalid")
.setEnvironmentVariable("SONARQUBE_SCANNER_PARAMS", "{ \"sonar.scanner.skip\" : \"true\" }");
- BuildResult result = ORCHESTRATOR.executeBuild(build);
+ BuildResult result = executeBuildAndValidateWithoutCE(build);
assertThat(result.getLogs()).contains("SonarQube Scanner analysis skipped");
+ assertThat(extractCETaskIds(result)).isEmpty();
}
/**
@@ -442,7 +436,7 @@ void supportMavenEncryption() throws Exception {
build.addArgument("-Dsettings.security=" + securityXml.getAbsolutePath());
build.setProperty("sonar.login", "julien");
build.addArgument("-Psonar-password");
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
});
}
@@ -462,7 +456,7 @@ void supportMavenEncryptionWithDefaultSecuritySettings() throws Exception {
build.setProperty("sonar.login", "julien3");
build.addArgument("-Psonar-password");
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
});
Assertions.assertDoesNotThrow(() -> {
@@ -479,7 +473,7 @@ void supportMavenEncryptionWithDefaultSecuritySettings() throws Exception {
build.addArgument("-Dsettings.security=" + securityXml.getAbsolutePath());
build.setProperty("sonar.login", "julien2");
build.addArgument("-Psonar-password");
- ORCHESTRATOR.executeBuild(build);
+ executeBuildAndValidateWithCE(build);
});
}
}
diff --git a/its/src/test/java/com/sonar/maven/it/suite/ProxyTest.java b/its/src/test/java/com/sonar/maven/it/suite/ProxyTest.java
index 821d8cb0..dbc838e6 100644
--- a/its/src/test/java/com/sonar/maven/it/suite/ProxyTest.java
+++ b/its/src/test/java/com/sonar/maven/it/suite/ProxyTest.java
@@ -71,7 +71,7 @@ void useActiveProxyInSettings() throws IOException, URISyntaxException, Interrup
build.addArgument("--settings=" + proxyXmlPatched.toAbsolutePath().toString());
build.addArgument("-X");
build.addArgument("-U");
- BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
+ BuildResult result = executeBuildAndValidateWithCE(build);
assertThat(result.getLogs()).contains("Setting proxy properties");
assertThat(proxy.seen()).isNotEmpty();