aboutsummaryrefslogtreecommitdiffstats
path: root/jrt/tests
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2019-01-21 13:58:19 +0100
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2019-01-22 12:26:50 +0100
commite7a2b1be18fa1b9238ec863f8b99cb73183c3afd (patch)
treedf53e3fa450442e4ea677453ae20bce10ee83a8a /jrt/tests
parent485f81f1eb9200511b22c7f984363592567b1508 (diff)
Add calculation of metrics changes since previous snapshot
- Move metric diff calculation to TransportMetrics.Snapshot. - Remove TransportMetrics.reset() and use changesSince() instead in EchoTest. - Remove unnecessary volatile modifier on JrtMetrics.previousSnapshot. - Initialize JrtMetrics.previousSnapshot in constructor. - Use separate field declarations for fields in TransportMetrics.Snapshot.
Diffstat (limited to 'jrt/tests')
-rw-r--r--jrt/tests/com/yahoo/jrt/EchoTest.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/jrt/tests/com/yahoo/jrt/EchoTest.java b/jrt/tests/com/yahoo/jrt/EchoTest.java
index 4ca9ba2bd64..8fe98ff3510 100644
--- a/jrt/tests/com/yahoo/jrt/EchoTest.java
+++ b/jrt/tests/com/yahoo/jrt/EchoTest.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertTrue;
public class EchoTest {
TransportMetrics metrics;
+ TransportMetrics.Snapshot startSnapshot;
Supervisor server;
Acceptor acceptor;
Supervisor client;
@@ -24,7 +25,7 @@ public class EchoTest {
Values refValues;
private interface MetricsAssertions {
- void assertMetrics(TransportMetrics metrics) throws AssertionError;
+ void assertMetrics(TransportMetrics.Snapshot snapshot) throws AssertionError;
}
@Parameter(value = 0) public CryptoEngine crypto;
@@ -63,7 +64,7 @@ public class EchoTest {
@Before
public void setUp() throws ListenFailedException {
metrics = TransportMetrics.getInstance();
- metrics.reset();
+ startSnapshot = metrics.snapshot();
server = new Supervisor(new Transport(crypto));
client = new Supervisor(new Transport(crypto));
acceptor = server.listen(new Spec(0));
@@ -134,7 +135,7 @@ public class EchoTest {
assertTrue(Test.equals(req.returnValues(), refValues));
assertTrue(Test.equals(req.parameters(), refValues));
if (metricsAssertions != null) {
- metricsAssertions.assertMetrics(metrics);
+ metricsAssertions.assertMetrics(metrics.snapshot().changesSince(startSnapshot));
}
}
}