From: Julien HENRY Date: Thu, 3 Dec 2015 08:44:59 +0000 (+0100) Subject: Try to make IssuesModeTest::concurrent_issue_mode_on_existing_project more robust X-Git-Tag: 5.3-RC1~90 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=54ddd3a2ea84ae6f394f3886266e1692e62a31d5;p=sonarqube.git Try to make IssuesModeTest::concurrent_issue_mode_on_existing_project more robust --- diff --git a/it/it-plugins/batch-plugin/pom.xml b/it/it-plugins/batch-plugin/pom.xml index f7957cbc9a3..c0828f3b125 100644 --- a/it/it-plugins/batch-plugin/pom.xml +++ b/it/it-plugins/batch-plugin/pom.xml @@ -27,7 +27,6 @@ org.sonarsource.sonar-packaging-maven-plugin sonar-packaging-maven-plugin - 1.15 true com.sonarsource.BatchPlugin diff --git a/it/it-plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java b/it/it-plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java index 422e9186a1d..7c4c479c64b 100644 --- a/it/it-plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java +++ b/it/it-plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java @@ -10,8 +10,8 @@ public class BatchPlugin extends SonarPlugin { return Arrays.asList( DumpSettingsInitializer.class, RaiseMessageException.class, - TempFolderExtension.class - ); + TempFolderExtension.class, + WaitingSensor.class); } } diff --git a/it/it-plugins/batch-plugin/src/main/java/com/sonarsource/WaitingSensor.java b/it/it-plugins/batch-plugin/src/main/java/com/sonarsource/WaitingSensor.java new file mode 100644 index 00000000000..05196cceace --- /dev/null +++ b/it/it-plugins/batch-plugin/src/main/java/com/sonarsource/WaitingSensor.java @@ -0,0 +1,29 @@ +package com.sonarsource; + +import org.sonar.api.batch.Sensor; +import org.sonar.api.batch.SensorContext; +import org.sonar.api.config.Settings; +import org.sonar.api.resources.Project; + +public class WaitingSensor implements Sensor { + private Settings settings; + + public WaitingSensor(Settings settings) { + this.settings = settings; + } + + @Override + public boolean shouldExecuteOnProject(Project project) { + return settings.getBoolean("sonar.it.enableWaitingSensor"); + } + + @Override + public void analyse(Project module, SensorContext context) { + try { + Thread.sleep(10_000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + +} diff --git a/it/it-tests/src/test/java/it/analysis/IssuesModeTest.java b/it/it-tests/src/test/java/it/analysis/IssuesModeTest.java index bb0b6d10b31..40c5866655f 100644 --- a/it/it-tests/src/test/java/it/analysis/IssuesModeTest.java +++ b/it/it-tests/src/test/java/it/analysis/IssuesModeTest.java @@ -397,7 +397,7 @@ public class IssuesModeTest { tasks.add(new Callable() { public BuildResult call() throws Exception { - SonarRunner runner = configureRunnerIssues("shared/xoo-sample", homeDir); + SonarRunner runner = configureRunnerIssues("shared/xoo-sample", homeDir, "sonar.it.enableWaitingSensor", "true"); return orchestrator.executeBuild(runner); } }); @@ -412,6 +412,8 @@ public class IssuesModeTest { BuildFailureException bfe = (BuildFailureException) e.getCause(); assertThat(bfe.getResult().getLogs()).contains("Another SonarQube analysis is already in progress for this project"); expectedError = true; + } else { + throw e; } } } diff --git a/it/pom.xml b/it/pom.xml index 575fded5120..dbf57f50be5 100644 --- a/it/pom.xml +++ b/it/pom.xml @@ -10,7 +10,6 @@ it - 5.3-SNAPSHOT SonarQube Integration Tests pom