]> source.dussan.org Git - sonarqube.git/commitdiff
Try to make IssuesModeTest::concurrent_issue_mode_on_existing_project more robust 668/head
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 3 Dec 2015 08:44:59 +0000 (09:44 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 3 Dec 2015 09:33:17 +0000 (10:33 +0100)
it/it-plugins/batch-plugin/pom.xml
it/it-plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java
it/it-plugins/batch-plugin/src/main/java/com/sonarsource/WaitingSensor.java [new file with mode: 0644]
it/it-tests/src/test/java/it/analysis/IssuesModeTest.java
it/pom.xml

index f7957cbc9a30f32d5f15d0e4d9e46eb0bab21af9..c0828f3b12521a7d9f7b13b6b220b10c4a604425 100644 (file)
@@ -27,7 +27,6 @@
       <plugin>
         <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
         <artifactId>sonar-packaging-maven-plugin</artifactId>
-        <version>1.15</version>
         <extensions>true</extensions>
         <configuration>
           <pluginClass>com.sonarsource.BatchPlugin</pluginClass>
index 422e9186a1d9d9ea47084485404c3790a881a3c8..7c4c479c64b41f24436f844d4dc4741f328061bb 100644 (file)
@@ -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 (file)
index 0000000..05196cc
--- /dev/null
@@ -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();
+    }
+  }
+
+}
index bb0b6d10b31f64513f04c0bbc69a06d61ea014ea..40c5866655fc9bedd7997f0ad890b474a6d08af5 100644 (file)
@@ -397,7 +397,7 @@ public class IssuesModeTest {
       tasks.add(new Callable<BuildResult>() {
 
         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;
         }
       }
     }
index 575fded5120ed6f4426863d9763f1b0430ae81e4..dbf57f50be56435b9a1cf25e106d56d201151cb8 100644 (file)
@@ -10,7 +10,6 @@
   </parent>
 
   <artifactId>it</artifactId>
-  <version>5.3-SNAPSHOT</version>
   <name>SonarQube Integration Tests</name>
   <packaging>pom</packaging>