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
This commit is contained in:
Nhat Nguyen 2020-12-13 09:23:07 -05:00
parent 84d4e5bcb1
commit cc674e7d74
1 changed files with 2 additions and 1 deletions

View File

@ -493,12 +493,13 @@ public class TranslogTests extends ESTestCase {
translog.getDeletionPolicy().setLocalCheckpointOfSafeCommit(randomLongBetween(3, Long.MAX_VALUE));
translog.trimUnreferencedReaders();
{
long lastModifiedAge = System.currentTimeMillis() - translog.getCurrent().getLastModifiedTime();
final TranslogStats stats = stats();
assertThat(stats.estimatedNumberOfOperations(), equalTo(4));
assertThat(stats.getTranslogSizeInBytes(), equalTo(355L));
assertThat(stats.getUncommittedOperations(), equalTo(0));
assertThat(stats.getUncommittedSizeInBytes(), equalTo(firstOperationPosition));
assertThat(stats.getEarliestLastModifiedAge(), greaterThan(0L));
assertThat(stats.getEarliestLastModifiedAge(), greaterThanOrEqualTo(lastModifiedAge));
}
}