diff options
author | gjoranv <gv@oath.com> | 2018-06-22 00:32:36 +0200 |
---|---|---|
committer | gjoranv <gv@oath.com> | 2018-06-22 11:22:48 +0200 |
commit | 11dc1545ff18be5359a2ae9db3b52f8b723b2fd6 (patch) | |
tree | 0599df5dd7c1434b34405c1a92f82ec2cc5118cb /controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java | |
parent | d244ecaf14c477ce90660e0943691554d928ed8f (diff) |
Java 9: Truncate Instants from Instant.now() to MILLIS
- JDK 9 has higher resolution for Instant.now() than JDK 1.8, while
instants deserialized from slime only has ms resolution.
Diffstat (limited to 'controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java index 768164c3002..fc1548fbcf4 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java @@ -13,8 +13,10 @@ import org.junit.Test; import java.time.Duration; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.function.Supplier; +import static java.time.temporal.ChronoUnit.MILLIS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -50,13 +52,13 @@ public class DeploymentMetricsMaintainerTest { assertEquals(3, deployment.get().metrics().documentCount(), Double.MIN_VALUE); assertEquals(4, deployment.get().metrics().queryLatencyMillis(), Double.MIN_VALUE); assertEquals(5, deployment.get().metrics().writeLatencyMillis(), Double.MIN_VALUE); - Instant t1 = tester.clock().instant(); + Instant t1 = tester.clock().instant().truncatedTo(MILLIS); assertEquals(t1, deployment.get().activity().lastQueried().get()); assertEquals(t1, deployment.get().activity().lastWritten().get()); // Time passes. Activity is updated as app is still receiving traffic tester.clock().advance(Duration.ofHours(1)); - Instant t2 = tester.clock().instant(); + Instant t2 = tester.clock().instant().truncatedTo(MILLIS); maintainer.maintain(); assertEquals(t2, deployment.get().activity().lastQueried().get()); assertEquals(t2, deployment.get().activity().lastWritten().get()); @@ -65,7 +67,7 @@ public class DeploymentMetricsMaintainerTest { // Query traffic disappears. Query activity stops updating tester.clock().advance(Duration.ofHours(1)); - Instant t3 = tester.clock().instant(); + Instant t3 = tester.clock().instant().truncatedTo(MILLIS); tester.metricsService().setMetric("queriesPerSecond", 0D); tester.metricsService().setMetric("writesPerSecond", 5D); maintainer.maintain(); |