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

yong pushed a commit to branch branch-4.15
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git

commit 2144ac321f0ba25f713b6c3bd247172bf5387c08
Author: wenbingshen <[email protected]>
AuthorDate: Mon Oct 24 09:53:27 2022 +0800

    fix flaky-test testWriteSetWriteableCheck (#3555)
    
    ### Motivation
     `testWriteSetWriteableCheck` always failed. After investigation, it is 
found that `isWritable=false` is set when the simulated channel is not 
writable, but the unit test cannot fully perceive the channel establishment, 
because the channel is completely established asynchronously. The isWritable 
state of false is changed to true again.
    
    you can see the following logs:
    
![image](https://user-images.githubusercontent.com/35599757/196625314-0ea5a305-9564-4738-8055-20baa6a5c5a2.png)
    
    The smallest change is that we can ensure that the channel is established 
before changing the channel state, such as executing `bkc.getBookieInfo()`, and 
then `setTargetChannelState`
    
    (cherry picked from commit c76e549fc93efb290adac9f7e295f44145772670)
---
 .../src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
index b8e5d2495d..9decf67ce7 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
@@ -323,6 +323,10 @@ public class SlowBookieTest extends 
BookKeeperClusterTestCase {
             // b2 or b3 is no more writeable
             int slowBookieIndex = 
writeSet.get(ThreadLocalRandom.current().nextInt(writeSet.size()));
             List<BookieId> curEns = lh.getCurrentEnsemble();
+
+            // Trigger connection to the bookie service first
+            bkc.getBookieInfo().get(curEns.get(slowBookieIndex));
+            // then mock channel is not writable
             setTargetChannelState(bkc, curEns.get(slowBookieIndex), 0, false);
 
             boolean isWriteable = lh.waitForWritable(writeSet, 0, 1000);

Reply via email to