]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6992 add IT 1232/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 9 Sep 2016 14:03:22 +0000 (16:03 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 12 Sep 2016 08:50:57 +0000 (10:50 +0200)
it/it-tests/src/test/java/it/serverSystem/ClusterTest.java

index a4dc295322d1a3ca7389f446f6b7ffd16f7f2e74..bf2640ab9afec420eb1019ce94e4da221a66e6ea 100644 (file)
@@ -39,7 +39,9 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.junit.Test;
 import org.sonarqube.ws.Issues;
+import org.sonarqube.ws.Settings;
 import org.sonarqube.ws.client.rule.SearchWsRequest;
+import org.sonarqube.ws.client.setting.ValuesRequest;
 import util.ItUtils;
 
 import static org.apache.commons.lang3.StringUtils.containsIgnoreCase;
@@ -109,11 +111,20 @@ public class ClusterTest {
         .build();
       web.start();
 
+      String coreId = getPropertyValue(web, "sonar.core.id");
+      String startTime = getPropertyValue(web, "sonar.core.startTime");
+
       assertThat(FileUtils.readFileToString(elasticsearch.getServer().getLogs())).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);
 
+      web.restartServer();
+
+      // sonar core id must not change after restart
+      assertThat(getPropertyValue(web, "sonar.core.id")).isEqualTo(coreId);
+      // startTime must change at each startup
+      assertThat(getPropertyValue(web, "sonar.core.startTime")).isNotEqualTo(startTime);
     } finally {
       if (web != null) {
         web.stop();
@@ -124,6 +135,16 @@ public class ClusterTest {
     }
   }
 
+  private static String getPropertyValue(Orchestrator web, String property) {
+    Settings.ValuesWsResponse response = ItUtils.newAdminWsClient(web).settingsService().values(ValuesRequest.builder().setKeys(property).build());
+    List<Settings.Setting> settingsList = response.getSettingsList();
+    if (settingsList.isEmpty()) {
+      return null;
+    }
+    assertThat(settingsList).hasSize(1);
+    return settingsList.iterator().next().getValue();
+  }
+
   private static class ElasticsearchStartupWatcher implements StartupLogWatcher {
     private final Pattern pattern = Pattern.compile("Elasticsearch listening on .*:(\\d+)");
     private int port = -1;