Skip to content

Commit 425d182

Browse files
committed
fix the skip logic in validator
1 parent a7b99d5 commit 425d182

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

validator/src/main/java/com/amazon/aoc/validators/MetricValidator.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,20 @@ public void validate() throws Exception {
5656
log.info("Start metric validating");
5757
final List<Metric> expectedMetricList = this.getExpectedMetricList(context);
5858
CloudWatchService cloudWatchService = new CloudWatchService(context.getRegion());
59-
6059
RetryHelper.retry(
6160
MAX_RETRY_COUNT,
6261
() -> {
6362
List<Metric> metricList =
6463
this.listMetricFromCloudWatch(cloudWatchService, expectedMetricList);
64+
65+
// remove the skip dimensions
66+
for (Metric metric : expectedMetricList) {
67+
metric.getDimensions().removeIf(dimension -> dimension.getValue().equals("SKIP"));
68+
}
69+
for (Metric metric : metricList) {
70+
metric.getDimensions().removeIf(dimension -> dimension.getValue().equals("SKIP"));
71+
}
72+
6573
log.info("check if all the expected metrics are found");
6674
compareMetricLists(expectedMetricList, metricList);
6775

@@ -99,23 +107,6 @@ private void compareMetricLists(List<Metric> toBeCheckedMetricList, List<Metric>
99107
List<Dimension> dimensionList1 = o1.getDimensions();
100108
List<Dimension> dimensionList2 = o2.getDimensions();
101109

102-
// remove the skipped dimension
103-
List<String> skippedDimensionNames = new ArrayList<>();
104-
for (Dimension dimension : dimensionList1) {
105-
if (dimension.getValue().equals("SKIP")) {
106-
skippedDimensionNames.add(dimension.getName());
107-
}
108-
}
109-
for (Dimension dimension : dimensionList2) {
110-
if (dimension.getValue().equals("SKIP")) {
111-
skippedDimensionNames.add(dimension.getName());
112-
}
113-
}
114-
for (String dimensionName : skippedDimensionNames) {
115-
dimensionList1.removeIf(dimension -> dimension.getName().equals(dimensionName));
116-
dimensionList2.removeIf(dimension -> dimension.getName().equals(dimensionName));
117-
}
118-
119110
// sort
120111
dimensionList1.sort(Comparator.comparing(Dimension::getName));
121112
dimensionList2.sort(Comparator.comparing(Dimension::getName));

validator/src/main/resources/expected-data-template/ecsContainerExpectedMetric.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-
22
metricName: ecs.task.memory.utilized_{{testingId}}
3-
namespace: default
3+
namespace: {{metricNamespace}}
44
dimensions:
55
-
66
name: ecs.cluster
@@ -10,7 +10,7 @@
1010
value: "undefined"
1111
-
1212
name: ecs.task-arn
13-
value: "{{ecsContext.ecsTaskArn}}"
13+
value: "SKIP"
1414
-
1515
name: ecs.task-definition-family
1616
value: "{{ecsContext.ecsTaskDefFamily}}"

0 commit comments

Comments
 (0)