Expand unit test to include un-filtered log file
@@ -27,7 +27,8 @@ public class LogReaderTest {
private final Path logDirectory = fileSystem.getPath("/opt/vespa/logs");
private static final String log1 = "0.1\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstdout\tinfo\tERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)\n";
- private static final String log2 = "0.2\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstderr\twarning\tjava.lang.NullPointerException\\n\\tat org.apache.felix.framework.BundleRevisionImpl.calculateContentPath(BundleRevisionImpl.java:438)\\n\\tat org.apache.felix.framework.BundleRevisionImpl.initializeContentPath(BundleRevisionImpl.java:371)\n";
+ private static final String log2 = "0.15\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstderr\twarning\twarning\n";
+ private static final String log3 = "0.2\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstderr\twarning\tjava.lang.NullPointerException\\n\\tat org.apache.felix.framework.BundleRevisionImpl.calculateContentPath(BundleRevisionImpl.java:438)\\n\\tat org.apache.felix.framework.BundleRevisionImpl.initializeContentPath(BundleRevisionImpl.java:371)\n";
@Before
public void setup() throws IOException {
@@ -37,7 +38,10 @@ public class LogReaderTest {
Files.write(logDirectory.resolve("log1.log.gz"), compress(log1)),
FileTime.from(Instant.ofEpochMilli(123)));
Files.setLastModifiedTime(
- Files.write(logDirectory.resolve("subfolder/log2.log"), log2.getBytes(UTF_8)),
+ Files.write(logDirectory.resolve("subfolder/log2.log.gz"), compress(log2)),
+ FileTime.from(Instant.ofEpochMilli(180)));
+ Files.setLastModifiedTime(
+ Files.write(logDirectory.resolve("subfolder/log3.log"), log3.getBytes(UTF_8)),
FileTime.from(Instant.ofEpochMilli(234)));
}
@@ -54,10 +58,10 @@ public class LogReaderTest {
@Test
public void testThatLogsNotMatchingRegexAreExcluded() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- LogReader logReader = new LogReader(logDirectory, Pattern.compile(".*2\\.log"));
+ LogReader logReader = new LogReader(logDirectory, Pattern.compile(".*3\\.log"));
logReader.writeLogs(baos, Instant.ofEpochMilli(0), Instant.ofEpochMilli(300));
- assertEquals(log2, decompress(baos.toByteArray()));
+ assertEquals(log3, decompress(baos.toByteArray()));
}
@Test
@@ -66,7 +70,7 @@ public class LogReaderTest {
LogReader logReader = new LogReader(logDirectory, Pattern.compile(".*"));
logReader.writeLogs(zippedBaos, Instant.ofEpochMilli(0), Instant.ofEpochMilli(300));
- assertEquals(log1 + log2, decompress(zippedBaos.toByteArray()));
+ assertEquals(log1 + log2 + log3, decompress(zippedBaos.toByteArray()));
}
private byte[] compress(String input) throws IOException {
