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

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 42620fd5c31b34901037045bb93d1649b1301c05
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Mar 26 16:46:21 2021 +0000

    Enable debug logging for intermittently failing tests on CI systems
---
 .../interceptors/TestNonBlockingCoordinator.java   | 100 +++++++++++----------
 1 file changed, 55 insertions(+), 45 deletions(-)

diff --git 
a/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
 
b/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
index 9f9ed42..2927dc4 100644
--- 
a/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
+++ 
b/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
@@ -16,6 +16,9 @@
  */
 package org.apache.catalina.tribes.group.interceptors;
 
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -39,55 +42,62 @@ public class TestNonBlockingCoordinator {
 
     @Before
     public void setUp() throws Exception {
-        log.info("Setup");
-        channels = new GroupChannel[CHANNEL_COUNT];
-        coordinators = new NonBlockingCoordinator[CHANNEL_COUNT];
-        Thread[] threads = new Thread[CHANNEL_COUNT];
-        for ( int i=0; i<CHANNEL_COUNT; i++ ) {
-            channels[i] = new GroupChannel();
-            coordinators[i] = new NonBlockingCoordinator();
-            channels[i].addInterceptor(coordinators[i]);
-            TcpFailureDetector tcpFailureDetector = new TcpFailureDetector();
-            // Double default timeout - mainly for loaded CI systems
-            
tcpFailureDetector.setReadTestTimeout(tcpFailureDetector.getReadTestTimeout() * 
2);
-            channels[i].addInterceptor(tcpFailureDetector);
-            final int j = i;
-            threads[i] = new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        channels[j].start(Channel.DEFAULT);
-                    } catch (Exception x) {
-                        x.printStackTrace();
+        LogManager.getLogManager().getLogger(
+                
"org.apache.catalina.tribes.group.interceptors.NonBlockingCoordinator").setLevel(Level.ALL);
+        try {
+            log.info("Setup");
+            channels = new GroupChannel[CHANNEL_COUNT];
+            coordinators = new NonBlockingCoordinator[CHANNEL_COUNT];
+            Thread[] threads = new Thread[CHANNEL_COUNT];
+            for ( int i=0; i<CHANNEL_COUNT; i++ ) {
+                channels[i] = new GroupChannel();
+                coordinators[i] = new NonBlockingCoordinator();
+                channels[i].addInterceptor(coordinators[i]);
+                TcpFailureDetector tcpFailureDetector = new 
TcpFailureDetector();
+                // Double default timeout - mainly for loaded CI systems
+                
tcpFailureDetector.setReadTestTimeout(tcpFailureDetector.getReadTestTimeout() * 
2);
+                channels[i].addInterceptor(tcpFailureDetector);
+                final int j = i;
+                threads[i] = new Thread() {
+                    @Override
+                    public void run() {
+                        try {
+                            channels[j].start(Channel.DEFAULT);
+                        } catch (Exception x) {
+                            x.printStackTrace();
+                        }
                     }
-                }
-            };
-        }
-        TesterUtil.addRandomDomain(channels);
-        for (int i = 0; i < CHANNEL_COUNT; i++) {
-            threads[i].start();
-        }
-        for (int i = 0; i < CHANNEL_COUNT; i++) {
-            threads[i].join();
-        }
+                };
+            }
+            TesterUtil.addRandomDomain(channels);
+            for (int i = 0; i < CHANNEL_COUNT; i++) {
+                threads[i].start();
+            }
+            for (int i = 0; i < CHANNEL_COUNT; i++) {
+                threads[i].join();
+            }
 
-        // Allow up to 30s for cluster to form once all the nodes have been
-        // started
-        int count = 0;
-        Member member = null;
-        boolean electionComplete = false;
-        while (!electionComplete && count < 300) {
-            electionComplete = true;
-            member = coordinators[0].getCoordinator();
-            if (member == null) {
-                electionComplete = false;
-            } else {
-                for (int i = 0; i < CHANNEL_COUNT; i++) {
-                    electionComplete = electionComplete && 
(member.equals(coordinators[i].getCoordinator()));
+            // Allow up to 30s for cluster to form once all the nodes have been
+            // started
+            int count = 0;
+            Member member = null;
+            boolean electionComplete = false;
+            while (!electionComplete && count < 300) {
+                electionComplete = true;
+                member = coordinators[0].getCoordinator();
+                if (member == null) {
+                    electionComplete = false;
+                } else {
+                    for (int i = 0; i < CHANNEL_COUNT; i++) {
+                        electionComplete = electionComplete && 
(member.equals(coordinators[i].getCoordinator()));
+                    }
                 }
+                Thread.sleep(100);
+                count++;
             }
-            Thread.sleep(100);
-            count++;
+        } finally {
+            LogManager.getLogManager().getLogger(
+                    
"org.apache.catalina.tribes.group.interceptors.NonBlockingCoordinator").setLevel(Level.INFO);
         }
     }
 

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

Reply via email to