Skip to content

Commit

Permalink
Add workflow for gauntlet tests and fix spotbug errors (opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#63)

* Add workflow for gauntlet tests and fix spotbug errors

Signed-off-by: Sruti Parthiban <partsrut@amazon.com>

* Fix failing gauntlet tests

Signed-off-by: Sruti Parthiban <partsrut@amazon.com>

* Exclude slow/failing tests

Signed-off-by: Sruti Parthiban <partsrut@amazon.com>

* Update the coverage for gaunlet tests

Signed-off-by: Sruti Parthiban <partsrut@amazon.com>

* [AdmissionControlRca] Pass healthy context explicitly (opensearch-project#67)

Signed-off-by: Mital Awachat <awachatm@amazon.com>

Co-authored-by: Mital Awachat <awachatm@amazon.com>

Co-authored-by: Mital Awachat <mitalawachat@users.noreply.github.com>
Co-authored-by: Mital Awachat <awachatm@amazon.com>
  • Loading branch information
3 people authored Sep 8, 2021
1 parent abdd9df commit cdcae41
Show file tree
Hide file tree
Showing 16 changed files with 456 additions and 244 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/gauntlet-tests-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Gauntlet tests Runner

on:
push:
branches:
- "*"

pull_request:
branches:
- "*"

jobs:
build_rca_pkg:
runs-on: [ubuntu-latest]
name: Build and Run Gauntlet tests
steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 14
# RCA in ./tmp/performance-analyzer-rca
- name: Checkout RCA
uses: actions/checkout@v2
with:
path: ./tmp/performance-analyzer-rca
- name: Build RCA and run Gauntlet tests
working-directory: ./tmp/performance-analyzer-rca
run: ./gradlew build -Drun.gauntlet.tests=true -Dopensearch.version=1.1.0-SNAPSHOT
41 changes: 30 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ext {
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
gitPaBranch = 'main'
gitPaRepo = "https://github.com/opensearch-project/performance-analyzer.git"
runGauntletTests = "true" == System.getProperty("run.gauntlet.tests", "false")
}

spotless {
Expand Down Expand Up @@ -179,12 +180,23 @@ jacocoTestCoverageVerification {
'**/org/opensearch/performanceanalyzer/grpc/**'])
})
}
violationRules {
rule {
limit {
minimum = 0.7
if (runGauntletTests) {
violationRules {
rule {
limit {
minimum = 0.4
}
}
}
}
else {
violationRules {
rule {
limit {
minimum = 0.7
}
}
}
}
}

Expand All @@ -211,13 +223,20 @@ publishing {
}

test {
filter {
// TODO: slow integration tests were disabled
// see https://github.com/opensearch-project/performance-analyzer-rca/issues/57
excludeTestsMatching 'org.opensearch.performanceanalyzer.reader.OSMetricsSnapshotTests'
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.RcaControllerTest'
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.persistence.SQLitePersistorTest'
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.integTests.*'
if (!runGauntletTests) {
filter {
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.integTests.*'
// TODO: Fix this test as it causes OutOfMemoryError: Java heap space error and runs forever
excludeTestsMatching 'org.opensearch.performanceanalyzer.reader.OSMetricsSnapshotTests'
}
}
else {
filter {
includeTestsMatching 'org.opensearch.performanceanalyzer.rca.integTests.*'
// Ignore failing tests (known issues with the test)
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.integTests.tests.jvmsizing.HeapSizeIncreaseMissingMetricsTest'
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.integTests.tests.consolidate_tuning.JvmFlipFlopITest'
}
}
enabled = true
retry {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
Expand All @@ -17,16 +28,16 @@

import static org.opensearch.performanceanalyzer.decisionmaker.actions.ImpactVector.Dimension.ADMISSION_CONTROL;

import org.opensearch.performanceanalyzer.AppContext;
import org.opensearch.performanceanalyzer.rca.framework.core.RcaConf;
import org.opensearch.performanceanalyzer.rca.store.rca.cluster.NodeKey;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.opensearch.performanceanalyzer.AppContext;
import org.opensearch.performanceanalyzer.rca.framework.core.RcaConf;
import org.opensearch.performanceanalyzer.rca.store.rca.cluster.NodeKey;

public class AdmissionControlAction extends SuppressibleAction {

Expand All @@ -41,12 +52,12 @@ public class AdmissionControlAction extends SuppressibleAction {
private final double currentValue;

public AdmissionControlAction(
AppContext appContext,
final NodeKey esNode,
final String controllerName,
final boolean canUpdate,
final double desiredValue,
final double currentValue) {
AppContext appContext,
final NodeKey esNode,
final String controllerName,
final boolean canUpdate,
final double desiredValue,
final double currentValue) {
super(appContext);
this.esNode = esNode;
this.canUpdate = canUpdate;
Expand All @@ -56,10 +67,10 @@ public AdmissionControlAction(
}

public static Builder newBuilder(
final NodeKey esNode,
final String controllerName,
final AppContext appContext,
final RcaConf conf) {
final NodeKey esNode,
final String controllerName,
final AppContext appContext,
final RcaConf conf) {
return new Builder(esNode, controllerName, appContext, conf);
}

Expand Down Expand Up @@ -103,13 +114,13 @@ public Map<NodeKey, ImpactVector> impact() {
@Override
public String summary() {
Summary summary =
new Summary(
esNode.getNodeId().toString(),
esNode.getHostAddress().toString(),
desiredValue,
currentValue,
DEFAULT_COOL_OFF_PERIOD_IN_MILLIS,
canUpdate);
new Summary(
esNode.getNodeId().toString(),
esNode.getHostAddress().toString(),
desiredValue,
currentValue,
DEFAULT_COOL_OFF_PERIOD_IN_MILLIS,
canUpdate);
return summary.toJson();
}

Expand All @@ -130,10 +141,10 @@ public static final class Builder {
private Double desiredValue;

private Builder(
final NodeKey esNode,
final String controllerName,
final AppContext appContext,
final RcaConf conf) {
final NodeKey esNode,
final String controllerName,
final AppContext appContext,
final RcaConf conf) {
this.esNode = esNode;
this.controllerName = controllerName;
this.appContext = appContext;
Expand All @@ -153,7 +164,7 @@ public Builder desiredValue(Double desiredValue) {
public AdmissionControlAction build() {
boolean canUpdate = desiredValue != 0;
return new AdmissionControlAction(
appContext, esNode, controllerName, canUpdate, desiredValue, currentValue);
appContext, esNode, controllerName, canUpdate, desiredValue, currentValue);
}
}

Expand Down Expand Up @@ -185,12 +196,12 @@ public static class Summary {
private boolean canUpdate;

public Summary(
String id,
String ip,
double desiredValue,
double currentValue,
long coolOffPeriodInMillis,
boolean canUpdate) {
String id,
String ip,
double desiredValue,
double currentValue,
long coolOffPeriodInMillis,
boolean canUpdate) {
this.id = id;
this.ip = ip;
this.desiredValue = desiredValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@

import static org.opensearch.performanceanalyzer.rca.store.rca.admissioncontrol.AdmissionControlRca.REQUEST_SIZE;

import java.time.Instant;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import org.opensearch.performanceanalyzer.decisionmaker.actions.AdmissionControlAction;
import org.opensearch.performanceanalyzer.grpc.ResourceEnum;
import org.opensearch.performanceanalyzer.rca.framework.api.flow_units.ResourceFlowUnit;
import org.opensearch.performanceanalyzer.rca.framework.api.summaries.HotNodeSummary;
import org.opensearch.performanceanalyzer.rca.framework.api.summaries.HotResourceSummary;
import org.opensearch.performanceanalyzer.rca.store.rca.admissioncontrol.AdmissionControlClusterRca;
import org.opensearch.performanceanalyzer.rca.store.rca.cluster.NodeKey;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

public class AdmissionControlDecider extends Decider {

Expand All @@ -48,9 +48,9 @@ public class AdmissionControlDecider extends Decider {
private AdmissionControlClusterRca admissionControlClusterRca;

public AdmissionControlDecider(
long evalIntervalSeconds,
int decisionFrequency,
AdmissionControlClusterRca admissionControlClusterRca) {
long evalIntervalSeconds,
int decisionFrequency,
AdmissionControlClusterRca admissionControlClusterRca) {
super(evalIntervalSeconds, decisionFrequency);
this.admissionControlClusterRca = admissionControlClusterRca;
}
Expand All @@ -71,24 +71,29 @@ public Decision operate() {

List<AdmissionControlAction> heapBasedActions = getHeapBasedActions();
heapBasedActions.stream()
.max(Comparator.comparingDouble(AdmissionControlAction::getDesiredValue))
.ifPresent(decision::addAction);
.max(Comparator.comparingDouble(AdmissionControlAction::getDesiredValue))
.ifPresent(decision::addAction);

return decision;
}

private List<AdmissionControlAction> getHeapBasedActions() {
List<AdmissionControlAction> heapBasedActions = new ArrayList<>();
admissionControlClusterRca.getFlowUnits().stream()
.filter(ResourceFlowUnit::hasResourceSummary)
.flatMap(clusterRcaFlowUnits -> clusterRcaFlowUnits.getSummary().getHotNodeSummaryList().stream())
.forEach(hotNodeSummary -> {
hotNodeSummary.getHotResourceSummaryList().stream()
.filter(this::isHeapResource)
.map(hotResourceSummary -> getAction(hotNodeSummary, hotResourceSummary))
.filter(Objects::nonNull)
.forEach(heapBasedActions::add);
});
.filter(ResourceFlowUnit::hasResourceSummary)
.flatMap(
clusterRcaFlowUnits ->
clusterRcaFlowUnits.getSummary().getHotNodeSummaryList().stream())
.forEach(
hotNodeSummary -> {
hotNodeSummary.getHotResourceSummaryList().stream()
.filter(this::isHeapResource)
.map(
hotResourceSummary ->
getAction(hotNodeSummary, hotResourceSummary))
.filter(Objects::nonNull)
.forEach(heapBasedActions::add);
});
return heapBasedActions;
}

Expand All @@ -97,15 +102,15 @@ private boolean isHeapResource(HotResourceSummary hotResourceSummary) {
}

private AdmissionControlAction getAction(
HotNodeSummary hotNodeSummary, HotResourceSummary hotResourceSummary) {
HotNodeSummary hotNodeSummary, HotResourceSummary hotResourceSummary) {
double currentHeapPercent = hotResourceSummary.getValue();
double desiredThreshold = hotResourceSummary.getThreshold();
NodeKey esNode = new NodeKey(hotNodeSummary.getNodeID(), hotNodeSummary.getHostAddress());
AdmissionControlAction action =
AdmissionControlAction.newBuilder(esNode, REQUEST_SIZE, getAppContext(), rcaConf)
.currentValue(currentHeapPercent)
.desiredValue(desiredThreshold)
.build();
AdmissionControlAction.newBuilder(esNode, REQUEST_SIZE, getAppContext(), rcaConf)
.currentValue(currentHeapPercent)
.desiredValue(desiredThreshold)
.build();
return action.isActionable() ? action : null;
}
}
Loading

0 comments on commit cdcae41

Please sign in to comment.