From d6d022d7064e10bf58b9bb664ae8f7725a9c13af Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sun, 13 Dec 2020 09:23:07 -0500 Subject: [PATCH] Fix TranslogTests#testStats (#66227) If creating the latest translog file and retrieving a translog stats happen within the same millisecond, then the earliestLastModifiedAge will be zero. Closes #66092 --- .../java/org/elasticsearch/index/translog/TranslogTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java index 554f64ee1c1d..cda91215b206 100644 --- a/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java +++ b/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java @@ -507,6 +507,7 @@ public void testStats() throws IOException { markCurrentGenAsCommitted(translog); { + lastModifiedAge = System.currentTimeMillis() - translog.getCurrent().getLastModifiedTime(); final TranslogStats stats = stats(); assertThat(stats.estimatedNumberOfOperations(), equalTo(4)); assertThat(stats.getTranslogSizeInBytes(), equalTo(expectedSizeInBytes));