You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by tk...@apache.org on 2024/02/28 11:17:17 UTC

(ignite-3) branch main updated: IGNITE-21616 Fix ClientLoggingTest.testBasicLogging (#3308)

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

tkalkirill pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new d70b18af4e IGNITE-21616 Fix ClientLoggingTest.testBasicLogging (#3308)
d70b18af4e is described below

commit d70b18af4ea67700f45c606e405c566ab2e8d858
Author: Roman Puchkovskiy <ro...@gmail.com>
AuthorDate: Wed Feb 28 15:17:10 2024 +0400

    IGNITE-21616 Fix ClientLoggingTest.testBasicLogging (#3308)
---
 .../test/java/org/apache/ignite/client/ClientLoggingTest.java  |  4 ++--
 .../test/java/org/apache/ignite/client/TestLoggerFactory.java  | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java
index a80bf0a79b..d199d58db0 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java
@@ -99,8 +99,8 @@ public class ClientLoggingTest extends BaseIgniteAbstractTest {
             client.tables().table("t");
 
             loggerFactory.waitForLogContains("Connection established", 5000);
-            loggerFactory.waitForLogContains("c:Sending request [opCode=3, remoteAddress=127.0.0.1:", 5000);
-            loggerFactory.waitForLogContains("c:Failed to establish connection to 127.0.0.1:43210", 5000);
+            loggerFactory.waitForLogContains("c:Sending request [opCode=3, remoteAddress=127.0.0.1", 5000);
+            loggerFactory.waitForLogMatches(".*c:Failed to establish connection to 127\\.0\\.0\\.1(/<unresolved>)?:43210.*", 5000);
         }
     }
 
diff --git a/modules/client/src/test/java/org/apache/ignite/client/TestLoggerFactory.java b/modules/client/src/test/java/org/apache/ignite/client/TestLoggerFactory.java
index 468aa75562..a8f3f13866 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/TestLoggerFactory.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/TestLoggerFactory.java
@@ -52,10 +52,20 @@ public class TestLoggerFactory implements LoggerFactory {
                 () -> "Log does not contain expected message '" + msg + "': " +  log());
     }
 
+    void waitForLogMatches(String regex, long timeoutMillis) throws InterruptedException {
+        assertTrue(
+                IgniteTestUtils.waitForCondition(() -> logLineMatches(regex), timeoutMillis),
+                () -> "Log does not match expected pattern '" + regex + "': " +  log());
+    }
+
     private boolean logContains(String msg) {
         return logger.entries().stream().anyMatch(x -> x.contains(msg));
     }
 
+    private boolean logLineMatches(String regex) {
+        return logger.entries().stream().anyMatch(x -> x.matches(regex));
+    }
+
     private String log() {
         return String.join("\n", logger.entries());
     }