From 2b82ea480e8122e2e8ce57f93d36d02e483b455c Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Wed, 25 Nov 2026 11:06:46 -0600 Subject: [PATCH] ARTEMIS-6387 fix flaky RecoverTest.testRecover --- .../tests/integration/cli/RecoverTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/RecoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/RecoverTest.java index 1d9225c2fe0d..b31f1893479e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/RecoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/RecoverTest.java @@ -37,6 +37,7 @@ import org.apache.activemq.artemis.cli.commands.ActionContext; import org.apache.activemq.artemis.cli.commands.tools.RecoverMessages; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.paging.PagingStore; import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.nativo.jlibaio.LibaioContext; import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension; @@ -115,6 +116,25 @@ protected boolean usePersistence() { return true; } + /** + * {@return the total number of bytes still held by the page files of the given store} + */ + private static long pagedBytes(PagingStore pagingStore) { + File folder = pagingStore.getFolder(); + if (folder == null) { + return 0; + } + File[] pageFiles = folder.listFiles((dir, name) -> name.endsWith(".page")); + if (pageFiles == null) { + return 0; + } + long total = 0; + for (File pageFile : pageFiles) { + total += pageFile.length(); + } + return total; + } + @TestTemplate public void testRecover() throws Exception { @@ -164,6 +184,9 @@ public void testRecover() throws Exception { // need to wait no paging, otherwise an eventual page cleanup would remove large message bodies from the recovery Wait.assertFalse(serverQueue.getPagingStore()::isPaging); + // wait for the page files to be really gone + Wait.assertEquals(0L, () -> pagedBytes(serverQueue.getPagingStore())); + server.stop(); File newJournalLocation = new File(server.getConfiguration().getJournalLocation().getParentFile(), "recovered");