summaryrefslogtreecommitdiffstats
path: root/vespa-osgi-testrunner
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2024-01-11 09:46:15 +0100
committerjonmv <venstad@gmail.com>2024-01-11 09:46:15 +0100
commit341528ac99a03df8d3863f52150b5d2944e1997b (patch)
tree720032e77d7ab598e816dfe5d544c3a0dd0d5f1f /vespa-osgi-testrunner
parentdf94fea49a0dc848cc2c7d86772ef4a2a83386ee (diff)
Revert "Update tenant test runner JUnit version as well"
This reverts commit df94fea49a0dc848cc2c7d86772ef4a2a83386ee.
Diffstat (limited to 'vespa-osgi-testrunner')
-rw-r--r--vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java25
-rw-r--r--vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/AggregateTestRunnerTest.java2
-rw-r--r--vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/JunitRunnerTest.java2
-rw-r--r--vespa-osgi-testrunner/src/test/resources/output.json52
-rw-r--r--vespa-osgi-testrunner/src/test/resources/report.json8
5 files changed, 40 insertions, 49 deletions
diff --git a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java
index b585739b950..f90f910ee7e 100644
--- a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java
+++ b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.testrunner;
import ai.vespa.hosted.cd.InconclusiveTestException;
import com.yahoo.collections.Comparables;
import com.yahoo.vespa.testrunner.TestRunner.Suite;
-import org.junit.platform.commons.util.ReflectionUtils;
import org.junit.platform.engine.UniqueId;
import org.junit.platform.engine.UniqueId.Segment;
import org.junit.platform.launcher.TestIdentifier;
@@ -31,8 +30,6 @@ import static java.util.Arrays.copyOf;
*/
public class TestReport {
- private static final List<String> testFrameworkRootClasses = List.of(ReflectionUtils.class.getName(), JunitRunner.class.getName());
-
private final Object monitor = new Object();
private final Set<TestIdentifier> complete = new HashSet<>();
private final Clock clock;
@@ -141,7 +138,7 @@ public class TestReport {
void log(LogRecord record) {
synchronized (monitor) {
- if (record.getThrown() != null) trimStackTraces(record.getThrown());
+ if (record.getThrown() != null) trimStackTraces(record.getThrown(), JunitRunner.class.getName());
if ( ! (current.children.peekLast() instanceof OutputNode))
current.children.add(new OutputNode(current));
@@ -280,9 +277,9 @@ public class TestReport {
private final Throwable thrown;
private final Suite suite;
- FailureNode(NamedNode parent, Instant now, Throwable thrown, Suite suite) {
+ public FailureNode(NamedNode parent, Instant now, Throwable thrown, Suite suite) {
super(parent, null, thrown.toString(), now);
- trimStackTraces(thrown);
+ trimStackTraces(thrown, JunitRunner.class.getName());
this.thrown = thrown;
this.suite = suite;
@@ -333,7 +330,7 @@ public class TestReport {
* This is based on the assumption that the relevant stack is anything above the first native
* reflection invocation, above any frame in the given root class.
*/
- static void trimStackTraces(Throwable thrown) {
+ static void trimStackTraces(Throwable thrown, String testFrameworkRootClass) {
if (thrown == null)
return;
@@ -343,8 +340,8 @@ public class TestReport {
int cutoff = 0;
boolean rootedInTestFramework = false;
while (++i < stack.length) {
- rootedInTestFramework |= testFrameworkRootClasses.contains(stack[i].getClassName());
- if (firstReflectFrame == -1 && (stack[i].getClassName().startsWith("jdk.internal.reflect.") || stack[i].getClassName().startsWith("java.lang.reflect.")))
+ rootedInTestFramework |= testFrameworkRootClass.equals(stack[i].getClassName());
+ if (firstReflectFrame == -1 && stack[i].getClassName().startsWith("jdk.internal.reflect."))
firstReflectFrame = i; // jdk.internal.reflect class invokes the first user test frame, on both jdk 17 and 21.
if (rootedInTestFramework && firstReflectFrame > 0) {
cutoff = firstReflectFrame;
@@ -356,18 +353,12 @@ public class TestReport {
break;
}
}
- if (cutoff == 0) {
- while (--i >= 0 && ( stack[i].isNativeMethod()
- || stack[i].getClassName().startsWith("java.lang.")
- || stack[i].getClassName().startsWith("java.util.")));
- cutoff = i + 1;
- }
thrown.setStackTrace(copyOf(stack, cutoff));
for (Throwable suppressed : thrown.getSuppressed())
- trimStackTraces(suppressed);
+ trimStackTraces(suppressed, testFrameworkRootClass);
- trimStackTraces(thrown.getCause());
+ trimStackTraces(thrown.getCause(), testFrameworkRootClass);
}
private static String toString(Suite suite) {
diff --git a/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/AggregateTestRunnerTest.java b/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/AggregateTestRunnerTest.java
index 9933e25b277..c54fb6abf37 100644
--- a/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/AggregateTestRunnerTest.java
+++ b/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/AggregateTestRunnerTest.java
@@ -163,7 +163,7 @@ class AggregateTestRunnerTest {
}
}
catch (Exception e) {
- TestReport.trimStackTraces(e);
+ TestReport.trimStackTraces(e, "org.junit.platform.commons.util.ReflectionUtils");
assertEquals("""
java.lang.RuntimeException: java.lang.RuntimeException: inner
\tat com.yahoo.vespa.testrunner.AggregateTestRunnerTest.testStackTrimming(AggregateTestRunnerTest.java:162)
diff --git a/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/JunitRunnerTest.java b/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/JunitRunnerTest.java
index fcf4403e3ab..bffcc75f160 100644
--- a/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/JunitRunnerTest.java
+++ b/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/JunitRunnerTest.java
@@ -135,7 +135,7 @@ class JunitRunnerTest {
}
private TestIdentifier getTestIdentifier(TestDescriptor testDescriptor) {
- return plan.getTestIdentifier(testDescriptor.getUniqueId());
+ return plan.getTestIdentifier(testDescriptor.getUniqueId().toString());
}
@Override public void dynamicTestRegistered(TestDescriptor testDescriptor) {
diff --git a/vespa-osgi-testrunner/src/test/resources/output.json b/vespa-osgi-testrunner/src/test/resources/output.json
index 37c4ef094f9..79e9c544149 100644
--- a/vespa-osgi-testrunner/src/test/resources/output.json
+++ b/vespa-osgi-testrunner/src/test/resources/output.json
@@ -1,136 +1,136 @@
{
"logRecords": [
{
- "id": 2,
+ "id": 18,
"at": 0,
"type": "info",
"message": "spam"
},
{
- "id": 5,
+ "id": 21,
"at": 0,
"type": "info",
"message": "spam"
},
{
- "id": 6,
+ "id": 22,
"at": 0,
"type": "error",
"message": "java.lang.NoClassDefFoundError\n\tat com.yahoo.vespa.test.samples.SampleTest.error(SampleTest.java:88)\n"
},
{
- "id": 9,
+ "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": 11,
+ "id": 27,
"at": 0,
"type": "error",
- "message": "org.opentest4j.AssertionFailedError: baz ==> expected: <foo> but was: <bar>\n\tat org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)\n\tat org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)\n\tat org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)\n\tat org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)\n\tat org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1156)\n\tat com.yahoo.vespa.test.samples.SampleTest.failing(SampleTest.java:82)\n"
+ "message": "org.opentest4j.AssertionFailedError: baz ==> expected: <foo> but was: <bar>\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:82)\n"
},
{
- "id": 15,
+ "id": 31,
"at": 0,
"type": "info",
"message": "spam"
},
{
- "id": 16,
+ "id": 32,
"at": 0,
"type": "info",
"message": "I'm here with Erwin today; Erwin, what can you tell us about your cat?"
},
{
- "id": 17,
+ "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:94)\n"
},
{
- "id": 20,
+ "id": 36,
"at": 0,
"type": "info",
"message": "spam"
},
{
- "id": 21,
+ "id": 37,
"at": 0,
"type": "info",
"message": "<body />"
},
{
- "id": 22,
+ "id": 38,
"at": 0,
"type": "info",
"message": "Very informative: \"\\n\": \n"
},
{
- "id": 23,
+ "id": 39,
"at": 0,
"type": "warning",
"message": "Oh no\njava.lang.IllegalArgumentException: error\n\tat com.yahoo.vespa.test.samples.SampleTest.successful(SampleTest.java:76)\nCaused by: java.lang.RuntimeException: wrapped\n\t... 1 more\n"
},
{
- "id": 27,
+ "id": 43,
"at": 0,
"type": "info",
"message": "spam"
},
{
- "id": 30,
+ "id": 46,
"at": 0,
"type": "info",
"message": "Catch me if you can!"
},
{
- "id": 34,
+ "id": 50,
"at": 0,
"type": "error",
- "message": "org.opentest4j.AssertionFailedError: no charm\n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:38)\n\tat org.junit.jupiter.api.Assertions.fail(Assertions.java:138)\n\tat com.yahoo.vespa.test.samples.SampleTest$Inner.lambda$others$1(SampleTest.java:106)\n"
+ "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:106)\n"
},
{
- "id": 38,
+ "id": 54,
"at": 0,
"type": "info",
"message": "spam"
},
{
- "id": 67,
+ "id": 2,
"at": 0,
"type": "error",
- "message": "org.opentest4j.AssertionFailedError\n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:34)\n\tat org.junit.jupiter.api.Assertions.fail(Assertions.java:119)\n\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.test(FailingTestAndBothAftersTest.java:20)\n\tSuppressed: java.lang.RuntimeException\n\t\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.moreFail(FailingTestAndBothAftersTest.java:17)\n"
+ "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:20)\n\tSuppressed: java.lang.RuntimeException\n\t\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.moreFail(FailingTestAndBothAftersTest.java:17)\n"
},
{
- "id": 69,
+ "id": 4,
"at": 0,
"type": "error",
"message": "java.lang.RuntimeException\n\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.fail(FailingTestAndBothAftersTest.java:14)\n"
},
{
- "id": 72,
+ "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": 76,
+ "id": 11,
"at": 0,
"type": "error",
"message": "java.lang.NullPointerException\n\tat com.yahoo.vespa.test.samples.FailingExtensionTest$FailingExtension.<init>(FailingExtensionTest.java:20)\n"
},
{
- "id": 80,
+ "id": 15,
"at": 12000,
"type": "error",
- "message": "java.lang.ClassNotFoundException: School's out all summer!\n\tat com.yahoo.vespa.testrunner.TestRunnerHandlerTest.setup(TestRunnerHandlerTest.java:57)\n"
+ "message": "java.lang.ClassNotFoundException: School's out all summer!\n"
}
]
}
diff --git a/vespa-osgi-testrunner/src/test/resources/report.json b/vespa-osgi-testrunner/src/test/resources/report.json
index 0252bfe565c..cf4868877a4 100644
--- a/vespa-osgi-testrunner/src/test/resources/report.json
+++ b/vespa-osgi-testrunner/src/test/resources/report.json
@@ -110,7 +110,7 @@
"type": "output",
"children": [
{
- "message": "org.opentest4j.AssertionFailedError: baz ==> expected: <foo> but was: <bar>\n\tat org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)\n\tat org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)\n\tat org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)\n\tat org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)\n\tat org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1156)\n\tat com.yahoo.vespa.test.samples.SampleTest.failing(SampleTest.java:82)\n",
+ "message": "org.opentest4j.AssertionFailedError: baz ==> expected: <foo> but was: <bar>\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:82)\n",
"at": 0,
"level": "error"
}
@@ -265,7 +265,7 @@
"type": "output",
"children": [
{
- "message": "org.opentest4j.AssertionFailedError: no charm\n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:38)\n\tat org.junit.jupiter.api.Assertions.fail(Assertions.java:138)\n\tat com.yahoo.vespa.test.samples.SampleTest$Inner.lambda$others$1(SampleTest.java:106)\n",
+ "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:106)\n",
"at": 0,
"level": "error"
}
@@ -350,7 +350,7 @@
"type": "output",
"children": [
{
- "message": "org.opentest4j.AssertionFailedError\n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:34)\n\tat org.junit.jupiter.api.Assertions.fail(Assertions.java:119)\n\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.test(FailingTestAndBothAftersTest.java:20)\n\tSuppressed: java.lang.RuntimeException\n\t\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.moreFail(FailingTestAndBothAftersTest.java:17)\n",
+ "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:20)\n\tSuppressed: java.lang.RuntimeException\n\t\tat com.yahoo.vespa.test.samples.FailingTestAndBothAftersTest.moreFail(FailingTestAndBothAftersTest.java:17)\n",
"at": 0,
"level": "error"
}
@@ -473,7 +473,7 @@
"type": "output",
"children": [
{
- "message": "java.lang.ClassNotFoundException: School's out all summer!\n\tat com.yahoo.vespa.testrunner.TestRunnerHandlerTest.setup(TestRunnerHandlerTest.java:57)\n",
+ "message": "java.lang.ClassNotFoundException: School's out all summer!\n",
"at": 12000,
"level": "error"
}