diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-23 14:57:35 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-23 14:57:35 +0200 |
commit | 21e95c8db5ae40ab1e93070b3490629f57450f7c (patch) | |
tree | 60abbd1b289c8490b87caaf55328ea775089df06 /controller-server | |
parent | 366fb4304f150b2aec83ab7fa5a673f3876696d3 (diff) |
Get sub-list of LogEntry from TesterCloud
Diffstat (limited to 'controller-server')
14 files changed, 65 insertions, 108 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index 799077028e0..40696909eec 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -337,6 +337,9 @@ public class InternalStepRunner implements StepRunner { URI testerEndpoint = testerEndpoint(id) .orElseThrow(() -> new NoSuchElementException("Endpoint for tester vanished again before tests were complete!")); + JobController jobs = controller.jobController(); + jobs.logTestEntries(id, testerCloud.getLog(testerEndpoint, jobs.run(id).get().lastTestLogEntry())); + RunStatus status; switch (testerCloud.getStatus(testerEndpoint)) { case NOT_STARTED: @@ -355,7 +358,6 @@ public class InternalStepRunner implements StepRunner { default: throw new AssertionError("Unknown status!"); } - logger.log(new String(testerCloud.getLogs(testerEndpoint))); // TODO jvenstad: Replace with something less hopeless! return Optional.of(status); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java index 6c95c4ed8cd..4759c03e9bb 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -6,6 +6,7 @@ import com.yahoo.vespa.curator.Lock; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.api.integration.RunDataStore; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NoInstanceException; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; @@ -23,7 +24,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeoutException; @@ -101,7 +101,7 @@ public class JobController { } /** Stores the given test log records, and records the id of the last of these, for continuation. */ - public void logTestRecords(RunId id, List<LogEntry> entries) { + public void logTestEntries(RunId id, List<LogEntry> entries) { if (entries.isEmpty()) return; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/LogEntry.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/LogEntry.java deleted file mode 100644 index fed5a9b84b1..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/LogEntry.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.yahoo.vespa.hosted.controller.deployment; - -import com.yahoo.log.LogLevel; - -import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.LogRecord; - -import static java.util.Objects.requireNonNull; - -/** Immutable, simple log entries. */ -public class LogEntry { - - private final long id; - private final long at; - private final Level level; - private final String message; - - public LogEntry(long id, long at, Level level, String message) { - if (id < 0) - throw new IllegalArgumentException("Id must be non-negative, but was " + id + "."); - - this.id = id; - this.at = at; - this.level = LogLevel.getVespaLogLevel(requireNonNull(level)); - this.message = requireNonNull(message); - } - - public static LogEntry of(LogRecord record) { - return new LogEntry(record.getSequenceNumber(), record.getMillis(), record.getLevel(), record.getMessage()); - } - - public long id() { - return id; - } - - public long at() { - return at; - } - - public Level level() { - return level; - } - - public String message() { - return message; - } - - @Override - public String toString() { - return "LogEntry{" + - "id=" + id + - ", at=" + at + - ", level=" + level + - ", message='" + message + '\'' + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof LogEntry)) return false; - LogEntry entry = (LogEntry) o; - return id == entry.id && - at == entry.at && - Objects.equals(level, entry.level) && - Objects.equals(message, entry.message); - } - - @Override - public int hashCode() { - return Objects.hash(id, at, level, message); - } - -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java index 9f70792fc53..6a0da68f3c9 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java @@ -125,7 +125,7 @@ public class Run { } /** Returns the sequence id of the last test record received from the tester, for the test logs of this run. */ - public long lastTestRecord() { + public long lastTestLogEntry() { return lastTestRecord; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.java index 9b9a32c6e65..d310ccc8915 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunLog.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import java.util.Collections; import java.util.List; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStore.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStore.java index b70c1283862..dce3f52bd35 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStore.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStore.java @@ -4,7 +4,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.hosted.controller.api.integration.RunDataStore; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId; -import com.yahoo.vespa.hosted.controller.deployment.LogEntry; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.deployment.RunLog; import com.yahoo.vespa.hosted.controller.deployment.Step; @@ -13,9 +13,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; -import java.util.stream.LongStream; /** * Stores logs in bite-sized chunks using a {@link CuratorDb}, and flushes to a diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java index 0117ae9ca40..337204a31af 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java @@ -7,7 +7,7 @@ import com.yahoo.slime.Inspector; import com.yahoo.slime.ObjectTraverser; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; -import com.yahoo.vespa.hosted.controller.deployment.LogEntry; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.deployment.Step; import java.io.IOException; @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.LogRecord; import java.util.stream.Collectors; /** diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/RunSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/RunSerializer.java index 47a690459a8..b4da0a6b033 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/RunSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/RunSerializer.java @@ -140,7 +140,7 @@ class RunSerializer { runObject.setLong(startField, run.start().toEpochMilli()); run.end().ifPresent(end -> runObject.setLong(endField, end.toEpochMilli())); runObject.setString(statusField, valueOf(run.status())); - runObject.setLong(lastTestRecordField, run.lastTestRecord()); + runObject.setLong(lastTestRecordField, run.lastTestLogEntry()); Cursor stepsObject = runObject.setObject(stepsField); run.steps().forEach((step, status) -> stepsObject.setString(valueOf(step), valueOf(status))); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java index 3ed4163a503..68ba8ab83f3 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java @@ -10,7 +10,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId; import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.SourceRevision; import com.yahoo.vespa.hosted.controller.deployment.JobController; -import com.yahoo.vespa.hosted.controller.deployment.LogEntry; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.deployment.RunLog; import com.yahoo.vespa.hosted.controller.deployment.Run; import com.yahoo.vespa.hosted.controller.deployment.Step; 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 42d4beedb0b..2c3f44ffebe 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 @@ -15,6 +15,7 @@ import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbi import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RestartAction; import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ServiceInfo; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud; @@ -39,18 +40,17 @@ import java.nio.file.Paths; import java.time.Duration; import java.util.Arrays; import java.util.Collections; -import java.util.List; import java.util.Optional; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static com.yahoo.log.LogLevel.DEBUG; +import static com.yahoo.log.LogLevel.ERROR; import static com.yahoo.vespa.hosted.controller.deployment.InternalStepRunner.testerOf; import static com.yahoo.vespa.hosted.controller.deployment.RunStatus.aborted; import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.failed; import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.succeeded; import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.unfinished; +import static java.util.logging.Level.INFO; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -212,7 +212,7 @@ public class InternalStepRunnerTest { assertEquals(Step.Status.succeeded, jobs.active(run.id()).get().steps().get(Step.startTests)); assertEquals(unfinished, jobs.active(run.id()).get().steps().get(Step.endTests)); - cloud.set("Awesome!".getBytes(), TesterCloud.Status.SUCCESS); + cloud.set(TesterCloud.Status.SUCCESS); runner.run(); assertTrue(jobs.run(run.id()).get().hasEnded()); assertFalse(jobs.run(run.id()).get().hasFailed()); @@ -321,9 +321,17 @@ public class InternalStepRunnerTest { } @Test - public void testsFailIfEndpointsAreGone() { + public void testsFailIfTesterEndpointsVanish() { RunId id = startSystemTestTests(); - cloud.set(new byte[0], TesterCloud.Status.NOT_STARTED); + routing.removeEndpoints(new DeploymentId(testerOf(appId), JobType.systemTest.zone(tester.controller().system()))); + runner.run(); + assertEquals(failed, jobs.run(id).get().steps().get(Step.endTests)); + } + + @Test + public void testsFailIfTesterRestarts() { + RunId id = startSystemTestTests(); + cloud.set(TesterCloud.Status.NOT_STARTED); runner.run(); assertEquals(failed, jobs.run(id).get().steps().get(Step.endTests)); } @@ -331,19 +339,29 @@ public class InternalStepRunnerTest { @Test public void testsFailIfTestsFailRemotely() { RunId id = startSystemTestTests(); - cloud.set("Failure!".getBytes(), TesterCloud.Status.FAILURE); + cloud.add(new LogEntry(123, 321, ERROR, "Failure!")); + cloud.set(TesterCloud.Status.FAILURE); + + long lastId = jobs.details(id).get().lastId().getAsLong(); runner.run(); + assertTestLogEntries(id, Step.endTests, + new LogEntry(lastId + 1, 321, ERROR, "Failure!"), + new LogEntry(lastId + 2, tester.clock().millis(), DEBUG, "Tests failed.")); assertEquals(failed, jobs.run(id).get().steps().get(Step.endTests)); - assertLogMessages(id, Step.endTests, "Tests failed.", "Failure!"); } @Test public void testsFailIfTestsErr() { RunId id = startSystemTestTests(); - cloud.set("Error!".getBytes(), TesterCloud.Status.ERROR); + cloud.add(new LogEntry(0, 123, ERROR, "Error!")); + cloud.set(TesterCloud.Status.ERROR); + + long lastId = jobs.details(id).get().lastId().getAsLong(); runner.run(); assertEquals(failed, jobs.run(id).get().steps().get(Step.endTests)); - assertLogMessages(id, Step.endTests, "Tester failed running its tests!", "Error!"); + assertTestLogEntries(id, Step.endTests, + new LogEntry(lastId + 1, 123, ERROR, "Error!"), + new LogEntry(lastId + 2, tester.clock().millis(), INFO, "Tester failed running its tests!")); } @Test @@ -362,17 +380,31 @@ public class InternalStepRunnerTest { configObject.field("endpoints").field(JobType.systemTest.zone(tester.controller().system()).value()).traverse((ArrayTraverser) (__, endpoint) -> assertEquals(routing.endpoints(new DeploymentId(appId, JobType.systemTest.zone(tester.controller().system()))).get(0).getEndpoint(), endpoint.asString())); - cloud.set("Success!".getBytes(), TesterCloud.Status.SUCCESS); + long lastId = jobs.details(id).get().lastId().getAsLong(); + cloud.add(new LogEntry(0, 123, INFO, "Ready!")); + runner.run(); + assertTestLogEntries(id, Step.endTests, + new LogEntry(lastId + 1, 123, INFO, "Ready!")); + + cloud.add(new LogEntry(1, 1234, INFO, "Steady!")); + runner.run(); + assertTestLogEntries(id, Step.endTests, + new LogEntry(lastId + 1, 123, INFO, "Ready!"), + new LogEntry(lastId + 2, 1234, INFO, "Steady!")); + + cloud.add(new LogEntry(12, 12345, INFO, "Success!")); + cloud.set(TesterCloud.Status.SUCCESS); 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.")); assertEquals(succeeded, jobs.run(id).get().steps().get(Step.endTests)); - assertLogMessages(id, Step.endTests, "Tests completed successfully.", "Success!"); } - private void assertLogMessages(RunId id, Step step, String... messages) { - assertEquals(Arrays.asList(messages), - jobs.details(id).get().get(step).get().stream() - .map(LogEntry::message) - .collect(Collectors.toList())); + private void assertTestLogEntries(RunId id, Step step, LogEntry... entries) { + assertEquals(Arrays.asList(entries), jobs.details(id).get().get(step).get()); } private RunId startSystemTestTests() { 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 35a6ab2aaec..6147c50120e 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 @@ -5,7 +5,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.RunDataStore; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockRunDataStore; -import com.yahoo.vespa.hosted.controller.deployment.LogEntry; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.deployment.RunLog; import com.yahoo.vespa.hosted.controller.deployment.Step; import org.junit.Test; 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 982d32bdda4..64aaec97b09 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 @@ -1,7 +1,7 @@ package com.yahoo.vespa.hosted.controller.persistence; import com.yahoo.log.LogLevel; -import com.yahoo.vespa.hosted.controller.deployment.LogEntry; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.deployment.Step; import org.junit.Test; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/RunSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/RunSerializerTest.java index a1fa4c1cd29..82aee3b3550 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/RunSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/RunSerializerTest.java @@ -69,7 +69,7 @@ public class RunSerializerTest { assertEquals(start, run.start()); assertFalse(run.hasEnded()); assertEquals(running, run.status()); - assertEquals(3, run.lastTestRecord()); + assertEquals(3, run.lastTestLogEntry()); assertEquals(new Version(1, 2, 3), run.versions().targetPlatform()); assertEquals(ApplicationVersion.from(new SourceRevision("git@github.com:user/repo.git", "master", @@ -106,7 +106,7 @@ public class RunSerializerTest { assertEquals(run.start(), phoenix.start()); assertEquals(run.end(), phoenix.end()); assertEquals(run.status(), phoenix.status()); - assertEquals(run.lastTestRecord(), phoenix.lastTestRecord()); + assertEquals(run.lastTestLogEntry(), phoenix.lastTestLogEntry()); assertEquals(run.versions(), phoenix.versions()); assertEquals(run.steps(), phoenix.steps()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelperTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelperTest.java index fd749d07491..bfa4a694208 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelperTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelperTest.java @@ -11,7 +11,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockRunDataStore; import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.SourceRevision; import com.yahoo.vespa.hosted.controller.deployment.JobController; -import com.yahoo.vespa.hosted.controller.deployment.LogEntry; +import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.deployment.Run; import com.yahoo.vespa.hosted.controller.deployment.RunStatus; import com.yahoo.vespa.hosted.controller.deployment.Step; |