summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2018-08-24 20:45:45 +0200
committerGitHub <noreply@github.com>2018-08-24 20:45:45 +0200
commitf17f5b9c41fb27f0c6ffa8e4ed5637f0e8c7d3aa (patch)
treec90a8dab53adfd6080d4ea9c2233626067570a54 /controller-api
parent1dfa9217af60397885df85370a903b25db81b892 (diff)
parentcb64da657691301a72dd12d1a074d06298a8e39c (diff)
Merge pull request #6661 from vespa-engine/jvenstad/testrunner-logging
Get sub-list of LogEntry from TesterCloud
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java71
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java7
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java20
3 files changed, 90 insertions, 8 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java
new file mode 100644
index 00000000000..026e9250cef
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java
@@ -0,0 +1,71 @@
+package com.yahoo.vespa.hosted.controller.api.integration;
+
+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 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-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java
index f1d07fc9097..f2dbcda54b6 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java
@@ -1,6 +1,9 @@
package com.yahoo.vespa.hosted.controller.api.integration.deployment;
+import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
+
import java.net.URI;
+import java.util.List;
/**
* Allows running some predefined tests -- typically remotely.
@@ -12,8 +15,8 @@ public interface TesterCloud {
/** Signals the tester to run its tests. */
void startTests(URI testerUrl, Suite suite, byte[] config);
- /** Returns the currently stored logs from the tester. */
- byte[] getLogs(URI testerUrl);
+ /** Returns the log entries from the tester with ids after the given threshold. */
+ List<LogEntry> getLog(URI testerUrl, long after);
/** Returns the current status of the tester. */
Status getStatus(URI testerUrl);
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
index ff3f168a978..176fa8ae683 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
@@ -1,16 +1,21 @@
package com.yahoo.vespa.hosted.controller.api.integration.stubs;
+import com.google.common.collect.ImmutableList;
+import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud;
import java.net.URI;
-import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud.Status.NOT_STARTED;
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud.Status.RUNNING;
public class MockTesterCloud implements TesterCloud {
- private byte[] logs = new byte[0];
+ private List<LogEntry> log = new ArrayList<>();
private Status status = NOT_STARTED;
private byte[] config;
private URI testerUrl;
@@ -23,8 +28,8 @@ public class MockTesterCloud implements TesterCloud {
}
@Override
- public byte[] getLogs(URI testerUrl) {
- return Arrays.copyOf(logs, logs.length);
+ public List<LogEntry> getLog(URI testerUrl, long after) {
+ return log.stream().filter(entry -> entry.id() > after).collect(Collectors.toList());
}
@Override
@@ -32,8 +37,11 @@ public class MockTesterCloud implements TesterCloud {
return status;
}
- public void set(byte[] logs, Status status) {
- this.logs = Arrays.copyOf(logs, logs.length);
+ public void add(LogEntry entry) {
+ log.add(entry);
+ }
+
+ public void set(Status status) {
this.status = status;
}