This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git


The following commit(s) were added to refs/heads/main by this push:
     new 822cdb83 PROTON-2780 Fix race in two tests that can lead to failed test
822cdb83 is described below

commit 822cdb83f02dba4db9efed3006056997d8c59e9e
Author: Timothy Bish <[email protected]>
AuthorDate: Thu Dec 14 16:50:05 2023 -0500

    PROTON-2780 Fix race in two tests that can lead to failed test
    
    Ensure the scripted expectations are added before triggering commands to
    be sent to the client to avoid any unexpected performative errors if the
    frames arrive before the test adds the expectations.
---
 .../apache/qpid/protonj2/client/impl/SenderTest.java   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git 
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SenderTest.java
 
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SenderTest.java
index 24567aad..09c6d6c8 100644
--- 
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SenderTest.java
+++ 
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SenderTest.java
@@ -2063,7 +2063,7 @@ public class SenderTest extends ImperativeClientTestCase {
     }
 
     @Test
-    void testConcurrentSendBlocksBehindSendWaitingForCredit() throws Exception 
{
+    public void testConcurrentSendBlocksBehindSendWaitingForCredit() throws 
Exception {
         try (ProtonTestServer peer = new ProtonTestServer()) {
             peer.expectSASLAnonymousConnect();
             peer.expectOpen().respond();
@@ -2111,11 +2111,13 @@ public class SenderTest extends 
ImperativeClientTestCase {
             });
 
             peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
-            
peer.remoteFlow().withIncomingWindow(1).withDeliveryCount(0).withNextIncomingId(1).withLinkCredit(1).now();
             
peer.expectTransfer().withNonNullPayload().withMore(false).respond().withSettled(true).withState().accepted();
             
peer.remoteFlow().withIncomingWindow(1).withDeliveryCount(1).withNextIncomingId(2).withLinkCredit(1).queue();
             
peer.expectTransfer().withNonNullPayload().withMore(false).respond().withSettled(true).withState().accepted();
 
+            // Now Trigger transfer / flow event chain
+            
peer.remoteFlow().withIncomingWindow(1).withDeliveryCount(0).withNextIncomingId(1).withLinkCredit(1).later(10);
+
             assertTrue(send2Completed.await(10, TimeUnit.SECONDS));
 
             peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
@@ -2132,7 +2134,7 @@ public class SenderTest extends ImperativeClientTestCase {
     }
 
     @Test
-    void 
testConcurrentSendWaitingOnSplitFramedSendToCompleteIsSentAfterCreditUpdated() 
throws Exception {
+    public void 
testConcurrentSendWaitingOnSplitFramedSendToCompleteIsSentAfterCreditUpdated() 
throws Exception {
         try (ProtonTestServer peer = new ProtonTestServer()) {
             peer.expectSASLAnonymousConnect();
             peer.expectOpen().respond();
@@ -2181,7 +2183,6 @@ public class SenderTest extends ImperativeClientTestCase {
             });
 
             peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
-            
peer.remoteFlow().withIncomingWindow(1).withDeliveryCount(0).withNextIncomingId(1).withLinkCredit(1).now();
             peer.expectTransfer().withNonNullPayload().withMore(true);
             
peer.remoteFlow().withIncomingWindow(1).withDeliveryCount(0).withNextIncomingId(2).withLinkCredit(1).queue();
             
peer.expectTransfer().withNonNullPayload().withMore(false).respond().withSettled(true).withState().accepted();
@@ -2190,6 +2191,9 @@ public class SenderTest extends ImperativeClientTestCase {
             
peer.remoteFlow().withIncomingWindow(1).withDeliveryCount(1).withNextIncomingId(4).withLinkCredit(1).queue();
             
peer.expectTransfer().withNonNullPayload().withMore(false).respond().withSettled(true).withState().accepted();
 
+            // Trigger chain of events after script is configured.
+            
peer.remoteFlow().withIncomingWindow(1).withDeliveryCount(0).withNextIncomingId(1).withLinkCredit(1).now();
+
             assertTrue(send2Completed.await(10, TimeUnit.SECONDS));
 
             peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
@@ -2319,7 +2323,7 @@ public class SenderTest extends ImperativeClientTestCase {
     }
 
     @Test
-    void testWaitForAcceptedReturnsOnRemoteAcceptance() throws Exception {
+    public void testWaitForAcceptedReturnsOnRemoteAcceptance() throws 
Exception {
         try (ProtonTestServer peer = new ProtonTestServer()) {
             peer.expectSASLAnonymousConnect();
             peer.expectOpen().respond();
@@ -2354,7 +2358,7 @@ public class SenderTest extends ImperativeClientTestCase {
     }
 
     @Test
-    void testWaitForAcceptanceFailsIfRemoteSendsRejected() throws Exception {
+    public void testWaitForAcceptanceFailsIfRemoteSendsRejected() throws 
Exception {
         try (ProtonTestServer peer = new ProtonTestServer()) {
             peer.expectSASLAnonymousConnect();
             peer.expectOpen().respond();
@@ -2395,7 +2399,7 @@ public class SenderTest extends ImperativeClientTestCase {
     }
 
     @Test
-    void testWaitForAcceptanceFailsIfRemoteSendsNoDisposition() throws 
Exception {
+    public void testWaitForAcceptanceFailsIfRemoteSendsNoDisposition() throws 
Exception {
         try (ProtonTestServer peer = new ProtonTestServer()) {
             peer.expectSASLAnonymousConnect();
             peer.expectOpen().respond();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to