From 148e64d654c694313e94afeb2f8948d44608cf58 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 23 Jun 2016 22:49:19 +0200 Subject: [PATCH] [TEST] Port testcase from #19035 to master --- .../index/translog/TranslogTests.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java index 0c6ee4117cb..c72a6ecef27 100644 --- a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java +++ b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java @@ -1902,4 +1902,23 @@ public class TranslogTests extends ESTestCase { Checkpoint read = Checkpoint.read(tempDir.resolve("foo.cpk")); assertEquals(read, checkpoint); } + + /** + * Tests that closing views after the translog is fine and we can reopen the translog + */ + public void testPendingDelete() throws IOException { + translog.add(new Translog.Index("test", "1", new byte[]{1})); + translog.prepareCommit(); + Translog.TranslogGeneration generation = translog.getGeneration(); + TranslogConfig config = translog.getConfig(); + translog.close(); + translog = new Translog(config, generation); + translog.add(new Translog.Index("test", "2", new byte[]{2})); + translog.prepareCommit(); + Translog.View view = translog.newView(); + translog.add(new Translog.Index("test", "3", new byte[]{3})); + translog.close(); + IOUtils.close(view); + translog = new Translog(config, generation); + } }