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


##########
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:
   So the over implementation "browse" reads from a snapshot while here 
deletion are dynamically applied onto the "browsing side. Ok with me.
   
   I am ok with the isolation level of the browse to be implementation specific.
   
   We could likely benefit from a little write up regarding this? Interesting 
details could be documented...



-- 
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