aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorgjoranv <gv@oath.com>2018-06-22 00:32:36 +0200
committergjoranv <gv@oath.com>2018-06-22 11:22:48 +0200
commit11dc1545ff18be5359a2ae9db3b52f8b723b2fd6 (patch)
tree0599df5dd7c1434b34405c1a92f82ec2cc5118cb /node-repository
parentd244ecaf14c477ce90660e0943691554d928ed8f (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 'node-repository')
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java6
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java13
2 files changed, 12 insertions, 7 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
index 9c9e4e0bc7a..525d2007d7a 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
@@ -24,11 +24,13 @@ import org.junit.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
+import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;
import java.util.stream.Collectors;
+import static java.time.temporal.ChronoUnit.MILLIS;
import static java.util.Collections.singleton;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -93,7 +95,7 @@ public class SerializationTest {
assertEquals(node.allocation().get().membership(), copy.allocation().get().membership());
assertEquals(node.allocation().get().isRemovable(), copy.allocation().get().isRemovable());
assertEquals(1, copy.history().events().size());
- assertEquals(clock.instant(), copy.history().event(History.Event.Type.reserved).get().at());
+ assertEquals(clock.instant().truncatedTo(MILLIS), copy.history().event(History.Event.Type.reserved).get().at());
assertEquals(NodeType.tenant, copy.type());
}
@@ -170,7 +172,7 @@ public class SerializationTest {
node = node.retire(Agent.application, clock.instant());
Node copy = nodeSerializer.fromJson(Node.State.provisioned, nodeSerializer.toJson(node));
assertEquals(2, copy.history().events().size());
- assertEquals(clock.instant(), copy.history().event(History.Event.Type.retired).get().at());
+ assertEquals(clock.instant().truncatedTo(MILLIS), copy.history().event(History.Event.Type.retired).get().at());
assertEquals(Agent.application,
(copy.history().event(History.Event.Type.retired).get()).agent());
assertTrue(copy.allocation().get().membership().retired());
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java
index 2ffe23cea07..a42d4ed1235 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java
@@ -34,6 +34,7 @@ import org.junit.Ignore;
import org.junit.Test;
import java.time.Duration;
+import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@@ -45,6 +46,7 @@ import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
+import static java.time.temporal.ChronoUnit.MILLIS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -736,11 +738,12 @@ public class ProvisioningTest {
"default", tester);
List<Node> reserved = tester.getNodes(application, Node.State.reserved).asList();
assertEquals("Reserved required nodes", 4, reserved.size());
- assertTrue("Time of event is updated for all nodes", reserved.stream()
- .allMatch(n -> n.history()
- .event(History.Event.Type.reserved)
- .get().at()
- .equals(tester.clock().instant())));
+ assertTrue("Time of event is updated for all nodes",
+ reserved.stream()
+ .allMatch(n -> n.history()
+ .event(History.Event.Type.reserved)
+ .get().at()
+ .equals(tester.clock().instant().truncatedTo(MILLIS))));
// Over 10 minutes pass since first reservation. First set of reserved nodes are not expired
tester.clock().advance(Duration.ofMinutes(8).plus(Duration.ofSeconds(1)));