Пример #1
0
 @CheckForNull
 public File get(Version version) {
   if (version.isRelease()) {
     File file = locateRelease(version);
     return file.exists() ? file : null;
   }
   return SNAPSHOTS.get(version);
 }
Пример #2
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;
 }
Пример #3
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");
    }
  }
Пример #4
0
 private File locateRelease(Version version) {
   String filename = format("sonarqube-%s.zip", version.toString());
   return new File(fs.sonarInstallsDir(), filename);
 }