private static final String USER = "sonar";
private static final String PASSWORD = "sonar";
- private static final int DEFAULT_DRY_RUN_READ_TIMEOUT = 60 * 1000;
+ private static final int DEFAULT_DRY_RUN_READ_TIMEOUT_SEC = 60;
private final Settings settings;
private final ServerClient server;
File databaseFile = tempDirectories.getFile("", "dryrun.h2.db");
// SONAR-4488 Allow to increase dryRun timeout
- int readTimeout = settings.getInt(CoreProperties.DRY_RUN_READ_TIMEOUT);
- readTimeout = (readTimeout == 0) ? DEFAULT_DRY_RUN_READ_TIMEOUT : readTimeout;
+ int readTimeoutSec = settings.getInt(CoreProperties.DRY_RUN_READ_TIMEOUT_SEC);
+ readTimeoutSec = (readTimeoutSec == 0) ? DEFAULT_DRY_RUN_READ_TIMEOUT_SEC : readTimeoutSec;
- downloadDatabase(databaseFile, readTimeout);
+ downloadDatabase(databaseFile, readTimeoutSec * 1000);
String databasePath = StringUtils.removeEnd(databaseFile.getAbsolutePath(), ".h2.db");
replaceSettings(databasePath);
if (rootCause instanceof SocketTimeoutException) {
// Pico will unwrap the first runtime exception
throw new SonarException(new SonarException(String.format("DryRun database read timed out after %s ms. You can try to increase read timeout with property -D"
- + CoreProperties.DRY_RUN_READ_TIMEOUT,
+ + CoreProperties.DRY_RUN_READ_TIMEOUT_SEC + "(in seconds)",
readTimeout), e));
}
if (projectKey != null && (rootCause instanceof HttpException) && (((HttpException) rootCause).getResponseCode() == 401)) {
@Test
public void should_download_database_with_overriden_timeout() {
- settings.setProperty(CoreProperties.DRY_RUN_READ_TIMEOUT, 80000);
+ settings.setProperty(CoreProperties.DRY_RUN_READ_TIMEOUT_SEC, 80);
new DryRunDatabase(settings, server, tempDirectories).start();
verify(server).download("/batch_bootstrap/db?project=group:project", databaseFile, 80000);
doThrow(new SonarException(new SocketTimeoutException())).when(server).download("/batch_bootstrap/db?project=group:project", databaseFile, 60000);
thrown.expect(SonarException.class);
- thrown.expectMessage("DryRun database read timed out after 60000 ms. You can try to increase read timeout with property -Dsonar.dryRun.readTimeout");
+ thrown.expectMessage("DryRun database read timed out after 60000 ms. You can try to increase read timeout with property -Dsonar.dryRun.readTimeout (in seconds)");
new DryRunDatabase(settings, server, tempDirectories).start();
}