This repository has been archived by the owner on Mar 17, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Evict all metrics for a cluster on collector stop or failure (#154)
- Loading branch information
Showing
6 changed files
with
98 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/test/scala/com/lightbend/kafkalagexporter/integration/ExporterPorts.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.lightbend.kafkalagexporter.integration | ||
|
||
object ExporterPorts { | ||
val IntegrationSpec = 8000 | ||
val MetricsEvictionSpec = 8001 | ||
val MetricsEvictionOnFailureSpec = 8002 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/test/scala/com/lightbend/kafkalagexporter/integration/MetricsEvictionOnFailureSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2019-2020 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package com.lightbend.kafkalagexporter.integration | ||
|
||
import com.lightbend.kafkalagexporter.Metrics._ | ||
|
||
class MetricsEvictionOnFailureSpec extends SpecBase(exporterPort = ExporterPorts.MetricsEvictionOnFailureSpec) { | ||
"kafka lag exporter" should { | ||
"not report metrics for group members or partitions after a failure" in { | ||
val group = createGroupId(1) | ||
val partition = "0" | ||
val topic = createTopic(1, 1, 1) | ||
|
||
val offsetsToCommit = 5 | ||
val totalOffsets = 10 | ||
|
||
val rules = List( | ||
Rule.create(LatestOffsetMetric, (actual: String) => actual shouldBe (totalOffsets + 1).toDouble.toString, clusterName, topic, partition), | ||
Rule.create(EarliestOffsetMetric, (actual: String) => actual shouldBe 0.toDouble.toString, clusterName, topic, partition), | ||
Rule.create(LastGroupOffsetMetric, (actual: String) => actual shouldBe offsetsToCommit.toDouble.toString, clusterName, group, topic, partition), | ||
Rule.create(OffsetLagMetric, (actual: String) => actual shouldBe (offsetsToCommit + 1).toDouble.toString, clusterName, group, topic, partition), | ||
Rule.create(TimeLagMetric, (_: String) => (), clusterName, group, topic, partition), | ||
Rule.create(MaxGroupOffsetLagMetric, (actual: String) => actual shouldBe (offsetsToCommit + 1).toDouble.toString, clusterName, group), | ||
Rule.create(MaxGroupTimeLagMetric, (_: String) => (), clusterName, group) | ||
) | ||
|
||
val simulator = new LagSimulator(topic, group) | ||
simulator.produceElements(totalOffsets) | ||
simulator.consumeElements(offsetsToCommit) | ||
simulator.shutdown() | ||
|
||
eventually(scrapeAndAssert(exporterPort, "Assert offset-based metrics", rules: _*)) | ||
|
||
stopKafka() | ||
|
||
eventually(scrapeAndAssertDne(exporterPort, "Assert offset-based metrics no longer exist", rules: _*)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters