Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add an IT which verifies that the RCA REST endpoint can be queried #157

Merged
merged 2 commits into from
Jul 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Objects;
import org.apache.http.HttpHost;
import org.apache.http.HttpStatus;
import org.apache.http.util.EntityUtils;
Expand All @@ -14,7 +15,7 @@
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.AfterClass;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -130,8 +131,22 @@ public void checkMetrics() throws Exception {
});
}

@AfterClass
public static void closePaClient() throws Exception {
@Test
public void testRcaIsRunning() throws Exception {
ensurePaAndRcaEnabled();
WaitFor.waitFor(() -> {
Request request = new Request("GET", "/_opendistro/_performanceanalyzer/rca");
try {
Response resp = paClient.performRequest(request);
return Objects.equals(HttpStatus.SC_OK, resp.getStatusLine().getStatusCode());
} catch (Exception e) { // 404, RCA context hasn't been set up yet
return false;
}
}, 2, TimeUnit.MINUTES);
}

@After
public void closePaClient() throws Exception {
ESRestTestCase.closeClients();
paClient.close();
LOG.debug("AfterClass has run");
Expand Down