Skip to content

Commit

Permalink
Add more assertions to testMaybeFlush (elastic#52792)
Browse files Browse the repository at this point in the history
We aren't able to reproduce or figure out the reason that failed this test.
This commit adds more assertions so we can narrow the scope.

Relates elastic#52223
  • Loading branch information
dnhatn committed Feb 26, 2020
1 parent ceb7967 commit e94a201
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,18 @@ public void testMaybeFlush() throws Exception {
assertTrue(shard.shouldPeriodicallyFlush());
final Translog translog = getTranslog(shard);
assertEquals(2, translog.stats().getUncommittedOperations());
assertThat(shard.flushStats().getTotal(), equalTo(0L));
client().prepareIndex("test", "_doc", "2").setSource("{}", XContentType.JSON)
.setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get();
assertThat(shard.getLastKnownGlobalCheckpoint(), equalTo(2L));
assertBusy(() -> { // this is async
assertFalse(shard.shouldPeriodicallyFlush());
assertThat(shard.flushStats().getPeriodic(), greaterThan(0L));
assertThat(shard.flushStats().getPeriodic(), equalTo(1L));
assertThat(shard.flushStats().getTotal(), equalTo(1L));
});
shard.sync();
assertEquals(0, translog.stats().getUncommittedOperations());
assertThat(shard.getLastSyncedGlobalCheckpoint(), equalTo(2L));
assertThat("last commit [" + shard.commitStats().getUserData() + "]", translog.stats().getUncommittedOperations(), equalTo(0));
long size = Math.max(translog.stats().getUncommittedSizeInBytes(), Translog.DEFAULT_HEADER_SIZE_IN_BYTES + 1);
logger.info("--> current translog size: [{}] num_ops [{}] generation [{}]",
translog.stats().getUncommittedSizeInBytes(), translog.stats().getUncommittedOperations(), translog.getGeneration());
Expand Down

0 comments on commit e94a201

Please sign in to comment.