aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com/yahoo
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 /controller-server/src/test/java/com/yahoo
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 'controller-server/src/test/java/com/yahoo')
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java39
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java4
3 files changed, 28 insertions, 23 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
index 621eb33bd66..6b7dd768502 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
@@ -61,6 +61,7 @@ import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobTy
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsWest1;
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest;
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest;
+import static java.time.temporal.ChronoUnit.MILLIS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -104,12 +105,12 @@ public class ControllerTest {
ApplicationVersion applicationVersion = tester.controller().applications().require(app1.id()).change().application().get();
assertFalse("Application version has been set during deployment", applicationVersion.isUnknown());
assertStatus(JobStatus.initial(stagingTest)
- .withTriggering(version1, applicationVersion, Optional.empty(),"", tester.clock().instant())
- .withCompletion(42, Optional.empty(), tester.clock().instant()), app1.id(), tester.controller());
+ .withTriggering(version1, applicationVersion, Optional.empty(),"", tester.clock().instant().truncatedTo(MILLIS))
+ .withCompletion(42, Optional.empty(), tester.clock().instant().truncatedTo(MILLIS)), app1.id(), tester.controller());
// Causes first deployment job to be triggered
assertStatus(JobStatus.initial(productionCorpUsEast1)
- .withTriggering(version1, applicationVersion, Optional.empty(), "", tester.clock().instant()), app1.id(), tester.controller());
+ .withTriggering(version1, applicationVersion, Optional.empty(), "", tester.clock().instant().truncatedTo(MILLIS)), app1.id(), tester.controller());
tester.clock().advance(Duration.ofSeconds(1));
// production job (failing) after deployment
@@ -118,13 +119,13 @@ public class ControllerTest {
assertEquals(4, applications.require(app1.id()).deploymentJobs().jobStatus().size());
JobStatus expectedJobStatus = JobStatus.initial(productionCorpUsEast1)
- .withTriggering(version1, applicationVersion, Optional.empty(), "", tester.clock().instant()) // Triggered first without application version info
- .withCompletion(42, Optional.of(JobError.unknown), tester.clock().instant())
+ .withTriggering(version1, applicationVersion, Optional.empty(), "", tester.clock().instant().truncatedTo(MILLIS)) // Triggered first without application version info
+ .withCompletion(42, Optional.of(JobError.unknown), tester.clock().instant().truncatedTo(MILLIS))
.withTriggering(version1,
applicationVersion,
Optional.of(tester.application(app1.id()).deployments().get(productionCorpUsEast1.zone(main).get())),
"",
- tester.clock().instant()); // Re-triggering (due to failure) has application version info
+ tester.clock().instant().truncatedTo(MILLIS)); // Re-triggering (due to failure) has application version info
assertStatus(expectedJobStatus, app1.id(), tester.controller());
@@ -147,8 +148,8 @@ public class ControllerTest {
applicationVersion = tester.application("app1").change().application().get();
tester.deployAndNotify(app1, applicationPackage, true, systemTest);
assertStatus(JobStatus.initial(systemTest)
- .withTriggering(version1, applicationVersion, productionCorpUsEast1.zone(main).map(tester.application(app1.id()).deployments()::get), "", tester.clock().instant())
- .withCompletion(42, Optional.empty(), tester.clock().instant()),
+ .withTriggering(version1, applicationVersion, productionCorpUsEast1.zone(main).map(tester.application(app1.id()).deployments()::get), "", tester.clock().instant().truncatedTo(MILLIS))
+ .withCompletion(42, Optional.empty(), tester.clock().instant().truncatedTo(MILLIS)),
app1.id(), tester.controller());
tester.clock().advance(Duration.ofHours(1)); // Stop retrying
tester.jobCompletion(productionCorpUsEast1).application(app1).unsuccessful().submit();
@@ -156,14 +157,14 @@ public class ControllerTest {
// production job succeeding now
expectedJobStatus = expectedJobStatus
- .withTriggering(version1, applicationVersion, productionCorpUsEast1.zone(main).map(tester.application(app1.id()).deployments()::get), "", tester.clock().instant())
- .withCompletion(42, Optional.empty(), tester.clock().instant());
+ .withTriggering(version1, applicationVersion, productionCorpUsEast1.zone(main).map(tester.application(app1.id()).deployments()::get), "", tester.clock().instant().truncatedTo(MILLIS))
+ .withCompletion(42, Optional.empty(), tester.clock().instant().truncatedTo(MILLIS));
tester.deployAndNotify(app1, applicationPackage, true, productionCorpUsEast1);
assertStatus(expectedJobStatus, app1.id(), tester.controller());
// causes triggering of next production job
assertStatus(JobStatus.initial(productionUsEast3)
- .withTriggering(version1, applicationVersion, Optional.empty(), "", tester.clock().instant()),
+ .withTriggering(version1, applicationVersion, Optional.empty(), "", tester.clock().instant().truncatedTo(MILLIS)),
app1.id(), tester.controller());
tester.deployAndNotify(app1, applicationPackage, true, productionUsEast3);
@@ -374,7 +375,7 @@ public class ControllerTest {
Application app = tester.createApplication("app1", "foo", 1, 1L);
// Initial failure
- Instant initialFailure = tester.clock().instant();
+ Instant initialFailure = tester.clock().instant().truncatedTo(MILLIS);
tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit();
tester.deployAndNotify(app, applicationPackage, false, systemTest);
assertEquals("Failure age is right at initial failure",
@@ -398,7 +399,7 @@ public class ControllerTest {
// Two repeated failures again.
// Initial failure
tester.clock().advance(Duration.ofMillis(1000));
- initialFailure = tester.clock().instant();
+ initialFailure = tester.clock().instant().truncatedTo(MILLIS);
tester.jobCompletion(component).application(app).nextBuildNumber().uploadArtifact(applicationPackage).submit();
tester.deployAndNotify(app, applicationPackage, false, systemTest);
assertEquals("Failure age is right at initial failure",
@@ -840,22 +841,22 @@ public class ControllerTest {
tester.deployAndNotify(app, applicationPackage, true, stagingTest);
JobStatus expected = JobStatus.initial(stagingTest)
.withTriggering(vespaVersion, version, productionCorpUsEast1.zone(main).map(tester.application(app.id()).deployments()::get), "",
- tester.clock().instant())
- .withCompletion(42, Optional.empty(), tester.clock().instant());
+ tester.clock().instant().truncatedTo(MILLIS))
+ .withCompletion(42, Optional.empty(), tester.clock().instant().truncatedTo(MILLIS));
assertStatus(expected, app.id(), tester.controller());
// Deploy in production
expected = JobStatus.initial(productionCorpUsEast1)
.withTriggering(vespaVersion, version, productionCorpUsEast1.zone(main).map(tester.application(app.id()).deployments()::get), "",
- tester.clock().instant())
- .withCompletion(42, Optional.empty(), tester.clock().instant());
+ tester.clock().instant().truncatedTo(MILLIS))
+ .withCompletion(42, Optional.empty(), tester.clock().instant().truncatedTo(MILLIS));
tester.deployAndNotify(app, applicationPackage, true, productionCorpUsEast1);
assertStatus(expected, app.id(), tester.controller());
expected = JobStatus.initial(productionUsEast3)
.withTriggering(vespaVersion, version, productionUsEast3.zone(main).map(tester.application(app.id()).deployments()::get), "",
- tester.clock().instant())
- .withCompletion(42, Optional.empty(), tester.clock().instant());
+ tester.clock().instant().truncatedTo(MILLIS))
+ .withCompletion(42, Optional.empty(), tester.clock().instant().truncatedTo(MILLIS));
tester.deployAndNotify(app, applicationPackage, true, productionUsEast3);
assertStatus(expected, app.id(), tester.controller());
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();
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java
index bba53f42a61..0baa56ca9b8 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java
@@ -10,11 +10,13 @@ import com.yahoo.vespa.hosted.controller.versions.VespaVersion;
import org.junit.Test;
import java.time.Instant;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
+import static java.time.temporal.ChronoUnit.MILLIS;
import static org.junit.Assert.assertEquals;
/**
@@ -46,7 +48,7 @@ public class VersionStatusSerializerTest {
VespaVersion a = status.versions().get(i);
VespaVersion b = deserialized.versions().get(i);
assertEquals(a.releaseCommit(), b.releaseCommit());
- assertEquals(a.committedAt(), b.committedAt());
+ assertEquals(a.committedAt().truncatedTo(MILLIS), b.committedAt());
assertEquals(a.isControllerVersion(), b.isControllerVersion());
assertEquals(a.isSystemVersion(), b.isSystemVersion());
assertEquals(a.statistics(), b.statistics());