aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2022-07-27 14:03:15 +0200
committersonartech <sonartech@sonarsource.com>2022-07-27 20:03:20 +0000
commit496ed35e61d007dca528ec48a0e79297aae31d8a (patch)
tree9ab3a444917deb8fd9dd788c847a4cf5c91b3a06 /sonar-scanner-engine/src
parent87eb70585fa0be0fe5b0e8c65877a82a918a27f4 (diff)
downloadsonarqube-496ed35e61d007dca528ec48a0e79297aae31d8a.tar.gz
sonarqube-496ed35e61d007dca528ec48a0e79297aae31d8a.zip
SONAR-17088 Increase default timeout of scanner report publishing to 60 sec
- Add scan property `sonar.report.publish.timeout`
Diffstat (limited to 'sonar-scanner-engine/src')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java5
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java8
4 files changed, 18 insertions, 4 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
index 432cf165f42..574fdd1e2a1 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
@@ -62,7 +62,6 @@ import static org.sonar.core.util.FileUtils.humanReadableByteCountSI;
import static org.sonar.scanner.scan.branch.BranchType.PULL_REQUEST;
public class ReportPublisher implements Startable {
- private static final int DEFAULT_WRITE_TIMEOUT = 30_000;
private static final Logger LOG = Loggers.get(ReportPublisher.class);
private static final String CHARACTERISTIC = "characteristic";
private static final String DASHBOARD = "dashboard";
@@ -201,7 +200,7 @@ public class ReportPublisher implements Startable {
WsResponse response;
try {
- post.setWriteTimeOutInMs(DEFAULT_WRITE_TIMEOUT);
+ post.setWriteTimeOutInMs(properties.reportPublishTimeout() * 1000);
response = wsClient.call(post);
} catch (Exception e) {
throw new IllegalStateException("Failed to upload report: " + e.getMessage(), e);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java
index 44a9c04c061..250d9d22482 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ScanProperties.java
@@ -42,6 +42,7 @@ public class ScanProperties {
public static final String SCM_REVISION = "sonar.scm.revision";
public static final String QUALITY_GATE_WAIT = "sonar.qualitygate.wait";
public static final String QUALITY_GATE_TIMEOUT_IN_SEC = "sonar.qualitygate.timeout";
+ public static final String REPORT_PUBLISH_TIMEOUT_IN_SEC = "sonar.ws.report.timeout";
private final Configuration configuration;
private final DefaultInputProject project;
@@ -88,6 +89,10 @@ public class ScanProperties {
return configuration.getInt(QUALITY_GATE_TIMEOUT_IN_SEC).orElse(300);
}
+ public int reportPublishTimeout() {
+ return configuration.getInt(REPORT_PUBLISH_TIMEOUT_IN_SEC).orElse(60);
+ }
+
/**
* This should be called in the beginning of the analysis to fail fast
*/
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
index ae2f877d384..5be9155e320 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
@@ -103,7 +103,9 @@ public class ReportPublisherTest {
}
@Test
- public void use_30s_write_timeout() {
+ public void use_write_timeout_from_properties() {
+ when(properties.reportPublishTimeout()).thenReturn(60);
+
MockWsResponse submitMockResponse = new MockWsResponse();
submitMockResponse.setContent(Ce.SubmitResponse.newBuilder().setTaskId("task-1234").build().toByteArray());
when(wsClient.call(any())).thenReturn(submitMockResponse);
@@ -111,7 +113,7 @@ public class ReportPublisherTest {
underTest.start();
underTest.execute();
- verify(wsClient).call(argThat(req -> (req).getWriteTimeOutInMs().orElse(0) == 30_000));
+ verify(wsClient).call(argThat(req -> (req).getWriteTimeOutInMs().orElse(0) == 60_000));
}
@Test
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java
index effa108aeae..4ccedb3bb22 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ScanPropertiesTest.java
@@ -65,6 +65,14 @@ public class ScanPropertiesTest {
}
@Test
+ public void should_define_report_publish_timeout() {
+ assertThat(underTest.reportPublishTimeout()).isEqualTo(60);
+
+ settings.setProperty("sonar.ws.report.timeout", "10");
+ assertThat(underTest.reportPublishTimeout()).isEqualTo(10);
+ }
+
+ @Test
public void should_define_preload_file_metadata() {
settings.setProperty("sonar.preloadFileMetadata", "true");
assertThat(underTest.preloadFileMetadata()).isTrue();