use of com.sonar.orchestrator.config.FileSystem 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");
}
}
use of com.sonar.orchestrator.config.FileSystem in project sonar-scanner-jenkins by SonarSource.
the class JenkinsOrchestrator method start.
public void start() {
if (started.getAndSet(true)) {
throw new IllegalStateException("Jenkins is already started");
}
int port = config.getInt("jenkins.container.port", 0);
if (port <= 0) {
port = NetworkUtils.getNextAvailablePort(NetworkUtils.getLocalhost());
}
distribution.setPort(port);
FileSystem fileSystem = config.fileSystem();
ServerInstaller serverInstaller = new ServerInstaller(fileSystem);
server = serverInstaller.install(distribution);
server.setUrl(String.format("http://localhost:%d", port));
jenkinsWrapper = new JenkinsWrapper(server, config, fileSystem.javaHome(), port);
jenkinsWrapper.start();
FirefoxProfile profile = new FirefoxProfile();
// force language to be English
profile.setPreference("intl.accept_languages", "en");
FirefoxOptions options = new FirefoxOptions().setProfile(profile);
driver = new FirefoxDriver(options);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get(server.getUrl());
// Fix window size for having reproducible test behavior
driver.manage().window().setPosition(new Point(20, 20));
driver.manage().window().setSize(new Dimension(1024, 768));
try {
cli = new CLI(new URL(server.getUrl()));
} catch (Exception e) {
throw new RuntimeException(e);
}
// Force updatecenter initialization
driver.get(server.getUrl() + "/pluginManager");
findElement(By.linkText("Advanced")).click();
findElement(buttonByText("Check now")).click();
}
Aggregations