Skip to content

Commit 814c275

Browse files
committed
Add more assertions to testMaybeFlush (#52792)
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 #52223
1 parent 0a15a6b commit 814c275

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,18 @@ public void testMaybeFlush() throws Exception {
362362
assertTrue(shard.shouldPeriodicallyFlush());
363363
final Translog translog = getTranslog(shard);
364364
assertEquals(2, translog.stats().getUncommittedOperations());
365+
assertThat(shard.flushStats().getTotal(), equalTo(0L));
365366
client().prepareIndex("test", "_doc", "2").setSource("{}", XContentType.JSON)
366367
.setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get();
368+
assertThat(shard.getLastKnownGlobalCheckpoint(), equalTo(2L));
367369
assertBusy(() -> { // this is async
368370
assertFalse(shard.shouldPeriodicallyFlush());
369-
assertThat(shard.flushStats().getPeriodic(), greaterThan(0L));
371+
assertThat(shard.flushStats().getPeriodic(), equalTo(1L));
372+
assertThat(shard.flushStats().getTotal(), equalTo(1L));
370373
});
371374
shard.sync();
372-
assertEquals(0, translog.stats().getUncommittedOperations());
375+
assertThat(shard.getLastSyncedGlobalCheckpoint(), equalTo(2L));
376+
assertThat("last commit [" + shard.commitStats().getUserData() + "]", translog.stats().getUncommittedOperations(), equalTo(0));
373377
long size = Math.max(translog.stats().getUncommittedSizeInBytes(), Translog.DEFAULT_HEADER_SIZE_IN_BYTES + 1);
374378
logger.info("--> current translog size: [{}] num_ops [{}] generation [{}]",
375379
translog.stats().getUncommittedSizeInBytes(), translog.stats().getUncommittedOperations(), translog.getGeneration());

0 commit comments

Comments
 (0)