Skip to content

Commit

Permalink
Atlas Cloud Watch: Add a unit test validating separate min/max rules (#…
Browse files Browse the repository at this point in the history
…423)

via streaming.
  • Loading branch information
manolama authored Mar 20, 2023
1 parent f781e21 commit 8610b9a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
10 changes: 10 additions & 0 deletions atlas-cloudwatch/src/test/resources/test-rules.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ atlas {
name = "Max"
alias = "aws.utm.max"
conversion = "max"
},
{
name = "TwoRuleMatch"
alias = "aws.utm.2rulematch"
conversion = "min"
},
{
name = "TwoRuleMatch"
alias = "aws.utm.2rulematch"
conversion = "max"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,49 @@ class CloudWatchMetricsProcessorSuite extends FunSuite with TestKitBase with Imp
assertCounters(1, publishFuture = 1)
}

test("processDatapoints 2 rules match") {
processor.processDatapoints(
List(
makeFirehoseMetric(
"AWS/UT1",
"TwoRuleMatch",
List(Dimension.builder().name("MyTag").value("Val").build()),
Array(39.0, 1.0, 7.0, 19),
"None",
timestamp - 60_00
)
),
timestamp - 60_00
)

// yup, two values with the same tag set. Just the min and max values.
assertPublished(
List(
com.netflix.atlas.core.model.Datapoint(
Map(
"name" -> "aws.utm.2rulematch",
"nf.region" -> "us-west-2",
"aws.tag" -> "Val",
"atlas.dstype" -> "gauge"
),
timestamp,
1
),
com.netflix.atlas.core.model.Datapoint(
Map(
"name" -> "aws.utm.2rulematch",
"nf.region" -> "us-west-2",
"aws.tag" -> "Val",
"atlas.dstype" -> "gauge"
),
timestamp,
7
)
)
)
assertCounters(1)
}

test("normalize") {
assertEquals(1677706140000L, normalize(1677706164123L, 60))
assertEquals(1677705900000L, normalize(1677706164123L, 300))
Expand Down Expand Up @@ -941,7 +984,7 @@ class CloudWatchMetricsProcessorSuite extends FunSuite with TestKitBase with Imp
assertEquals(routerCaptor.values.size, dps.size)

dps.foreach { dp =>
val metric = routerCaptor.values.filter(_.tags.equals(dp.tags)).headOption match {
val metric = routerCaptor.values.filter(_.equals(dp)).headOption match {
case Some(d) => d
case None =>
throw new AssertionError(s"Data point not found: ${dp} in ${routerCaptor.values}")
Expand Down

0 comments on commit 8610b9a

Please sign in to comment.