@@ -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 ));
0 commit comments