diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-11-15 09:41:20 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-11-16 10:09:21 +0100 |
commit | 91a6c35e590a92b02e7406133162d8d5ec2fb5ac (patch) | |
tree | a172d0ce8113ff1885f854263e454dc3137f8afe /tests | |
parent | ad40128e3d6b300eef57e24180fc22d2e374f125 (diff) | |
download | sonarqube-91a6c35e590a92b02e7406133162d8d5ec2fb5ac.tar.gz sonarqube-91a6c35e590a92b02e7406133162d8d5ec2fb5ac.zip |
SONAR-8333 fixing ITs
Diffstat (limited to 'tests')
-rw-r--r-- | tests/perf/src/main/java/org/sonarsource/sonarqube/perf/ServerLogs.java | 10 | ||||
-rw-r--r-- | tests/perf/src/test/java/org/sonarsource/sonarqube/perf/server/ServerTest.java | 14 |
2 files changed, 14 insertions, 10 deletions
diff --git a/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/ServerLogs.java b/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/ServerLogs.java index 5549395c963..69a2a01dd5b 100644 --- a/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/ServerLogs.java +++ b/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/ServerLogs.java @@ -20,6 +20,7 @@ package org.sonarsource.sonarqube.perf; import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.container.Server; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; @@ -56,8 +57,13 @@ public class ServerLogs { } public static void clear(Orchestrator orch) throws IOException { - if (orch.getServer() != null && orch.getServer().getCeLogs() != null) { - FileUtils.write(orch.getServer().getCeLogs(), "", false); + Server server = orch.getServer(); + if (server != null) { + for (File file : new File[]{server.getAppLogs(), server.getWebLogs(), server.getCeLogs(), server.getEsLogs()}) { + if (file != null) { + FileUtils.write(file, "", false); + } + } } } diff --git a/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/server/ServerTest.java b/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/server/ServerTest.java index b53b5efb9ac..10b484bd30c 100644 --- a/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/server/ServerTest.java +++ b/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/server/ServerTest.java @@ -24,13 +24,14 @@ import java.io.IOException; import java.util.Collections; import java.util.Date; import java.util.List; -import org.apache.commons.io.FileUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; import org.sonarsource.sonarqube.perf.PerfTestCase; import org.sonarsource.sonarqube.perf.ServerLogs; +import static org.apache.commons.io.FileUtils.readLines; + public class ServerTest extends PerfTestCase { private static final int TIMEOUT_3_MINUTES = 1000 * 60 * 3; @@ -56,14 +57,14 @@ public class ServerTest extends PerfTestCase { orchestrator.start(); // compare dates of first and last log - long firstLogDate = ServerLogs.extractFirstDate(readLogLines(orchestrator)).getTime(); + long firstLogDate = ServerLogs.extractFirstDate(readLines(orchestrator.getServer().getAppLogs())).getTime(); long startedAtDate = extractStartedAtDate(orchestrator); assertDurationAround(startedAtDate - firstLogDate, 38_000); ServerLogs.clear(orchestrator); orchestrator.stop(); - List<String> lines = readLogLines(orchestrator); + List<String> lines = readLines(orchestrator.getServer().getAppLogs()); long firstStopLogDate = ServerLogs.extractFirstDate(lines).getTime(); long stopDate = extractStopDate(lines); assertDurationLessThan(stopDate - firstStopLogDate, 10_000); @@ -74,12 +75,12 @@ public class ServerTest extends PerfTestCase { } private static long extractStartedAtDate(Orchestrator orchestrator) throws IOException { - Date startedAtDate = extractStartedDate(readLogLines(orchestrator)); + Date startedAtDate = extractStartedDate(readLines(orchestrator.getServer().getCeLogs())); // if SQ never starts, the test will fail with timeout while (startedAtDate == null) { try { Thread.sleep(100); - startedAtDate = extractStartedDate(readLogLines(orchestrator)); + startedAtDate = extractStartedDate(readLines(orchestrator.getServer().getCeLogs())); } catch (InterruptedException e) { // ignored } @@ -105,7 +106,4 @@ public class ServerTest extends PerfTestCase { return end.getTime(); } - private static List<String> readLogLines(Orchestrator orchestrator) throws IOException { - return FileUtils.readLines(orchestrator.getServer().getCeLogs()); - } } |