TEST: Adjust translog size assumption in new engine
A new engine now can have more than one empty translog since #28676. This cause #testShouldPeriodicallyFlush failed because in the test we asssume an engine should have one empty translog. This commit takes into account the extra translog size of a new engine.
This commit is contained in:
parent
2f21dc7129
commit
22ad52a288
|
@ -4251,13 +4251,16 @@ public class InternalEngineTests extends EngineTestCase {
|
|||
|
||||
public void testShouldPeriodicallyFlush() throws Exception {
|
||||
assertThat("Empty engine does not need flushing", engine.shouldPeriodicallyFlush(), equalTo(false));
|
||||
// A new engine may have more than one empty translog files - the test should account this extra.
|
||||
final long extraTranslogSizeInNewEngine = engine.getTranslog().uncommittedSizeInBytes() - Translog.DEFAULT_HEADER_SIZE_IN_BYTES;
|
||||
int numDocs = between(10, 100);
|
||||
for (int id = 0; id < numDocs; id++) {
|
||||
final ParsedDocument doc = testParsedDocument(Integer.toString(id), null, testDocumentWithTextField(), SOURCE, null);
|
||||
engine.index(indexForDoc(doc));
|
||||
}
|
||||
assertThat("Not exceeded translog flush threshold yet", engine.shouldPeriodicallyFlush(), equalTo(false));
|
||||
long flushThreshold = RandomNumbers.randomLongBetween(random(), 100, engine.getTranslog().uncommittedSizeInBytes());
|
||||
long flushThreshold = RandomNumbers.randomLongBetween(random(), 100,
|
||||
engine.getTranslog().uncommittedSizeInBytes() - extraTranslogSizeInNewEngine);
|
||||
final IndexSettings indexSettings = engine.config().getIndexSettings();
|
||||
final IndexMetaData indexMetaData = IndexMetaData.builder(indexSettings.getIndexMetaData())
|
||||
.settings(Settings.builder().put(indexSettings.getSettings())
|
||||
|
|
Loading…
Reference in New Issue