diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-03-25 13:32:03 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-03-25 13:32:12 +0100 |
commit | dcb221abc2896304e55e92d7f366c503cafc2a50 (patch) | |
tree | 3b6cc8aba588465c657ce3142ea48f4454241bdb /it | |
parent | bdd14b31bcd4ff599dd2dffd133d80f43b8970c3 (diff) | |
download | sonarqube-dcb221abc2896304e55e92d7f366c503cafc2a50.tar.gz sonarqube-dcb221abc2896304e55e92d7f366c503cafc2a50.zip |
Fix integration test about System Info page
Diffstat (limited to 'it')
-rw-r--r-- | it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java b/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java index 51192aac4bc..d3960193e5e 100644 --- a/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java +++ b/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java @@ -23,9 +23,11 @@ import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarRunner; import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; +import java.io.File; import java.io.IOException; import java.util.List; import java.util.Map; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpResponse; @@ -97,15 +99,29 @@ public class ServerSystemTest { */ @Test public void monitor_compute_engine_and_elasticsearch_processes() throws Exception { + waitForComputeEngineToBeUp(orchestrator); + WsResponse response = newAdminWsClient(orchestrator).wsConnector().call( new GetRequest("api/system/info")); - assertThat(response.code()).isEqualTo(200); - assertThat(response.content()).containsSequence("\"Compute Engine Database\":", "\"Pool Active Connections\""); - assertThat(response.content()).containsSequence("\"Compute Engine State\":", "\"Heap Used\""); - assertThat(response.content()).containsSequence("\"Compute Engine Tasks\":", "\"Pending\"", "\"In Progress\""); + assertThat(response.code()).isEqualTo(200); + assertThat(response.content()).contains("\"Compute Engine Database\":", "\"Compute Engine State\":", "\"Compute Engine Tasks\":"); + assertThat(response.content()).contains("\"Elasticsearch\":", "\"State\":\"GREEN\"", "\"Elasticsearch State\""); + } - assertThat(response.content()).containsSequence("\"Elasticsearch\":", "\"State\":\"GREEN\""); + private static void waitForComputeEngineToBeUp(Orchestrator orchestrator) throws IOException { + for (int i = 0; i < 10_000; i++) { + File logs = orchestrator.getServer().getLogs(); + if (FileUtils.readFileToString(logs).contains("Compute Engine is up")) { + return; + } + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + throw new IllegalStateException("Compute Engine is not up"); } /** |