logstash-plugins / logstash-filter-date

Apache License 2.0
7 stars 43 forks source link

Switched time string comparation to Timestamp comparable to avoiding problems due to precision loss #141

Closed andsel closed 3 years ago

andsel commented 3 years ago

Release notes

Fix spec and unit tests after introduction of nanosecond precision in Logstash with https://github.com/elastic/logstash/pull/12797

What does this PR do?

This PR switched time comparations in specs and unit test from String to org.logstash.Timestamp to avoid problems due to loss of precision.

The PR https://github.com/elastic/logstash/pull/12797 introduced nanosecond precision into Logstash, a similar problem happened also into JDBC plugin and here is implemented the same solution described in the original comment.

Why is it important/What is the impact to the user?

It doesn't impact the user, it's only related to tests

Checklist

Author's Checklist

How to test this PR locally

Related issues

Use cases

Screenshots

The problem could be seen at https://app.travis-ci.com/github/logstash-plugins/logstash-filter-date/jobs/545405353#L528

Logs

logstash_1_f52dffb2a8a0 | <=====--------> 42% EXECUTING [8s]> :compileTestJava<=====--------> 42% EXECUTING [9s]<===========--> 85% EXECUTING [9s]> :test<===========--> 85% EXECUTING [10s]<===========--> 85% EXECUTING [11s]<===========--> 85% EXECUTING [12s]> :test > Resolve files of :testRuntimeClasspath> :test > 0 tests completed<===========--> 85% EXECUTING [13s]> :test > Executing test org.logstash.filters.parser.JodaParserTest<===========--> 85% EXECUTING [14s]> :test > 2 tests completed> :test > Executing test org.logstash.filters.parser.UnixEpochParserTest> :test > 16 tests completed> :test > 162 tests completed> :test > 178 tests completed> :test > Executing test org.logstash.filters.DateFilterTest<===========--> 85% EXECUTING [15s]<===========--> 85% EXECUTING [16s]<===========--> 85% EXECUTING [17s]<===========--> 85% EXECUTING [18s]> :test > 180 tests completedlogstash_1_f52dffb2a8a0 | > Task :test
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | org.logstash.filters.DateFilterTest > testIsoStrings FAILED
logstash_1_f52dffb2a8a0 |     java.lang.AssertionError at DateFilterTest.java:210
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | org.logstash.filters.DateFilterTest > testUnixLongs FAILED
logstash_1_f52dffb2a8a0 |     java.lang.AssertionError at DateFilterTest.java:210
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | org.logstash.filters.DateFilterTest > testIsoStringsInterpolateTz FAILED
logstash_1_f52dffb2a8a0 |     java.lang.AssertionError at DateFilterTest.java:210
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | org.logstash.filters.DateFilterTest > testUnixInts FAILED
logstash_1_f52dffb2a8a0 |     java.lang.AssertionError at DateFilterTest.java:210
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | <===========--> 85% EXECUTING [18s]> :test > 186 tests completed, 4 failed> :test > Executing test org.logstash.filters.DateFilterTestlogstash_1_f52dffb2a8a0 | org.logstash.filters.DateFilterTest > testPatternStringsInterpolateTzNoYear FAILED
logstash_1_f52dffb2a8a0 |     java.lang.AssertionError at DateFilterTest.java:210
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | org.logstash.filters.DateFilterTest > testUnixStrings FAILED
logstash_1_f52dffb2a8a0 |     java.lang.AssertionError at DateFilterTest.java:210
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | <===========--> 85% EXECUTING [18s]> :test > 188 tests completed, 6 failedlogstash_1_f52dffb2a8a0 | 188 tests completed, 6 failed
loggstash_1_f52dffb2a8a0 | logstash_1_f52dffb2a8a0 | 
logstash_1_f52dffb2a8a0 | <===========--> 85% EXECUTING [19s]> :testlogstash_1_f52dffb2a8a0 | > Task :test FAILED
andsel commented 3 years ago

@yaauie in the comment you noted that the implementation of Data filter needs to switch from Joda to java.time, this PR is intended to be a bugfix to get the tests green again.