]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8333 use orchestrator 3.13-build783 to fix SQ ITs based on logs
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 9 Nov 2016 15:22:08 +0000 (16:22 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 16 Nov 2016 09:09:21 +0000 (10:09 +0100)
12 files changed:
it/it-tests/src/test/java/it/qualityGate/QualityGateTest.java
it/it-tests/src/test/java/it/serverSystem/ClusterTest.java
it/it-tests/src/test/java/it/serverSystem/RestartTest.java
it/it-tests/src/test/java/it/serverSystem/ServerSystemRestartingOrchestrator.java
it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java
it/it-tests/src/test/java/it/settings/SettingsTest.java
it/it-tests/src/test/java/it/user/BaseIdentityProviderTest.java
it/it-tests/src/test/java/it/user/SsoAuthenticationTest.java
it/it-tests/src/test/java/util/ItUtils.java
pom.xml
tests/perf/src/main/java/org/sonarsource/sonarqube/perf/ServerLogs.java
tests/perf/src/test/java/org/sonarsource/sonarqube/perf/server/ServerTest.java

index fb82d80c56f87f6ded1fe9d7795cc96cdb54c195..46b3160a6674a4a5de9ca0593cd3069696056ad3 100644 (file)
@@ -259,7 +259,7 @@ public class QualityGateTest {
   }
 
   private void verifyQGStatusInPostTask(BuildResult buildResult, String taskStatus, String qgStatus) throws IOException {
-    List<String> logsLines = FileUtils.readLines(orchestrator.getServer().getLogs(), Charsets.UTF_8);
+    List<String> logsLines = FileUtils.readLines(orchestrator.getServer().getCeLogs(), Charsets.UTF_8);
     List<String> postTaskLogLines = extractPosttaskPluginLogs(extractCeTaskId(buildResult), logsLines);
 
     assertThat(postTaskLogLines).hasSize(1);
index bf2640ab9afec420eb1019ce94e4da221a66e6ea..4b50204454e3c0fbbf2a6262aa617bb06f4de982 100644 (file)
@@ -71,7 +71,7 @@ public class ClusterTest {
     // verify that datastores are populated by requesting rules
     assertThat(newWsClient(orchestrator).rules().search(new SearchWsRequest()).getTotal()).isGreaterThan(0);
 
-    FileUtils.write(orchestrator.getServer().getLogs(), "", false);
+    FileUtils.write(orchestrator.getServer().getWebLogs(), "", false);
     updateSonarPropertiesFile(orchestrator, ImmutableMap.of("sonar.cluster.web.startupLeader", "false"));
     orchestrator.restartServer();
 
@@ -96,7 +96,7 @@ public class ClusterTest {
         .build();
       elasticsearch.start();
       assertThat(esWatcher.port).isGreaterThan(0);
-      assertThat(FileUtils.readFileToString(elasticsearch.getServer().getLogs())).doesNotContain("Process[web]");
+      assertThat(FileUtils.readFileToString(elasticsearch.getServer().getAppLogs())).doesNotContain("Process[web]");
 
       web = Orchestrator.builderEnv()
         .setServerProperty("sonar.cluster.enabled", "true")
@@ -114,7 +114,7 @@ public class ClusterTest {
       String coreId = getPropertyValue(web, "sonar.core.id");
       String startTime = getPropertyValue(web, "sonar.core.startTime");
 
-      assertThat(FileUtils.readFileToString(elasticsearch.getServer().getLogs())).doesNotContain("Process[es]");
+      assertThat(FileUtils.readFileToString(elasticsearch.getServer().getAppLogs())).doesNotContain("Process[es]");
       // call a web service that requires Elasticsearch
       Issues.SearchWsResponse wsResponse = ItUtils.newWsClient(web).issues().search(new org.sonarqube.ws.client.issue.SearchWsRequest());
       assertThat(wsResponse.getIssuesCount()).isEqualTo(0);
@@ -160,14 +160,14 @@ public class ClusterTest {
   }
 
   private static void expectLog(Orchestrator orchestrator, String expectedLog) throws IOException {
-    File logFile = orchestrator.getServer().getLogs();
+    File logFile = orchestrator.getServer().getWebLogs();
     try (Stream<String> lines = Files.lines(logFile.toPath())) {
       assertThat(lines.anyMatch(s -> StringUtils.containsIgnoreCase(s, expectedLog))).isTrue();
     }
   }
 
   private static void expectWriteOperations(Orchestrator orchestrator, boolean expected) throws IOException {
-    try (Stream<String> lines = Files.lines(orchestrator.getServer().getLogs().toPath())) {
+    try (Stream<String> lines = Files.lines(orchestrator.getServer().getWebLogs().toPath())) {
       List<String> writeOperations = lines.filter(ClusterTest::isWriteOperation).collect(Collectors.toList());
       if (expected) {
         assertThat(writeOperations).isNotEmpty();
index e7ffaf50e5328709f00d0f226d22fd7ba7f764d5..cbb6abb5e90126c25233288fddfd3c5ab6b1290a 100644 (file)
@@ -81,7 +81,7 @@ public class RestartTest {
       // we just wait five seconds, for a lack of a better approach to waiting for the restart process to start in SQ
       Thread.sleep(5000);
 
-      assertThat(FileUtils.readFileToString(orchestrator.getServer().getLogs()))
+      assertThat(FileUtils.readFileToString(orchestrator.getServer().getWebLogs()))
         .contains("SonarQube restart requested by big");
     }
   }
@@ -99,7 +99,7 @@ public class RestartTest {
       orchestrator.start();
 
       newAdminWsClient(orchestrator).system().restart();
-      assertThat(FileUtils.readFileToString(orchestrator.getServer().getLogs()))
+      assertThat(FileUtils.readFileToString(orchestrator.getServer().getWebLogs()))
         .contains("Fast restarting WebServer...")
         .contains("WebServer restarted");
     }
index ef91d1d72980868eecc0bf60f08183e69e29ad23..8161521a34b57312c4a39f9668c34459268fd557 100644 (file)
@@ -63,7 +63,7 @@ public class ServerSystemRestartingOrchestrator {
       orchestrator.start();
       fail();
     } catch (Exception e) {
-      assertThat(FileUtils.readFileToString(orchestrator.getServer().getLogs())).contains(
+      assertThat(FileUtils.readFileToString(orchestrator.getServer().getWebLogs())).contains(
         "Plugin incompatible-plugin [incompatibleplugin] requires at least SonarQube 100");
     }
   }
@@ -92,7 +92,7 @@ public class ServerSystemRestartingOrchestrator {
 
     File tempDir = new File(orchestrator.getServer().getHome(), "temp/tmp");
 
-    String logs = FileUtils.readFileToString(orchestrator.getServer().getLogs());
+    String logs = FileUtils.readFileToString(orchestrator.getServer().getWebLogs());
     assertThat(logs).contains("Creating temp directory: " + tempDir.getAbsolutePath() + File.separator + "sonar-it");
     assertThat(logs).contains("Creating temp file: " + tempDir.getAbsolutePath() + File.separator + "sonar-it");
 
index 86507c184a0be57c55abda88a9704cf6cb68dad5..0c67af41e8beadfd364caf98d9a7d7938979eb92 100644 (file)
@@ -130,7 +130,7 @@ public class ServerSystemTest {
 
   private static void waitForComputeEngineToBeUp(Orchestrator orchestrator) throws IOException {
     for (int i = 0; i < 10_000; i++) {
-      File logs = orchestrator.getServer().getLogs();
+      File logs = orchestrator.getServer().getCeLogs();
       if (FileUtils.readFileToString(logs).contains("Compute Engine is up")) {
         return;
       }
index e9b1ea0a06acc3c398d9947c10bc1c942b3555a7..41fc8df8296315f0d7baebe0a36c3d5e35d477ed 100644 (file)
@@ -67,7 +67,8 @@ public class SettingsTest {
   @Test
   public void global_property_change_extension_point() throws IOException {
     SETTINGS.set(SetRequest.builder().setKey("globalPropertyChange.received").setValue("NEWVALUE").build());
-    assertThat(FileUtils.readFileToString(orchestrator.getServer().getLogs())).contains("Received change: [key=globalPropertyChange.received, newValue=NEWVALUE]");
+    assertThat(FileUtils.readFileToString(orchestrator.getServer().getWebLogs()))
+        .contains("Received change: [key=globalPropertyChange.received, newValue=NEWVALUE]");
   }
 
   @Test
index 2801b4e3d48cb73a69a16c34c175498f901d0c5b..c5408415336b9f0aae5a1b62a50ccacd8cbf7a64 100644 (file)
@@ -193,7 +193,7 @@ public class BaseIdentityProviderTest {
     new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("fail_to_authenticate_when_not_allowed_to_sign_up",
       "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html").build()).runOn(ORCHESTRATOR);
 
-    File logFile = ORCHESTRATOR.getServer().getLogs();
+    File logFile = ORCHESTRATOR.getServer().getWebLogs();
     assertThat(FileUtils.readFileToString(logFile)).doesNotContain("A functional error has happened");
     assertThat(FileUtils.readFileToString(logFile)).doesNotContain("UnauthorizedException");
 
index d13ff117f46620527b7197415281858fcec04578..76543eb289e4eb68ce854bef00024478cf6739ef 100644 (file)
@@ -132,7 +132,7 @@ public class SsoAuthenticationTest {
     assertThat(response.code()).isEqualTo(200);
     assertThat(response.body().string()).contains("You're not authorized to access this page. Please contact the administrator");
 
-    List<String> logsLines = FileUtils.readLines(orchestrator.getServer().getLogs(), Charsets.UTF_8);
+    List<String> logsLines = FileUtils.readLines(orchestrator.getServer().getWebLogs(), Charsets.UTF_8);
     assertThat(logsLines).doesNotContain("org.sonar.server.exceptions.BadRequestException: user.bad_login");
     USER_RULE.verifyUserDoesNotExist(USER_LOGIN);
   }
index 871b27784474a9ee11c98016682811f9bba0b7f9..e445b242f15a5caa4cf5d61ad50fb2cf8c1423e1 100644 (file)
  */
 package util;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
 import com.google.common.base.Splitter;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.sonar.orchestrator.Orchestrator;
@@ -36,11 +33,15 @@ import java.io.IOException;
 import java.lang.reflect.Type;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 import javax.annotation.Nullable;
 import org.apache.commons.io.FileUtils;
 import org.json.simple.JSONArray;
@@ -57,10 +58,8 @@ import org.sonarqube.ws.client.setting.ResetRequest;
 import org.sonarqube.ws.client.setting.SetRequest;
 
 import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.FluentIterable.from;
 import static com.sonar.orchestrator.container.Server.ADMIN_LOGIN;
 import static com.sonar.orchestrator.container.Server.ADMIN_PASSWORD;
-import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.fail;
 
@@ -252,7 +251,8 @@ public class ItUtils {
     if (properties == null || properties.length == 0) {
       return str;
     }
-    return from(Iterables.concat(asList(properties), asList(str))).toArray(String.class);
+    return Stream.concat(Arrays.stream(properties), Arrays.stream(str))
+      .toArray(String[]::new);
   }
 
   public static void verifyHttpException(Exception e, int expectedCode) {
@@ -283,19 +283,10 @@ public class ItUtils {
 
   public static List<String> extractCeTaskIds(BuildResult buildResult) {
     String logs = buildResult.getLogs();
-    return from(LINE_SPLITTER.split(logs))
-      .filter(new Predicate<String>() {
-        @Override
-        public boolean apply(String s) {
-          return s.contains("More about the report processing at");
-        }
-      }).transform(new Function<String, String>() {
-        @Nullable
-        @Override
-        public String apply(String s) {
-          return s.substring(s.length() - 20, s.length());
-        }
-      }).toList();
+    return StreamSupport.stream(LINE_SPLITTER.split(logs).spliterator(), false)
+      .filter(s -> s.contains("More about the report processing at"))
+      .map(s -> s.substring(s.length() - 20, s.length()))
+      .collect(Collectors.toList());
   }
 
   public static Map<String, Object> jsonToMap(String json) {
diff --git a/pom.xml b/pom.xml
index 68397c3753cf411643fbdb65dbd7e67633a0a305..ba557d6ab11ae6ddd578aabbb60a69b59c25d3e5 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -66,7 +66,7 @@
     <slf4j.version>1.7.21</slf4j.version>
     <tomcat.version>8.0.32</tomcat.version>
     <elasticsearch.version>2.3.5</elasticsearch.version>
-    <orchestrator.version>3.13-build640</orchestrator.version>
+    <orchestrator.version>3.13-build783</orchestrator.version>
     <okhttp.version>3.3.1</okhttp.version>
     <jackson.version>2.6.6</jackson.version>
 
index 9bacd727c2f8080b14793ca1e44d2743b2a52f49..5549395c9635e055e3b2e2f0cd2ef163fc911258 100644 (file)
@@ -56,8 +56,8 @@ public class ServerLogs {
   }
 
   public static void clear(Orchestrator orch) throws IOException {
-    if (orch.getServer() != null && orch.getServer().getLogs() != null) {
-      FileUtils.write(orch.getServer().getLogs(), "", false);
+    if (orch.getServer() != null && orch.getServer().getCeLogs() != null) {
+      FileUtils.write(orch.getServer().getCeLogs(), "", false);
     }
   }
 
@@ -65,7 +65,7 @@ public class ServerLogs {
    * 2015.09.29 16:57:45 INFO ce[o.s.s.c.q.CeWorkerRunnableImpl] Executed task | project=com.github.kevinsawicki:http-request-parent | id=AVAZm9oHIXrp54OmOeQe | time=2283ms
    */
   public static Long extractComputationTotalTime(Orchestrator orchestrator) throws IOException {
-    File report = orchestrator.getServer().getLogs();
+    File report = orchestrator.getServer().getCeLogs();
     List<String> logsLines = FileUtils.readLines(report, Charsets.UTF_8);
     return extractComputationTotalTime(logsLines);
   }
index d0c17e807ff158f82a72648ab80c92b01edeb493..b53b5efb9ac699a0ecb85fb1590f6d37a30cc6c6 100644 (file)
@@ -106,6 +106,6 @@ public class ServerTest extends PerfTestCase {
   }
 
   private static List<String> readLogLines(Orchestrator orchestrator) throws IOException {
-    return FileUtils.readLines(orchestrator.getServer().getLogs());
+    return FileUtils.readLines(orchestrator.getServer().getCeLogs());
   }
 }