use of com.sonar.orchestrator.build.BuildFailureException in project sonarqube by SonarSource.
the class OrganizationTest method by_default_anonymous_cannot_analyse_project_on_organization.
@Test
public void by_default_anonymous_cannot_analyse_project_on_organization() {
verifyNoExtraOrganization();
String orgKeyAndName = "org-key";
Organizations.Organization createdOrganization = adminOrganizationService.create(new CreateWsRequest.Builder().setName(orgKeyAndName).setKey(orgKeyAndName).build()).getOrganization();
verifySingleSearchResult(createdOrganization, orgKeyAndName, null, null, null);
try {
ItUtils.runProjectAnalysis(orchestrator, "shared/xoo-sample", "sonar.organization", orgKeyAndName);
fail();
} catch (BuildFailureException e) {
assertThat(e.getResult().getLogs()).contains("Insufficient privileges");
}
ComponentsService componentsService = ItUtils.newAdminWsClient(orchestrator).components();
assertThat(searchSampleProject(orgKeyAndName, componentsService).getComponentsCount()).isEqualTo(0);
adminOrganizationService.delete(orgKeyAndName);
}
use of com.sonar.orchestrator.build.BuildFailureException in project sonarqube by SonarSource.
the class IssuesModeTest method runConcurrentIssues.
private void runConcurrentIssues(final String workDirPath) throws Exception {
// Install sonar-runner in advance to avoid concurrent unzip issues
FileSystem fileSystem = orchestrator.getConfiguration().fileSystem();
new SonarScannerInstaller(fileSystem).install(Version.create(SonarScanner.DEFAULT_SCANNER_VERSION), fileSystem.workspace(), true);
final int nThreads = 3;
ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
List<Callable<BuildResult>> tasks = new ArrayList<>();
final File homeDir = temp.newFolder();
for (int i = 0; i < nThreads; i++) {
tasks.add(new Callable<BuildResult>() {
public BuildResult call() throws Exception {
SonarScanner runner = configureRunnerIssues("shared/xoo-sample", homeDir, "sonar.it.enableWaitingSensor", "true", "sonar.working.directory", workDirPath);
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;
} else {
throw e;
}
}
}
if (!expectedError) {
fail("At least one of the threads should have failed");
}
}
Aggregations