chibenwa commented on code in PR #2416:
URL: https://github.com/apache/james-project/pull/2416#discussion_r1773316370


##########
server/queue/queue-api/src/test/java/org/apache/james/queue/api/ManageableMailQueueContract.java:
##########
@@ -457,24 +454,25 @@ default void removeShouldNotFailWhenBrowsingIterating() 
throws Exception {
 
     @Test
     default void browseShouldNotFailWhenConcurrentRemoveWhenIterating() throws 
Exception {
-        enQueue(defaultMail()
-            .name("name1")
-            .build());
-        enQueue(defaultMail()
-            .name("name2")
-            .build());
-        enQueue(defaultMail()
-            .name("name3")
-            .build());
+        // We use a large number of emails so that the probability of the 
remove being propagated
+        // through the queue is high enough that the test is not flaky.
+        IntStream.range(0, 100).forEach(
+                Throwing.intConsumer(i ->
+                        enQueue(defaultMail()
+                                .name("name" + i)
+                                .build())
+                ).sneakyThrow()
+        );
 
         ManageableMailQueue.MailQueueIterator items = 
getManageableMailQueue().browse();
-        items.next();
+        items.next(); // we consume 1 here
 
-        getManageableMailQueue().remove(ManageableMailQueue.Type.Name, 
"name2");
+        getManageableMailQueue().remove(ManageableMailQueue.Type.Name, 
"name99");
 
-        awaitRemove();
 
-        assertThatCode(() ->  
Iterators.consumingIterator(items)).doesNotThrowAnyException();
+        assertThatCode(
+                () -> assertThat(consumeIterator(items)).isEqualTo(98) // and 
998 here so 999 in total
+        ).doesNotThrowAnyException();

Review Comment:
   I thought a README at the base of each mail queue implementation but maybe 
not the best idea...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to