From f687f3ea6e2fa5ddfaf2965abe3e42e9e477e0f7 Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Fri, 24 Mar 2017 08:11:38 +0100 Subject: [PATCH] [ML] fix test mix up of millisecond with second (elastic/x-pack-elasticsearch#816) Fix spurious Test failure fix test resolution bug: mix up of millisecond with second Original commit: elastic/x-pack-elasticsearch@37b8fed559fbd056a1e270217951dfd39c7ed25c --- .../xpack/ml/job/process/DataCountsReporterTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java index 31f9c230846..847fd54f0f2 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java @@ -22,6 +22,7 @@ import org.mockito.Mockito; import java.io.IOException; import java.util.Arrays; import java.util.Date; +import java.util.concurrent.TimeUnit; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; @@ -300,7 +301,8 @@ public class DataCountsReporterTests extends ESTestCase { long lastReportedTimeMs = dataCountsReporter.incrementalStats().getLastDataTimeStamp().getTime(); // check last data time is equal to now give or take a second - assertTrue(lastReportedTimeMs >= now.getTime() && lastReportedTimeMs <= now.getTime() +1); + assertTrue(lastReportedTimeMs >= now.getTime() + && lastReportedTimeMs <= now.getTime() + TimeUnit.SECONDS.toMillis(1)); assertEquals(dataCountsReporter.incrementalStats().getLastDataTimeStamp(), dataCountsReporter.runningTotalStats().getLastDataTimeStamp());