From 0d0c6e4a7f21608930c7fc64cc5bf480daa6e30f Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Fri, 15 Feb 2019 10:12:41 -0500 Subject: [PATCH] Ensure random timestamps are within search boundary (#38753) The random timestamps were landing too close to the current time, so an unlucky rollup interval would round such that the doc wasn't included in the search range (and thus not "rolled up") which would then fail the test. The fix is to make sure the timestamp of all docs is sufficiently behind 'now' that the possible rounding intervals will always include them. Unmutes testRandomizedDateHisto, closes #34762 "Forward-port" of 368c6f279064ff9f5836cfdbfa86f90fb04f6da5 (wasn't merged into master for some reason) --- .../xpack/rollup/job/RollupIndexerIndexingTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java index 492d24b88f06e..98f4d9e428333 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java @@ -452,7 +452,6 @@ public void testSimpleDateHistoWithTimeZone() throws Exception { }); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/34762") public void testRandomizedDateHisto() throws Exception { String rollupIndex = randomAlphaOfLengthBetween(5, 10); @@ -468,7 +467,9 @@ public void testRandomizedDateHisto() throws Exception { final List> dataset = new ArrayList<>(); int numDocs = randomIntBetween(1,100); for (int i = 0; i < numDocs; i++) { - long timestamp = new DateTime().minusHours(randomIntBetween(1,100)).getMillis(); + // Make sure the timestamp is sufficiently in the past that we don't get bitten + // by internal rounding, causing no docs to match + long timestamp = new DateTime().minusDays(2).minusHours(randomIntBetween(11,100)).getMillis(); dataset.add(asMap(timestampField, timestamp, valueField, randomLongBetween(1, 100))); } executeTestCase(dataset, job, System.currentTimeMillis(), (resp) -> {