Skip to content

Commit c02b47c

Browse files
authored
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 59944a0 commit c02b47c

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
@@ -343,14 +343,18 @@ public void testMaybeFlush() throws Exception {
343343
assertTrue(shard.shouldPeriodicallyFlush());
344344
final Translog translog = getTranslog(shard);
345345
assertEquals(2, translog.stats().getUncommittedOperations());
346+
assertThat(shard.flushStats().getTotal(), equalTo(0L));
346347
client().prepareIndex("test").setId("2").setSource("{}", XContentType.JSON)
347348
.setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get();
349+
assertThat(shard.getLastKnownGlobalCheckpoint(), equalTo(2L));
348350
assertBusy(() -> { // this is async
349351
assertFalse(shard.shouldPeriodicallyFlush());
350-
assertThat(shard.flushStats().getPeriodic(), greaterThan(0L));
352+
assertThat(shard.flushStats().getPeriodic(), equalTo(1L));
353+
assertThat(shard.flushStats().getTotal(), equalTo(1L));
351354
});
352355
shard.sync();
353-
assertEquals(0, translog.stats().getUncommittedOperations());
356+
assertThat(shard.getLastSyncedGlobalCheckpoint(), equalTo(2L));
357+
assertThat("last commit [" + shard.commitStats().getUserData() + "]", translog.stats().getUncommittedOperations(), equalTo(0));
354358
long size = Math.max(translog.stats().getUncommittedSizeInBytes(), Translog.DEFAULT_HEADER_SIZE_IN_BYTES + 1);
355359
logger.info("--> current translog size: [{}] num_ops [{}] generation [{}]",
356360
translog.stats().getUncommittedSizeInBytes(), translog.stats().getUncommittedOperations(), translog.getGeneration());

0 commit comments

Comments
 (0)