Esempio n. 1
0
 private File prepareAddToCache(Version version, File file) {
   File to;
   if (version.isRelease()) {
     to = locateRelease(version);
   } else {
     // do not rename the file, as it can differ from version
     to = new File(fs.workspace(), file.getName());
     SNAPSHOTS.put(version, to);
   }
   if (to.exists()) {
     FileUtils.deleteQuietly(to);
   }
   return to;
 }
Esempio n. 2
0
  private void runConcurrentIssues() throws InterruptedException, ExecutionException {
    // Install sonar-runner in advance to avoid concurrent unzip issues
    FileSystem fileSystem = orchestrator.getConfiguration().fileSystem();
    new SonarRunnerInstaller(fileSystem)
        .install(Version.create(SonarRunner.DEFAULT_RUNNER_VERSION), fileSystem.workspace());
    final int nThreads = 3;
    ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
    List<Callable<BuildResult>> tasks = new ArrayList<>();
    for (int i = 0; i < nThreads; i++) {
      tasks.add(
          new Callable<BuildResult>() {

            public BuildResult call() throws Exception {
              SonarRunner runner = configureRunnerIssues("shared/xoo-sample");
              return orchestrator.executeBuild(runner);
            }
          });
    }

    boolean expectedError = false;
    for (Future<BuildResult> result : executorService.invokeAll(tasks)) {
      try {
        result.get();
      } catch (ExecutionException e) {
        if (e.getCause() instanceof BuildFailureException) {
          BuildFailureException bfe = (BuildFailureException) e.getCause();
          assertThat(bfe.getResult().getLogs())
              .contains("Another SonarQube analysis is already in progress for this project");
          expectedError = true;
        }
      }
    }
    if (!expectedError) {
      fail("At least one of the threads should have failed");
    }
  }