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

Commit

Permalink
IT improvements (#143)
Browse files Browse the repository at this point in the history
* Use true/false instead of null/present for integTest props

integTest is a gradle task which runs our integration tests. It uses
system properties like -Dtests.useDockerCluster to decide whether or not
to perform certain actions like spinning up a docker cluster for
testing. The task would previously perform the property's action if the
property was present.

This commit makes the integTest task only execute a system property
action if that property is set to "true"

* Make IT port number configurable

The PerformanceAnalyzerIT class previously assumed that the Performance
Analyzer Webservice would always be listening on port 9600 for any
deployment of PerformanceAnalyzer.

Since this isn't always the case, this commit makes the port number
configurable through a gradle property.

* Allow logging to be enabled for ensurePaAndRcaEnabled
  • Loading branch information
Sid Narayan authored Jul 23, 2020
1 parent 3f90e17 commit 5c34976
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
run: ./gradlew build
- name: Run Integration Tests
working-directory: ./tmp/pa
run: ./gradlew integTest -Dtests.enableIT -Dtests.useDockerCluster
run: ./gradlew integTest -Dtests.enableIT=true -Dtests.useDockerCluster=true
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ import org.ajoberstar.gradle.git.tasks.GitClone
String rcaDir

static def propEnabled(property) {
return System.getProperty(property) != null
return System.getProperty(property) != null && System.getProperty(property).toLowerCase().equals("true")
}

// The following Gradle tasks are used to create a PA/RCA enabled Elasticsearch cluster
Expand Down
12 changes: 9 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
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
# Comment this out if you don't want a cluster spun up
systemProp.tests.useDockerCluster=

# Set this to true if you want a cluster spun up for integration testing
systemProp.tests.useDockerCluster=false

# Set this to true if you want to enable integration testing
systemProp.tests.enableIT=false

# The port number for the PerformanceAnalyzer WebService
systemProp.tests.pa.port=9600
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class PerformanceAnalyzerIT extends ESRestTestCase {
private static final Logger LOG = LogManager.getLogger(PerformanceAnalyzerIT.class);
private static final int PORT = 9600;
private static final int PORT = Integer.parseInt(System.getProperty("tests.pa.port"));
private static final ObjectMapper mapper = new ObjectMapper();
private static RestClient paClient;

Expand Down Expand Up @@ -81,15 +81,17 @@ public static void ensurePaAndRcaEnabled() throws Exception {
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)) {
if (respMap.get("currentPerformanceAnalyzerClusterState").equals(3) &&
!respMap.get("currentPerformanceAnalyzerClusterState").equals(7)) {
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)) {
if (!respMap.get("currentPerformanceAnalyzerClusterState").equals(3) &&
!respMap.get("currentPerformanceAnalyzerClusterState").equals(7)) {
throw new Exception("PA and RCA are not enabled on the target cluster!");
}
}
Expand Down

0 comments on commit 5c34976

Please sign in to comment.