[TEST] Add test to ensure master is not prone to #8917

This commit is contained in:
Simon Willnauer 2014-12-12 10:59:11 +01:00
parent 7b82660ffc
commit 6dacf61dfc
1 changed files with 20 additions and 0 deletions

View File

@ -548,4 +548,24 @@ public abstract class AbstractSimpleTranslogTests extends ElasticsearchTestCase
private Term newUid(String id) { private Term newUid(String id) {
return new Term("_uid", id); return new Term("_uid", id);
} }
@Test
public void testVerifyTranslogIsNotDeleted() throws IOException {
Path path = translogFileDirectory();
assertTrue(Files.exists(path.resolve("translog-1")));
translog.add(new Translog.Create("test", "1", new byte[]{1}));
Translog.Snapshot snapshot = translog.snapshot();
MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1));
assertThat(snapshot.estimatedTotalOperations(), equalTo(1));
if (randomBoolean()) {
translog.close();
snapshot.close();
} else {
snapshot.close();
translog.close();
}
assertTrue(Files.exists(path.resolve("translog-1")));
}
} }