aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-07-26 10:30:05 +0200
committerSonarTech <sonartech@sonarsource.com>2018-08-02 20:21:33 +0200
commit2afc1eb0305f0d8639391820f41cae364b8c286e (patch)
tree745374d5b96962a75e46dd1ae342849647da740c /server/sonar-ce-task
parentf2ff1d961ee722300bdc7ed04da63f7f002e03ee (diff)
downloadsonarqube-2afc1eb0305f0d8639391820f41cae364b8c286e.tar.gz
sonarqube-2afc1eb0305f0d8639391820f41cae364b8c286e.zip
SONAR-11077 log profiling of CE steps in INFO level
Diffstat (limited to 'server/sonar-ce-task')
-rw-r--r--server/sonar-ce-task/src/main/java/org/sonar/ce/task/step/ComputationStepExecutor.java2
-rw-r--r--server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java38
2 files changed, 11 insertions, 29 deletions
diff --git a/server/sonar-ce-task/src/main/java/org/sonar/ce/task/step/ComputationStepExecutor.java b/server/sonar-ce-task/src/main/java/org/sonar/ce/task/step/ComputationStepExecutor.java
index 3187f37b7cd..9fa8eea74dd 100644
--- a/server/sonar-ce-task/src/main/java/org/sonar/ce/task/step/ComputationStepExecutor.java
+++ b/server/sonar-ce-task/src/main/java/org/sonar/ce/task/step/ComputationStepExecutor.java
@@ -62,7 +62,7 @@ public final class ComputationStepExecutor {
for (ComputationStep step : steps.instances()) {
stepProfiler.start();
step.execute();
- stepProfiler.stopDebug(step.getDescription());
+ stepProfiler.stopInfo(step.getDescription());
}
}
diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java
index ca3af2117f3..e8ae8735f05 100644
--- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java
+++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java
@@ -83,35 +83,17 @@ public class ComputationStepExecutorTest {
}
@Test
- public void execute_does_not_log_end_timing_for_each_ComputationStep_called_when_level_is_INFO() {
- List<String> infoLogs = execute_logs_end_timing_for_each_ComputationStep_called_when_(LoggerLevel.INFO);
- assertThat(infoLogs).isEmpty();
- }
-
- @Test
- public void execute_logs_end_timing_for_each_ComputationStep_called_when_level_is_DEBUG() {
- List<String> infoLogs = execute_logs_end_timing_for_each_ComputationStep_called_when_(LoggerLevel.DEBUG);
- assertThat(infoLogs).hasSize(2);
- assertThat(infoLogs.get(0)).contains("step1 | time=");
- assertThat(infoLogs.get(1)).contains("step2 | time=");
- }
-
- @Test
- public void execute_logs_end_timing_for_each_ComputationStep_called_when_level_is_TRACE() {
- List<String> infoLogs = execute_logs_end_timing_for_each_ComputationStep_called_when_(LoggerLevel.TRACE);
- assertThat(infoLogs).hasSize(2);
- assertThat(infoLogs.get(0)).contains("step1 | time=");
- assertThat(infoLogs.get(1)).contains("step2 | time=");
- }
-
- private List<String> execute_logs_end_timing_for_each_ComputationStep_called_when_(LoggerLevel level) {
- try (ChangeLogLevel executor = new ChangeLogLevel(ComputationStepExecutor.class, level);
- ChangeLogLevel step1 = new ChangeLogLevel(computationStep1.getClass(), level);
- ChangeLogLevel step2 = new ChangeLogLevel(computationStep2.getClass(), level)) {
+ public void execute_logs_end_timing_for_each_ComputationStep_in_INFO_level() {
+ try (ChangeLogLevel executor = new ChangeLogLevel(ComputationStepExecutor.class, LoggerLevel.INFO);
+ ChangeLogLevel step1 = new ChangeLogLevel(computationStep1.getClass(), LoggerLevel.INFO);
+ ChangeLogLevel step2 = new ChangeLogLevel(computationStep2.getClass(), LoggerLevel.INFO)) {
new ComputationStepExecutor(mockComputationSteps(computationStep1, computationStep2))
.execute();
- return logTester.logs(LoggerLevel.DEBUG);
+ List<String> infoLogs = logTester.logs(LoggerLevel.INFO);
+ assertThat(infoLogs).hasSize(2);
+ assertThat(infoLogs.get(0)).contains("step1 | time=");
+ assertThat(infoLogs.get(1)).contains("step2 | time=");
}
}
@@ -146,8 +128,8 @@ public class ComputationStepExecutorTest {
public void execute_does_not_fail_if_listener_throws_Throwable() {
ComputationStepExecutor.Listener listener = mock(ComputationStepExecutor.Listener.class);
doThrow(new Error("Facking error thrown by Listener"))
- .when(listener)
- .finished(anyBoolean());
+ .when(listener)
+ .finished(anyBoolean());
new ComputationStepExecutor(mockComputationSteps(computationStep1), listener).execute();
}