This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Odfe it framework release #107
Merged
ktkrg
merged 14 commits into
opendistro-for-elasticsearch:master
from
sidheart:odfe-it-framework-release
Jun 15, 2020
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
50b2526
ODFE IT Framework POC
a0735e9
Testing to see if Dockerstuff is set up
ba6a61f
Modified workflow to set DOCKER_COMPOSE_LOCATION
c0c8170
Modify workflow to include stacktrace and no symbolic linkage
93f1daf
Set DOCKER_COMPOSE_LOCATION using set-env
e0f101e
Try set-env in a different location
04d1703
Attempt to fix docker-compose set-env
4d811f4
Make workflow set vm.max_map_count
7d37c72
Use sudo when setting vm.max_map_count
321c4ad
Make performance-analyzer execute integration tests on checkin
9f3938e
Clean up PerformanceAnalyzerIT and build.gradle script
68da615
Add newline to end of gradle.properties file
998f7bc
Modify gradle.yml and checkMetrics
30e106c
Fix ObjectMapper allocation and move TestUtils definition
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# The following 3 properties are used for integration testing with Elasticsearch | ||
# The "enablePaAndRca" gradle task in the performance-analyzer-rca repository contains logic to spin up a 2-node | ||
# Elasticsearch cluster with the PA and RCA components enabled. The cluster endpoint for this cluster is localhost:9300 | ||
# and the REST endpoint is localhost:9200. | ||
|
||
# The Elasticsearch cluster endpoint to use for test REST requests | ||
systemProp.tests.rest.cluster=localhost:9200 | ||
# The Elasticsearch cluster node communication endpoint | ||
systemProp.tests.cluster=localhost:9300 | ||
# Whether or not to spin up a new Elasticsearch cluster for integration testing | ||
systemProp.tests.useDockerCluster=true |
106 changes: 106 additions & 0 deletions
106
...t/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/PerformanceAnalyzerIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package com.amazon.opendistro.elasticsearch.performanceanalyzer; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.apache.http.HttpHost; | ||
import org.apache.http.HttpStatus; | ||
import org.apache.http.util.EntityUtils; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.client.RestClient; | ||
import org.elasticsearch.test.rest.ESRestTestCase; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class PerformanceAnalyzerIT extends ESRestTestCase { | ||
private static final Logger LOG = LogManager.getLogger(PerformanceAnalyzerIT.class); | ||
private static final int PORT = 9600; | ||
private static final ObjectMapper mapper = new ObjectMapper(); | ||
private static RestClient paClient; | ||
|
||
@Before | ||
public void initPaClient() throws IOException { | ||
String cluster = System.getProperty("tests.rest.cluster"); | ||
logger.info("Cluster is {}", cluster); | ||
if (cluster == null) { | ||
throw new RuntimeException("Must specify [tests.rest.cluster] system property with a comma delimited list of [host:port] " | ||
+ "to which to send REST requests"); | ||
} | ||
List<HttpHost> hosts = Collections.singletonList( | ||
buildHttpHost(cluster.substring(0, cluster.lastIndexOf(":")), PORT)); | ||
logger.info("initializing PerformanceAnalyzer client against {}", hosts); | ||
paClient = buildClient(restClientSettings(), hosts.toArray(new HttpHost[0])); | ||
} | ||
|
||
|
||
public static void ensurePaAndRcaEnabled() throws Exception { | ||
// TODO replace with waitFor with a 1min timeout | ||
for (int i = 0; i < 60; i++) { | ||
Response resp = client().performRequest(new Request("GET", "_opendistro/_performanceanalyzer/cluster/config")); | ||
Map<String, Object> respMap = mapper.readValue(EntityUtils.toString(resp.getEntity(), "UTF-8"), | ||
new TypeReference<Map<String, Object>>(){}); | ||
if (respMap.get("currentPerformanceAnalyzerClusterState").equals(3)) { | ||
break; | ||
} | ||
Thread.sleep(1000L); | ||
} | ||
Response resp = client().performRequest(new Request("GET", "_opendistro/_performanceanalyzer/cluster/config")); | ||
Map<String, Object> respMap = mapper.readValue(EntityUtils.toString(resp.getEntity(), "UTF-8"), | ||
new TypeReference<Map<String, Object>>(){}); | ||
if (!respMap.get("currentPerformanceAnalyzerClusterState").equals(3)) { | ||
throw new Exception("PA and RCA are not enabled on the target cluster!"); | ||
} | ||
} | ||
|
||
@Test | ||
public void checkMetrics() throws Exception { | ||
ensurePaAndRcaEnabled(); | ||
Request request = new Request("GET", | ||
"/_opendistro/_performanceanalyzer/metrics/?metrics=Disk_Utilization&agg=max&dim=&nodes=all"); | ||
Response resp = paClient.performRequest(request); | ||
Assert.assertEquals(HttpStatus.SC_OK, resp.getStatusLine().getStatusCode()); | ||
String jsonString = EntityUtils.toString(resp.getEntity()); | ||
JsonNode root = mapper.readTree(jsonString); | ||
root.forEach( entry -> { | ||
JsonNode data = entry.get(TestUtils.DATA); | ||
Assert.assertEquals(1, data.get(TestUtils.FIELDS).size()); | ||
JsonNode field = data.get(TestUtils.FIELDS).get(0); | ||
Assert.assertEquals(TestUtils.M_DISKUTIL, field.get(TestUtils.FIELD_NAME).asText()); | ||
Assert.assertEquals(TestUtils.DOUBLE_TYPE, field.get(TestUtils.FIELD_TYPE).asText()); | ||
JsonNode records = data.get(TestUtils.RECORDS); | ||
Assert.assertEquals(1, records.size()); | ||
records.get(0).forEach(record -> Assert.assertTrue(record.asDouble() >= 0)); | ||
}); | ||
} | ||
|
||
@AfterClass | ||
public static void closePaClient() throws Exception { | ||
ESRestTestCase.closeClients(); | ||
paClient.close(); | ||
LOG.debug("AfterClass has run"); | ||
} | ||
|
||
private static class TestUtils { | ||
public static final String DATA = "data"; | ||
public static final String RECORDS = "records"; | ||
|
||
// Field related strings | ||
public static final String FIELDS = "fields"; | ||
public static final String FIELD_NAME = "name"; | ||
public static final String FIELD_TYPE = "type"; | ||
public static final String DOUBLE_TYPE = "DOUBLE"; | ||
|
||
// Metrics related strings | ||
public static final String M_DISKUTIL = "Disk_Utilization"; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment saying why this is necessary ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done