NO-JIRA Fix PagingStoreImplTest#testBlockUnblock random failure

PagingStroeImpl.checkReleasedMemory() will kick off
executor.execute(this::memoryReleased) to pull from the queue onMemoryFreedRunnables
asynchronously. If the executor fires the task too late, it can pick up one of the
late trackMemoryChecks runnable and increase its calls, making assertion fail.
need to flush the executors to make sure it doesn't happen.
This commit is contained in:
Howard Gao 2024-01-22 21:57:32 +08:00 committed by Justin Bertram
parent 2269ad417e
commit 5e99516a27
1 changed files with 3 additions and 0 deletions

View File

@ -1252,6 +1252,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
};
store.applySetting(new AddressSettings().setMaxSizeBytes(1000).setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK));
store.addSize(100);
store.flushExecutors();
store.checkMemory(trackMemoryChecks, null);
assertEquals(1, calls.get());
@ -1270,6 +1271,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
store.addSize(900);
assertEquals(100, store.getAddressLimitPercent());
store.flushExecutors();
// address full blocks
store.checkMemory(trackMemoryChecks, null);
@ -1285,6 +1287,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
assertEquals(2, calls.get());
store.unblock();
store.flushExecutors();
// now released
assertTrue(Wait.waitFor(new Wait.Condition() {