From 6ccb111087c71347decae7d38f40f6d43f6a0c0c Mon Sep 17 00:00:00 2001 From: jonmv Date: Fri, 1 Jul 2022 17:39:27 +0200 Subject: More log output in test --- .../yahoo/vespa/testrunner/TestRunnerHandler.java | 4 +- .../src/test/resources/output.json | 80 ++++++++++++++++++---- 2 files changed, 69 insertions(+), 15 deletions(-) (limited to 'vespa-osgi-testrunner') diff --git a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestRunnerHandler.java b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestRunnerHandler.java index 19d7afc0a81..31dbd939991 100644 --- a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestRunnerHandler.java +++ b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestRunnerHandler.java @@ -128,11 +128,11 @@ public class TestRunnerHandler extends ThreadedHttpRequestHandler { recordObject.setLong("id", record.getSequenceNumber()); recordObject.setLong("at", record.getMillis()); recordObject.setString("type", typeOf(record.getLevel())); - String message = record.getMessage(); + String message = record.getMessage() == null ? "" : record.getMessage(); if (record.getThrown() != null) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); record.getThrown().printStackTrace(new PrintStream(buffer)); - message += "\n" + buffer; + message += (message.isEmpty() ? "" : "\n") + buffer; } recordObject.setString("message", message); }); diff --git a/vespa-osgi-testrunner/src/test/resources/output.json b/vespa-osgi-testrunner/src/test/resources/output.json index 04682fa9f31..847ae5800e9 100644 --- a/vespa-osgi-testrunner/src/test/resources/output.json +++ b/vespa-osgi-testrunner/src/test/resources/output.json @@ -1,82 +1,136 @@ { "logRecords": [ { - "id": 3, + "id": 18, "at": 0, "type": "info", "message": "spam" }, { - "id": 6, + "id": 21, "at": 0, "type": "info", "message": "spam" }, { - "id": 9, + "id": 22, + "at": 0, + "type": "error", + "message": "java.lang.NoClassDefFoundError\n\tat com.yahoo.vespa.test.samples.SampleTest.error(SampleTest.java:87)\n" + }, + { + "id": 25, "at": 0, "type": "info", "message": "spam" }, { - "id": 10, + "id": 26, "at": 0, "type": "info", "message": "I have a bad feeling about this" }, { - "id": 14, + "id": 27, + "at": 0, + "type": "error", + "message": "org.opentest4j.AssertionFailedError: baz ==> expected: but was: \n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)\n\tat org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:62)\n\tat org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)\n\tat org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1152)\n\tat com.yahoo.vespa.test.samples.SampleTest.failing(SampleTest.java:81)\n" + }, + { + "id": 31, "at": 0, "type": "info", "message": "spam" }, { - "id": 15, + "id": 32, "at": 0, "type": "info", "message": "I'm here with Erwin today; Erwin, what can you tell us about your cat?" }, { - "id": 18, + "id": 33, + "at": 0, + "type": "warning", + "message": "ai.vespa.hosted.cd.InconclusiveTestException: the cat is both dead _and_ alive\n\tat com.yahoo.vespa.test.samples.SampleTest.inconclusive(SampleTest.java:93)\n" + }, + { + "id": 36, "at": 0, "type": "info", "message": "spam" }, { - "id": 19, + "id": 37, "at": 0, "type": "info", "message": "" }, { - "id": 20, + "id": 38, "at": 0, "type": "info", "message": "Very informative" }, { - "id": 21, + "id": 39, "at": 0, "type": "warning", "message": "Oh no\njava.lang.IllegalArgumentException: error\n\tat com.yahoo.vespa.test.samples.SampleTest.successful(SampleTest.java:75)\nCaused by: java.lang.RuntimeException: wrapped\n\t... 1 more\n" }, { - "id": 25, + "id": 43, "at": 0, "type": "info", "message": "spam" }, { - "id": 28, + "id": 46, "at": 0, "type": "info", "message": "Catch me if you can!" }, { - "id": 35, + "id": 50, + "at": 0, + "type": "error", + "message": "org.opentest4j.AssertionFailedError: no charm\n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:39)\n\tat org.junit.jupiter.api.Assertions.fail(Assertions.java:134)\n\tat com.yahoo.vespa.test.samples.SampleTest$Inner.lambda$others$1(SampleTest.java:105)\n" + }, + { + "id": 54, "at": 0, "type": "info", "message": "spam" + }, + { + "id": 2, + "at": 0, + "type": "error", + "message": "org.opentest4j.AssertionFailedError\n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:35)\n\tat org.junit.jupiter.api.Assertions.fail(Assertions.java:115)\n\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.test(FailingTestAndBothAftersTest.java:19)\n\tSuppressed: java.lang.RuntimeException\n\t\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.moreFail(FailingTestAndBothAftersTest.java:16)\n" + }, + { + "id": 4, + "at": 0, + "type": "error", + "message": "java.lang.RuntimeException\n\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.fail(FailingTestAndBothAftersTest.java:13)\n" + }, + { + "id": 7, + "at": 0, + "type": "error", + "message": "org.junit.platform.commons.JUnitException: @BeforeAll method 'void com.yahoo.vespa.test.samples.WrongBeforeAllTest.wrong()' must be static unless the test class is annotated with @TestInstance(Lifecycle.PER_CLASS).\n" + }, + { + "id": 11, + "at": 0, + "type": "error", + "message": "java.lang.NullPointerException\n\tat com.yahoo.vespa.test.samples.FailingExtensionTest$FailingExtension.(FailingExtensionTest.java:19)\n" + }, + { + "id": 15, + "at": 12000, + "type": "error", + "message": "java.lang.ClassNotFoundException: School's out all summer!\n" } ] } -- cgit v1.2.3