-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for Metric Rollup Addition of [RemoteService, RemoteTarget, ...] #729
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,12 +30,14 @@ | |||||
import com.google.common.collect.Lists; | ||||||
import java.io.IOException; | ||||||
import java.util.ArrayList; | ||||||
import java.util.Arrays; | ||||||
import java.util.Comparator; | ||||||
import java.util.HashMap; | ||||||
import java.util.HashSet; | ||||||
import java.util.List; | ||||||
import java.util.Set; | ||||||
import java.util.TreeSet; | ||||||
import kotlin.Pair; | ||||||
import lombok.extern.log4j.Log4j2; | ||||||
|
||||||
@Log4j2 | ||||||
|
@@ -103,16 +105,27 @@ public void validate() throws Exception { | |||||
} | ||||||
|
||||||
List<Metric> actualMetricList = Lists.newArrayList(); | ||||||
addMetrics( | ||||||
CloudWatchService.SERVICE_DIMENSION, | ||||||
serviceNames, | ||||||
expectedMetricList, | ||||||
actualMetricList); | ||||||
addMetrics( | ||||||
CloudWatchService.REMOTE_SERVICE_DIMENSION, | ||||||
remoteServiceNames, | ||||||
expectedMetricList, | ||||||
actualMetricList); | ||||||
|
||||||
// Add sets of dimesion filters to use for each query to CloudWatch | ||||||
List<List<Pair<String, String>>> dimensionLists = Lists.newArrayList(); | ||||||
for (String serviceName : serviceNames) { | ||||||
dimensionLists.add( | ||||||
Arrays.asList(new Pair<>(CloudWatchService.SERVICE_DIMENSION, serviceName))); | ||||||
} | ||||||
for (String remoteServiceName : remoteServiceNames) { | ||||||
dimensionLists.add( | ||||||
Arrays.asList( | ||||||
new Pair<>(CloudWatchService.REMOTE_SERVICE_DIMENSION, remoteServiceName))); | ||||||
} | ||||||
Comment on lines
+115
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this new logic able to pull This is due to the fact that when trying to pull |
||||||
dimensionLists.add( | ||||||
Arrays.asList( | ||||||
new Pair<>(CloudWatchService.REMOTE_SERVICE_DIMENSION, "AWS.SDK.S3"), | ||||||
new Pair<>(CloudWatchService.REMOTE_TARGET_DIMENSION, "e2e-test-bucket-name"))); | ||||||
Comment on lines
+120
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once the metric exists, how do we know whether the test that just occurred is the one that populated it or if it simply exists from a previous test run? It's entirely possible that a test from 2 hours ago created the metric and then all tests since then did not appropriately populate this metric but because of our This is the same issue we had with trying to check Note: |
||||||
|
||||||
// Populate actualMetricList with each set of dimension filters | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
for (List<Pair<String, String>> dimensionList : dimensionLists) { | ||||||
addMetrics(dimensionList, expectedMetricList, actualMetricList); | ||||||
} | ||||||
|
||||||
// remove the skip dimensions | ||||||
log.info("dimensions to be skipped in validation: {}", skippedDimensionNameList); | ||||||
|
@@ -132,16 +145,12 @@ public void validate() throws Exception { | |||||
} | ||||||
|
||||||
private void addMetrics( | ||||||
String dimensionName, | ||||||
List<String> dimensionValues, | ||||||
List<Pair<String, String>> dimensionList, | ||||||
List<Metric> expectedMetricList, | ||||||
List<Metric> actualMetricList) | ||||||
throws Exception { | ||||||
for (String dimensionValue : dimensionValues) { | ||||||
actualMetricList.addAll( | ||||||
this.listMetricFromCloudWatch( | ||||||
cloudWatchService, expectedMetricList, dimensionName, dimensionValue)); | ||||||
} | ||||||
actualMetricList.addAll( | ||||||
this.listMetricFromCloudWatch(cloudWatchService, expectedMetricList, dimensionList)); | ||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -194,8 +203,7 @@ private void compareMetricLists(List<Metric> toBeCheckedMetricList, List<Metric> | |||||
private List<Metric> listMetricFromCloudWatch( | ||||||
CloudWatchService cloudWatchService, | ||||||
List<Metric> expectedMetricList, | ||||||
String dimensionKey, | ||||||
String dimensionValue) | ||||||
List<Pair<String, String>> dimensionList) | ||||||
throws IOException { | ||||||
// put namespace into the map key, so that we can use it to search metric | ||||||
HashMap<String, String> metricNameMap = new HashMap<>(); | ||||||
|
@@ -207,8 +215,7 @@ private List<Metric> listMetricFromCloudWatch( | |||||
List<Metric> result = new ArrayList<>(); | ||||||
for (String metricName : metricNameMap.keySet()) { | ||||||
result.addAll( | ||||||
cloudWatchService.listMetrics( | ||||||
metricNameMap.get(metricName), metricName, dimensionKey, dimensionValue)); | ||||||
cloudWatchService.listMetrics(metricNameMap.get(metricName), metricName, dimensionList)); | ||||||
} | ||||||
return result; | ||||||
} | ||||||
|
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.
We've now added a second edge case to this logic, i.e. the [RemoteService] and [RemoteService, RemoteTarget] aggregations. It would be worth adding a larger comment here explaining what's happening and explain why in the PR description for future reference.
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.
Please be more descriptive in other comments in your PR as well.