diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-09-13 13:48:40 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-09-13 13:48:40 +0200 |
commit | 5aeb3e1a0f86433a4156b848ad579eeb2894abfa (patch) | |
tree | 96134dca1c9037e40a2bbf3f909bb93aaa191cb7 /controller-server/src/test/java/com | |
parent | 19e020e201b6a7bf3acd972b6238bdfc68752202 (diff) |
Handle log server giving overlapping log windows (with micro precision)
Diffstat (limited to 'controller-server/src/test/java/com')
6 files changed, 42 insertions, 37 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java index 5447d6e44d4..50d34226cae 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java @@ -1,6 +1,7 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.deployment; +import com.google.common.collect.ImmutableList; import com.yahoo.component.Version; import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.provision.AthenzDomain; @@ -35,6 +36,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.security.cert.X509Certificate; import java.time.Duration; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -267,29 +270,29 @@ public class InternalStepRunnerTest { @Test public void testsFailIfTestsFailRemotely() { RunId id = tester.startSystemTestTests(); - tester.cloud().add(new LogEntry(123, 321, error, "Failure!")); + tester.cloud().add(new LogEntry(123, Instant.ofEpochMilli(321), error, "Failure!")); tester.cloud().set(TesterCloud.Status.FAILURE); long lastId = tester.jobs().details(id).get().lastId().getAsLong(); tester.runner().run(); assertTestLogEntries(id, Step.endTests, - new LogEntry(lastId + 1, 321, error, "Failure!"), - new LogEntry(lastId + 2, tester.clock().millis(), debug, "Tests failed.")); + new LogEntry(lastId + 1, Instant.ofEpochMilli(321), error, "Failure!"), + new LogEntry(lastId + 2, tester.clock().instant(), debug, "Tests failed.")); assertEquals(failed, tester.jobs().run(id).get().steps().get(Step.endTests)); } @Test public void testsFailIfTestsErr() { RunId id = tester.startSystemTestTests(); - tester.cloud().add(new LogEntry(0, 123, error, "Error!")); + tester.cloud().add(new LogEntry(0, Instant.ofEpochMilli(123), error, "Error!")); tester.cloud().set(TesterCloud.Status.ERROR); long lastId = tester.jobs().details(id).get().lastId().getAsLong(); tester.runner().run(); assertEquals(failed, tester.jobs().run(id).get().steps().get(Step.endTests)); assertTestLogEntries(id, Step.endTests, - new LogEntry(lastId + 1, 123, error, "Error!"), - new LogEntry(lastId + 2, tester.clock().millis(), info, "Tester failed running its tests!")); + new LogEntry(lastId + 1, Instant.ofEpochMilli(123), error, "Error!"), + new LogEntry(lastId + 2, tester.clock().instant(), info, "Tester failed running its tests!")); } @Test @@ -308,25 +311,25 @@ public class InternalStepRunnerTest { configObject.field("endpoints").field(JobType.systemTest.zone(system()).value()).traverse((ArrayTraverser) (__, endpoint) -> assertEquals(tester.routing().endpoints(new DeploymentId(appId, JobType.systemTest.zone(system()))).get(0).endpoint(), endpoint.asString())); long lastId = tester.jobs().details(id).get().lastId().getAsLong(); - tester.cloud().add(new LogEntry(0, 123, info, "Ready!")); + tester.cloud().add(new LogEntry(0, Instant.ofEpochMilli(123), info, "Ready!")); tester.runner().run(); assertTestLogEntries(id, Step.endTests, - new LogEntry(lastId + 1, 123, info, "Ready!")); + new LogEntry(lastId + 1, Instant.ofEpochMilli(123), info, "Ready!")); - tester.cloud().add(new LogEntry(1, 1234, info, "Steady!")); + tester.cloud().add(new LogEntry(1, Instant.ofEpochMilli(1234), info, "Steady!")); tester.runner().run(); assertTestLogEntries(id, Step.endTests, - new LogEntry(lastId + 1, 123, info, "Ready!"), - new LogEntry(lastId + 2, 1234, info, "Steady!")); + new LogEntry(lastId + 1, Instant.ofEpochMilli(123), info, "Ready!"), + new LogEntry(lastId + 2, Instant.ofEpochMilli(1234), info, "Steady!")); - tester.cloud().add(new LogEntry(12, 12345, info, "Success!")); + tester.cloud().add(new LogEntry(12, Instant.ofEpochMilli(12345), info, "Success!")); tester.cloud().set(TesterCloud.Status.SUCCESS); tester.runner().run(); assertTestLogEntries(id, Step.endTests, - new LogEntry(lastId + 1, 123, info, "Ready!"), - new LogEntry(lastId + 2, 1234, info, "Steady!"), - new LogEntry(lastId + 3, 12345, info, "Success!"), - new LogEntry(lastId + 4, tester.clock().millis(), debug, "Tests completed successfully.")); + new LogEntry(lastId + 1, Instant.ofEpochMilli(123), info, "Ready!"), + new LogEntry(lastId + 2, Instant.ofEpochMilli(1234), info, "Steady!"), + new LogEntry(lastId + 3, Instant.ofEpochMilli(12345), info, "Success!"), + new LogEntry(lastId + 4, tester.clock().instant(), debug, "Tests completed successfully.")); assertEquals(succeeded, tester.jobs().run(id).get().steps().get(Step.endTests)); } @@ -391,19 +394,16 @@ public class InternalStepRunnerTest { tester.runner().run(); assertEquals(failed, tester.jobs().run(id).get().steps().get(Step.endTests)); assertTestLogEntries(id, Step.copyVespaLogs, - new LogEntry(lastId + 2, 1554970337084L, info, - "17480180-v6-3.ostk.bm2.prod.ne1.yahoo.com\tcontainer\tContainer.com.yahoo.container.jdisc.ConfiguredApplication\n" + - "Switching to the latest deployed set of configurations and components. Application switch number: 2"), - new LogEntry(lastId + 3, 1554970337935L, info, + new LogEntry(lastId + 2, Instant.EPOCH.plus(3554970337935104L, ChronoUnit.MICROS), info, "17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\tcontainer\tstdout\n" + "ERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)"), - new LogEntry(lastId + 4, 1554970337947L, info, + new LogEntry(lastId + 3, Instant.EPOCH.plus(3554970337947777L, ChronoUnit.MICROS), info, "17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\tcontainer\tstdout\n" + "ERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)"), - new LogEntry(lastId + 5, 1554970337947L, info, + new LogEntry(lastId + 4, Instant.EPOCH.plus(3554970337947820L, ChronoUnit.MICROS), info, "17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\tcontainer\tstdout\n" + "ERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)"), - new LogEntry(lastId + 6, 1554970337947L, warning, + new LogEntry(lastId + 5, Instant.EPOCH.plus(3554970337947845L, ChronoUnit.MICROS), warning, "17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\tcontainer\tstderr\n" + "java.lang.NullPointerException\n\tat org.apache.felix.framework.BundleRevisionImpl.calculateContentPath(BundleRevisionImpl.java:438)\n\tat org.apache.felix.framework.BundleRevisionImpl.initializeContentPath(BundleRevisionImpl.java:371)")); } @@ -424,14 +424,14 @@ public class InternalStepRunnerTest { } private void assertTestLogEntries(RunId id, Step step, LogEntry... entries) { - assertEquals(List.of(entries), tester.jobs().details(id).get().get(step)); + assertEquals(ImmutableList.copyOf(entries), tester.jobs().details(id).get().get(step)); } - private static final String vespaLog = "1554970337.084804\t17480180-v6-3.ostk.bm2.prod.ne1.yahoo.com\t5549/832\tcontainer\tContainer.com.yahoo.container.jdisc.ConfiguredApplication\tinfo\tSwitching to the latest deployed set of configurations and components. Application switch number: 2\n" + - "1554970337.935104\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstdout\tinfo\tERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)\n" + - "1554970337.947777\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstdout\tinfo\tERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)\n" + - "1554970337.947820\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstdout\tinfo\tERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)\n" + - "1554970337.947844\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstderr\twarning\tjava.lang.NullPointerException\\n\\tat org.apache.felix.framework.BundleRevisionImpl.calculateContentPath(BundleRevisionImpl.java:438)\\n\\tat org.apache.felix.framework.BundleRevisionImpl.initializeContentPath(BundleRevisionImpl.java:371)"; + private static final String vespaLog = "-1554970337.084804\t17480180-v6-3.ostk.bm2.prod.ne1.yahoo.com\t5549/832\tcontainer\tContainer.com.yahoo.container.jdisc.ConfiguredApplication\tinfo\tSwitching to the latest deployed set of configurations and components. Application switch number: 2\n" + + "3554970337.935104\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstdout\tinfo\tERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)\n" + + "3554970337.947777\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstdout\tinfo\tERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)\n" + + "3554970337.947820\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstdout\tinfo\tERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)\n" + + "3554970337.947845\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstderr\twarning\tjava.lang.NullPointerException\\n\\tat org.apache.felix.framework.BundleRevisionImpl.calculateContentPath(BundleRevisionImpl.java:438)\\n\\tat org.apache.felix.framework.BundleRevisionImpl.initializeContentPath(BundleRevisionImpl.java:371)"; @Test public void generates_correct_services_xml_test() { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStoreTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStoreTest.java index a6022d259be..394f884f20f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStoreTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStoreTest.java @@ -11,6 +11,7 @@ import com.yahoo.vespa.hosted.controller.deployment.RunLog; import com.yahoo.vespa.hosted.controller.deployment.Step; import org.junit.Test; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -32,7 +33,7 @@ public class BufferedLogStoreTest { byte[] manyBytes = new byte[BufferedLogStore.chunkSize / 2 + 1]; // One fits, and two (over-)fills. Arrays.fill(manyBytes, (byte) 'O'); - LogEntry entry = new LogEntry(0, 123, LogEntry.Type.warning, new String(manyBytes)); + LogEntry entry = new LogEntry(0, Instant.ofEpochMilli(123), LogEntry.Type.warning, new String(manyBytes)); // Log entries are re-sequenced by the log store, by enumeration. LogEntry entry0 = new LogEntry(0, entry.at(), entry.type(), entry.message()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializerTest.java index a53a026eff6..e8029e0bdbd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializerTest.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -33,10 +34,10 @@ public class LogSerializerTest { byte[] logJson = Files.readAllBytes(logsFile); - LogEntry first = new LogEntry(0, 0, LogEntry.Type.info, "First"); - LogEntry second = new LogEntry(1, 0, LogEntry.Type.info, "Second"); - LogEntry third = new LogEntry(2, 1000, LogEntry.Type.debug, "Third"); - LogEntry fourth = new LogEntry(3, 2000, LogEntry.Type.warning, "Fourth"); + LogEntry first = new LogEntry(0, Instant.ofEpochMilli(0), LogEntry.Type.info, "First"); + LogEntry second = new LogEntry(1, Instant.ofEpochMilli(0), LogEntry.Type.info, "Second"); + LogEntry third = new LogEntry(2, Instant.ofEpochMilli(1000), LogEntry.Type.debug, "Third"); + LogEntry fourth = new LogEntry(3, Instant.ofEpochMilli(2000), LogEntry.Type.warning, "Fourth"); Map<Step, List<LogEntry>> expected = new HashMap<>(); expected.put(deployReal, new ArrayList<>()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/testdata/run-status.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/testdata/run-status.json index e112493cb94..535c87d9a7a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/testdata/run-status.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/testdata/run-status.json @@ -6,6 +6,7 @@ "start": 1196676930000, "status": "running", "lastTestRecord": 3, + "lastVespaLogTimestamp": 1196676930000432, "testerCertificate": "-----BEGIN CERTIFICATE-----\nMIIBEzCBu6ADAgECAgEBMAoGCCqGSM49BAMEMBQxEjAQBgNVBAMTCW15c2Vydmlj\nZTAeFw0xOTA5MDYwNzM3MDZaFw0xOTA5MDcwNzM3MDZaMBQxEjAQBgNVBAMTCW15\nc2VydmljZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABM0JhD8fV2DlAkjQOGX3\nY50ryMBr3g2+v/uFiRoxJ1muuSOWYrW7HCQIGuzc04fa0QwtaX/voAZKCV51t6jF\n0fwwCgYIKoZIzj0EAwQDRwAwRAIgVbQ3Co1H4X0gmRrtXSyTU0HgBQu9PXHMmX20\n5MyyPSoCIBltOcmaPfdN03L3zqbqZ6PgUBWsvAHgiBzL3hrtJ+iy\n-----END CERTIFICATE-----", "steps": { "deployInitialReal": "unfinished", diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1-log-first-part.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1-log-first-part.json index cce8fe196a7..5cd1afa3fb9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1-log-first-part.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1-log-first-part.json @@ -41,7 +41,7 @@ { "at": 0, "type": "debug", - "message": " host-tenant:application:default-dev.us-east-1: container on port 43 has 1" + "message": " host-tenant:application:default-dev.us-east-1: container on port 43 has config generation 1" }, { "at": 0, @@ -58,5 +58,6 @@ ] }, "active": true, - "lastId": 9 + "lastId": 9, + "status": "running" } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1-log-second-part.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1-log-second-part.json index 31e25739c4d..57b3f382c76 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1-log-second-part.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1-log-second-part.json @@ -49,5 +49,6 @@ ] }, "active": false, - "lastId": 18 + "lastId": 18, + "status": "success" } |