|
120 | 120 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoSearchHits;
|
121 | 121 | import static org.hamcrest.Matchers.allOf;
|
122 | 122 | import static org.hamcrest.Matchers.containsString;
|
| 123 | +import static org.hamcrest.Matchers.either; |
123 | 124 | import static org.hamcrest.Matchers.equalTo;
|
124 | 125 | import static org.hamcrest.Matchers.greaterThan;
|
125 | 126 | import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
@@ -474,18 +475,22 @@ public void testStressMaybeFlushOrRollTranslogGeneration() throws Exception {
|
474 | 475 | final FlushStats initialStats = shard.flushStats();
|
475 | 476 | client().prepareIndex("test", "test", "1").setSource("{}", XContentType.JSON).get();
|
476 | 477 | check = () -> {
|
| 478 | + assertFalse(shard.shouldPeriodicallyFlush()); |
477 | 479 | final FlushStats currentStats = shard.flushStats();
|
478 | 480 | String msg = String.format(Locale.ROOT, "flush stats: total=[%d vs %d], periodic=[%d vs %d]",
|
479 | 481 | initialStats.getTotal(), currentStats.getTotal(), initialStats.getPeriodic(), currentStats.getPeriodic());
|
480 |
| - assertThat(msg, currentStats.getPeriodic(), equalTo(initialStats.getPeriodic() + 1)); |
481 |
| - assertThat(msg, currentStats.getTotal(), equalTo(initialStats.getTotal() + 1)); |
| 482 | + assertThat(msg, currentStats.getPeriodic(), |
| 483 | + either(equalTo(initialStats.getPeriodic() + 1)).or(equalTo(initialStats.getPeriodic() + 2))); |
| 484 | + assertThat(msg, currentStats.getTotal(), |
| 485 | + either(equalTo(initialStats.getTotal() + 1)).or(equalTo(initialStats.getTotal() + 2))); |
482 | 486 | };
|
483 | 487 | } else {
|
484 | 488 | final long generation = getTranslog(shard).currentFileGeneration();
|
485 | 489 | client().prepareIndex("test", "test", "1").setSource("{}", XContentType.JSON).get();
|
486 |
| - check = () -> assertEquals( |
487 |
| - generation + 1, |
488 |
| - getTranslog(shard).currentFileGeneration()); |
| 490 | + check = () -> { |
| 491 | + assertFalse(shard.shouldRollTranslogGeneration()); |
| 492 | + assertEquals(generation + 1, getTranslog(shard).currentFileGeneration()); |
| 493 | + }; |
489 | 494 | }
|
490 | 495 | assertBusy(check);
|
491 | 496 | running.set(false);
|
|
0 commit comments