-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #260 from hivemq/fix/17211/metrics-cascade
fix(17211) - Cascase bridge and adapter metrics on delete / stop
- Loading branch information
Showing
8 changed files
with
171 additions
and
34 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
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
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
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
46 changes: 46 additions & 0 deletions
46
hivemq-edge/src/test/java/com/hivemq/bridge/BridgeMetricsTest.java
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,46 @@ | ||
package com.hivemq.bridge; | ||
|
||
import com.codahale.metrics.MetricRegistry; | ||
import com.hivemq.bridge.metrics.PerBridgeMetrics; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Simon L Johnson | ||
*/ | ||
public class BridgeMetricsTest { | ||
|
||
static final String ARBITRARY_METRIC = "arbitrary-metric"; | ||
@Test | ||
void testTearDownMetrics() { | ||
|
||
MetricRegistry registry = new MetricRegistry(); | ||
|
||
//adapter helper creates 10 metrics | ||
PerBridgeMetrics perBridgeMetrics = new PerBridgeMetrics("bridge-name", registry); | ||
|
||
assertEquals(10, registry.getMetrics().size(), "Number of metrics should match"); | ||
|
||
PerBridgeMetrics perBridgeMetrics2 = new PerBridgeMetrics("bridge-name2", registry); | ||
|
||
assertEquals(20, registry.getMetrics().size(), "Number of metrics should match"); | ||
|
||
//add an arbitrary fifth | ||
registry.counter(ARBITRARY_METRIC).inc(); | ||
|
||
assertEquals(21, registry.getMetrics().size(), "Number of metrics should match"); | ||
|
||
perBridgeMetrics.clearAll(registry); | ||
|
||
assertEquals(11, registry.getMetrics().size(), "Number of metrics should match"); | ||
|
||
perBridgeMetrics2.clearAll(registry); | ||
|
||
assertEquals(1, registry.getMetrics().size(), "Number of metrics should match"); | ||
|
||
assertEquals(1, registry.getCounters().get(ARBITRARY_METRIC).getCount(), "Matching success data point should be incremented"); | ||
|
||
} | ||
|
||
} |