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

Odfe it framework release #107

Merged
Prev Previous commit
Next Next commit
Modify gradle.yml and checkMetrics
Sid Narayan committed May 26, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 998f7bc6f09915bc8e6f394337da9e6a3ae0ccfa
5 changes: 4 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -39,10 +39,13 @@ jobs:
- name: Update SHA
working-directory: ./tmp/pa
run: ./gradlew updateShas
# Explicitly set the docker-compose program path so that our build scripts in RCA can run the program
# This is necessary because of the Github Actions environment and the workingDir of the Gradle environment
- name: Set docker-compose path
run: echo ::set-env name=DOCKER_COMPOSE_LOCATION::$(which docker-compose)
# Set the vm.max_map_count system property to the minimum required to run Elasticsearch
- name: Set vm.max_map_count
Copy link
Contributor

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

run: sudo sysctl -w vm.max_map_count=262144
- name: Start Build
working-directory: ./tmp/pa
run: ./gradlew build --info --stacktrace
run: ./gradlew build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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;
@@ -12,6 +13,7 @@
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;

@@ -60,15 +62,40 @@ public static void ensurePaAndRcaEnabled() throws Exception {
}
}

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";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move the class definition to the end of the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@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 resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
LOG.info("PA is emitting metrics!! {}", EntityUtils.toString(resp.getEntity(), "UTF-8"));
System.out.println("WASSUP");
Assert.assertEquals(HttpStatus.SC_OK, resp.getStatusLine().getStatusCode());
ObjectMapper mapper = new ObjectMapper();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a new ObjectMapper here? Can we re-use the one defined on line 28?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

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