diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2019-03-29 12:52:00 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2019-03-29 12:52:00 +0100 |
commit | 9ae49b67e47aa2f0c5e1c7b326aad9c9236fa150 (patch) | |
tree | cff0de939dad2c5d85d526b70a0ab5a2114052ab /vespalog/src/test/java | |
parent | d961a004fa0b93a598d7aa958d12d710eeb87c23 (diff) |
Increase number of decimals in log timestamp from 3 to 6
Diffstat (limited to 'vespalog/src/test/java')
3 files changed, 44 insertions, 29 deletions
diff --git a/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java b/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java index d0e2baf47c5..2cea88b1c36 100644 --- a/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java +++ b/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java @@ -1,20 +1,24 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.log; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; import java.io.IOException; import java.time.Instant; +import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; -import java.util.logging.Level; -import java.io.File; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.Before; -import org.junit.rules.TemporaryFolder; -import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; /** * Make sure we can install the logging stuff properly. @@ -52,7 +56,7 @@ public class LogSetupTestCase { hostname = Util.getHostName(); pid = Util.getPID(); - zookeeperLogRecordString = "1107011348.029\t" + zookeeperLogRecordString = "1107011348.029000\t" + hostname + "\t" + pid diff --git a/vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java b/vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java index cbfbd609f61..d3d1d52c1d5 100644 --- a/vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java +++ b/vespalog/src/test/java/com/yahoo/log/VespaFormatterTestCase.java @@ -40,7 +40,7 @@ public class VespaFormatterTestCase { testRecord1.setInstant(Instant.ofEpochMilli(1098709021843L)); testRecord1.setThreadID(123); - expected1 = "1098709021.843\t" + expected1 = "1098709021.843000\t" + hostname + "\t" + pid + "/123" + "\t" @@ -49,7 +49,7 @@ public class VespaFormatterTestCase { + "info\t" + "this is a test\n"; - expected2 = "1098709021.843\t" + expected2 = "1098709021.843000\t" + hostname + "\t" + pid + "/123" + "\t" @@ -64,7 +64,7 @@ public class VespaFormatterTestCase { testRecord2.setThreadID(123); testRecord2.setLoggerName("org.foo"); - expected3 = "1098709021.843\t" + expected3 = "1098709021.843000\t" + hostname + "\t" + pid + "/123" + "\t" @@ -73,7 +73,7 @@ public class VespaFormatterTestCase { + "info\t" + "this is a test\n"; - expected4 = "1098709021.843\t" + expected4 = "1098709021.843000\t" + hostname + "\t" + pid + "/123" + "\t" @@ -112,7 +112,7 @@ public class VespaFormatterTestCase { Object[] params = { "a small", "message" }; testRecord.setParameters(params); - String expected = "1098709021.843\t" + String expected = "1098709021.843000\t" + hostname + "\t" + pid + "/123" + "\t" @@ -232,6 +232,7 @@ public class VespaFormatterTestCase { * of runtime errors. -bb */ @Test + @SuppressWarnings("removal") // for VespaFormat.formatException public void testExceptionFormatting () { StringBuilder sb = new StringBuilder(128); Exception e = new Exception("testing", new Exception("nested")); @@ -240,9 +241,10 @@ public class VespaFormatterTestCase { @Test - public void testGeneralFormat() { + @SuppressWarnings("removal") + public void testGeneralFormat() { // for VespaFormat.format String[] expected = new String[] { - "54.321", + "54.321000", "hostname", "26019/UnitTest-Thread-37", "UnitTestRunner", diff --git a/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java b/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java index d18bce2f4ec..c0dd856b634 100644 --- a/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java +++ b/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java @@ -5,19 +5,28 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.io.*; -import java.time.Instant; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CyclicBarrier; import java.util.logging.Level; import java.util.logging.LogRecord; -import java.util.logging.Logger; -import static java.time.Instant.ofEpochMilli; +import static java.time.Instant.ofEpochSecond; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * @author Bjorn Borud @@ -43,8 +52,8 @@ public class VespaLogHandlerTestCase { pid = Util.getPID(); record1 = new LogRecord(Level.INFO, "This is a test"); - record1.setInstant(ofEpochMilli(1100011348029L)); - record1String = "1100011348.029\t" + record1.setInstant(ofEpochSecond(1100011348L, 29_123_543)); + record1String = "1100011348.029123\t" + hostname + "\t" + pid @@ -53,9 +62,9 @@ public class VespaLogHandlerTestCase { + "\tmy-test-config-id\tTST\tinfo\tThis is a test"; record2 = new LogRecord(Level.FINE, "This is a test too"); - record2.setInstant(ofEpochMilli(1100021348029L)); + record2.setInstant(ofEpochSecond(1100021348L, 29_987_654)); record2.setLoggerName("com.yahoo.log.test"); - record2String = "1100021348.029\t" + record2String = "1100021348.029987\t" + hostname + "\t" + pid @@ -63,8 +72,8 @@ public class VespaLogHandlerTestCase { record3 = new LogRecord(Level.WARNING, "another test"); record3.setLoggerName("com.yahoo.log.test"); - record3.setInstant(ofEpochMilli(1107011348029L)); - record3String = "1107011348.029\t" + record3.setInstant(ofEpochSecond(1107011348L, 29_000_000L)); + record3String = "1107011348.029000\t" + hostname + "\t" + pid @@ -73,8 +82,8 @@ public class VespaLogHandlerTestCase { record4 = new LogRecord(Level.WARNING, "unicode \u00E6\u00F8\u00E5 test \u7881 unicode"); record4.setLoggerName("com.yahoo.log.test"); - record4.setInstant(ofEpochMilli(1107011348029L)); - record4String = "1107011348.029\t" + record4.setInstant(ofEpochSecond(1107011348, 29_000_001L)); + record4String = "1107011348.029000\t" + hostname + "\t" + pid |