From 4abfa45490191187597f27110702d92a5ea548ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Fri, 9 Sep 2016 16:03:22 +0200 Subject: [PATCH] SONAR-6992 add IT --- .../java/it/serverSystem/ClusterTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/it/it-tests/src/test/java/it/serverSystem/ClusterTest.java b/it/it-tests/src/test/java/it/serverSystem/ClusterTest.java index a4dc295322d..bf2640ab9af 100644 --- a/it/it-tests/src/test/java/it/serverSystem/ClusterTest.java +++ b/it/it-tests/src/test/java/it/serverSystem/ClusterTest.java @@ -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 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; -- 2.39.5