ARTEMIS-3928 Fixing intermittent failure after executor's change

This commit is contained in:
Clebert Suconic 2022-08-13 22:09:32 -04:00
parent 252e5b0b14
commit 2fbf2fcef0
1 changed files with 21 additions and 7 deletions

View File

@ -235,13 +235,25 @@ public class PagingSendTest extends ActiveMQTestBase {
// Give time Queue.deliverAsync to deliver messages // Give time Queue.deliverAsync to deliver messages
Assert.assertTrue("Messages were not propagated to internal structures.", waitForMessages(queue, batchSize, 3000)); Assert.assertTrue("Messages were not propagated to internal structures.", waitForMessages(queue, batchSize, 3000));
checkBatchMessagesAreNotPagedTwice(queue); AtomicInteger errors = new AtomicInteger(0);
CountDownLatch done = new CountDownLatch(1);
for (int i = 0; i < 10; i++) { queue.getPagingStore().getExecutor().execute(() -> {
// execute the same count a couple times. This is to make sure the iterators have no impact regardless try {
// the number of times they are called checkBatchMessagesAreNotPagedTwice(queue);
assertEquals(batchSize, processCountThroughIterator(queue)); for (int i = 0; i < 10; i++) {
} // execute the same count a couple times. This is to make sure the iterators have no impact regardless
// the number of times they are called
assertEquals(batchSize, processCountThroughIterator(queue));
}
} catch (Throwable e) {
e.printStackTrace();
errors.incrementAndGet();
}
done.countDown();
});
Assert.assertEquals(0, errors.get());
} }
@ -312,6 +324,7 @@ public class PagingSendTest extends ActiveMQTestBase {
Set<String> messageOrderSet = new HashSet<>(); Set<String> messageOrderSet = new HashSet<>();
int duplicates = 0; int duplicates = 0;
while (pageIterator.hasNext()) { while (pageIterator.hasNext()) {
MessageReference reference = pageIterator.next(); MessageReference reference = pageIterator.next();
@ -320,10 +333,11 @@ public class PagingSendTest extends ActiveMQTestBase {
// If add(id) returns true it means that this id was already added to this set. Hence a duplicate is found. // If add(id) returns true it means that this id was already added to this set. Hence a duplicate is found.
if (!messageOrderSet.add(id)) { if (!messageOrderSet.add(id)) {
System.out.println("Received a duplicate on " + id);
duplicates++; duplicates++;
} }
} }
assertTrue(duplicates == 0); Assert.assertEquals(0, duplicates);
} }
public boolean waitForMessages(Queue queue, int count, long timeout) throws Exception { public boolean waitForMessages(Queue queue, int count, long timeout) throws Exception {