diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-12-03 08:33:12 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-12-03 08:33:12 +0100 |
commit | 7cc3980cf2b38da62f06444e2785cc752eacf75c (patch) | |
tree | 62d67a3670cae14745265062a1b4e1d9d60b08cd /vespa-testrunner-components | |
parent | 852b5c8d895a6bf3f0a3490aa512d0fa6b5782c0 (diff) |
Remove unused log file generation
Diffstat (limited to 'vespa-testrunner-components')
2 files changed, 8 insertions, 23 deletions
diff --git a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java index 6f12535c317..83cfd0030a0 100644 --- a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java +++ b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java @@ -9,7 +9,6 @@ import org.fusesource.jansi.HtmlAnsiOutputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; @@ -57,7 +56,6 @@ public class TestRunner implements com.yahoo.vespa.testrunner.TestRunner { private final Path artifactsPath; private final Path testPath; - private final Path logFile; private final Path configFile; private final Path settingsFile; private final Function<TestProfile, ProcessBuilder> testBuilder; @@ -69,16 +67,14 @@ public class TestRunner implements com.yahoo.vespa.testrunner.TestRunner { public TestRunner(TestRunnerConfig config) { this(config.artifactsPath(), vespaHome.resolve("tmp/test"), - vespaHome.resolve("logs/vespa/maven.log"), vespaHome.resolve("tmp/config.json"), vespaHome.resolve("tmp/settings.xml"), profile -> mavenProcessFrom(profile, config)); } - TestRunner(Path artifactsPath, Path testPath, Path logFile, Path configFile, Path settingsFile, Function<TestProfile, ProcessBuilder> testBuilder) { + TestRunner(Path artifactsPath, Path testPath, Path configFile, Path settingsFile, Function<TestProfile, ProcessBuilder> testBuilder) { this.artifactsPath = artifactsPath; this.testPath = testPath; - this.logFile = logFile; this.configFile = configFile; this.settingsFile = settingsFile; this.testBuilder = testBuilder; @@ -154,9 +150,7 @@ public class TestRunner implements com.yahoo.vespa.testrunner.TestRunner { } boolean success; - // The AnsiOutputStream filters out ANSI characters, leaving the file contents pure. - try (PrintStream fileStream = new PrintStream(new AnsiOutputStream(new BufferedOutputStream(new FileOutputStream(logFile.toFile())))); - ByteArrayOutputStream logBuffer = new ByteArrayOutputStream(); + try (ByteArrayOutputStream logBuffer = new ByteArrayOutputStream(); PrintStream logPlainFormatter = new PrintStream(new AnsiOutputStream(logBuffer)); PrintStream logFormatter = new PrintStream(new HtmlAnsiOutputStream(logBuffer))){ writeTestApplicationPom(testProfile); @@ -166,7 +160,6 @@ public class TestRunner implements com.yahoo.vespa.testrunner.TestRunner { Process mavenProcess = builder.start(); BufferedReader in = new BufferedReader(new InputStreamReader(mavenProcess.getInputStream())); in.lines().forEach(line -> { - fileStream.println(line); logFormatter.print(line); String message = logBuffer.toString(UTF_8); if (message.length() > 1 << 13) { @@ -185,11 +178,6 @@ public class TestRunner implements com.yahoo.vespa.testrunner.TestRunner { record.setThrown(exception); logger.log(record); log.put(record.getSequenceNumber(), record); - try (PrintStream file = new PrintStream(new FileOutputStream(logFile.toFile(), true))) { - file.println(record.getMessage()); - exception.printStackTrace(file); - } - catch (IOException ignored) { } status = exception instanceof NoTestsException ? Status.FAILURE : Status.ERROR; return; } diff --git a/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java b/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java index b513dfba8b5..752ca6103d1 100644 --- a/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java +++ b/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java @@ -30,7 +30,6 @@ public class TestRunnerTest { private Path artifactsPath; private Path testPath; - private Path logFile; private Path configFile; private Path settingsFile; @@ -40,14 +39,13 @@ public class TestRunnerTest { Files.createFile(artifactsPath.resolve("my-tests.jar")); Files.createFile(artifactsPath.resolve("my-fat-test.jar")); testPath = tmp.newFolder("testData").toPath(); - logFile = tmp.newFile("maven.log").toPath(); configFile = tmp.newFile("testConfig.json").toPath(); settingsFile = tmp.newFile("settings.xml").toPath(); } @Test public void ansiCodesAreConvertedToHtml() throws InterruptedException { - TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile, + TestRunner runner = new TestRunner(artifactsPath, testPath, configFile, settingsFile, __ -> new ProcessBuilder("echo", Ansi.ansi().fg(Ansi.Color.RED).a("Hello!").reset().toString())); runner.test(SYSTEM_TEST, new byte[0]); while (runner.getStatus() == TestRunner.Status.RUNNING) { @@ -64,7 +62,7 @@ public class TestRunnerTest { @Test public void noTestJarIsAFailure() throws InterruptedException, IOException { Files.delete(artifactsPath.resolve("my-tests.jar")); - TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile, + TestRunner runner = new TestRunner(artifactsPath, testPath, configFile, settingsFile, __ -> new ProcessBuilder("This is a command that doesn't exist, for sure!")); runner.test(SYSTEM_TEST, new byte[0]); while (runner.getStatus() == TestRunner.Status.RUNNING) { @@ -80,7 +78,7 @@ public class TestRunnerTest { @Test public void errorLeadsToError() throws InterruptedException { - TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile, + TestRunner runner = new TestRunner(artifactsPath, testPath, configFile, settingsFile, __ -> new ProcessBuilder("false")); runner.test(SYSTEM_TEST, new byte[0]); while (runner.getStatus() == TestRunner.Status.RUNNING) { @@ -92,7 +90,7 @@ public class TestRunnerTest { @Test public void failureLeadsToFailure() throws InterruptedException { - TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile, + TestRunner runner = new TestRunner(artifactsPath, testPath, configFile, settingsFile, __ -> new ProcessBuilder("false")); runner.test(SYSTEM_TEST, new byte[0]); while (runner.getStatus() == TestRunner.Status.RUNNING) { @@ -104,7 +102,7 @@ public class TestRunnerTest { @Test public void filesAreGenerated() throws InterruptedException, IOException { - TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile, + TestRunner runner = new TestRunner(artifactsPath, testPath, configFile, settingsFile, __ -> new ProcessBuilder("echo", "Hello!")); runner.test(SYSTEM_TEST, "config".getBytes()); while (runner.getStatus() == TestRunner.Status.RUNNING) { @@ -113,12 +111,11 @@ public class TestRunnerTest { assertEquals("config", new String(Files.readAllBytes(configFile))); assertTrue(Files.exists(testPath.resolve("pom.xml"))); assertTrue(Files.exists(settingsFile)); - assertEquals("Hello!\n", new String(Files.readAllBytes(logFile))); } @Test public void runnerCanBeReused() throws InterruptedException, IOException { - TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile, + TestRunner runner = new TestRunner(artifactsPath, testPath, configFile, settingsFile, __ -> new ProcessBuilder("sleep", "0.1")); runner.test(SYSTEM_TEST, "config".getBytes()); assertEquals(TestRunner.Status.RUNNING, runner.getStatus()); |