You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2024/02/11 10:32:03 UTC

(plc4x) branch fix/flaky-tranaction-manager-test created (now 7c2d2c4913)

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

cdutz pushed a change to branch fix/flaky-tranaction-manager-test
in repository https://gitbox.apache.org/repos/asf/plc4x.git


      at 7c2d2c4913 fix: Tried fixing the flaky test.

This branch includes the following new commits:

     new 7c2d2c4913 fix: Tried fixing the flaky test.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(plc4x) 01/01: fix: Tried fixing the flaky test.

Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch fix/flaky-tranaction-manager-test
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 7c2d2c4913382faae336cd080b9a2cb28cd54712
Author: Christofer Dutz <cd...@apache.org>
AuthorDate: Sun Feb 11 11:31:55 2024 +0100

    fix: Tried fixing the flaky test.
---
 .../java/spi/optimizer/RequestTransactionManagerTest.java    | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/optimizer/RequestTransactionManagerTest.java b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/optimizer/RequestTransactionManagerTest.java
index 820eda9ee1..f8a862fdc3 100644
--- a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/optimizer/RequestTransactionManagerTest.java
+++ b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/optimizer/RequestTransactionManagerTest.java
@@ -132,23 +132,25 @@ public class RequestTransactionManagerTest {
         RequestTransactionManager tm = new RequestTransactionManager();
         RequestTransactionManager.RequestTransaction handle = tm.startRequest();
         handle.submit(() -> {
-            // ...
+            // Completing this future simulates "having sent the request" and
+            // it makes the main test continue.
             sendRequest.complete(null);
-            // Receive
             receiveResponse.thenAccept((n) -> {
+                // Receive (This code should actually never be run)
                 handle.endRequest();
                 transactionIsFinished.complete(null);
             });
         });
 
-        // Assert that there is a request going on
+        // Wait until the sendRequest future is completed inside the transaction.
         sendRequest.get();
 
-        // Exception case
+        // Now fail the transaction (Simulating anything going wrong while processing it)
         handle.failRequest(new RuntimeException());
 
         // Wait that the fail is handled internally surely
-        Thread.sleep(100);
+        // Commented out, as all operations in "failRequest" are executed immediately.
+        //Thread.sleep(100);
 
         // Assert that no requests are active
         assertEquals(0, tm.getNumberOfActiveRequests());