kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject [kafka] branch 2.2 updated: MINOR: improve stabilty of ProcessorStateManagerTest (#6240)
Date Fri, 08 Feb 2019 21:48:45 GMT
This is an automated email from the ASF dual-hosted git repository.

guozhang pushed a commit to branch 2.2
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.2 by this push:
     new c823204  MINOR: improve stabilty of ProcessorStateManagerTest (#6240)
c823204 is described below

commit c823204ee5edda3b5ebe56df17c1a96b88e08383
Author: Matthias J. Sax <mjsax@apache.org>
AuthorDate: Fri Feb 8 13:47:53 2019 -0800

    MINOR: improve stabilty of ProcessorStateManagerTest (#6240)
    
    This PR addressed the following test failure:
    
    ```
    java.lang.AssertionError:
    Expected: a string starting with "process-state-manager-test Failed to write offset checkpoint
file to ["
    but: was "[AdminClient clientId=adminclient-874] Connection to node -1 (localhost/127.0.0.1:8080)
could not be established. Broker may not be available."
    ```
    
    Reviewers: Bill Bejeck <bill@confluent.io>, John Roesler <john@confluent.io>,
Guozhang Wang <guozhang@confluent.io>
---
 .../internals/ProcessorStateManagerTest.java         | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/streams/src/test/java/org/apache/kafka/streams/processor/internals/ProcessorStateManagerTest.java
b/streams/src/test/java/org/apache/kafka/streams/processor/internals/ProcessorStateManagerTest.java
index ce76749..119790f 100644
--- a/streams/src/test/java/org/apache/kafka/streams/processor/internals/ProcessorStateManagerTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/processor/internals/ProcessorStateManagerTest.java
@@ -53,9 +53,7 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static java.util.Collections.singletonList;
-import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertEquals;
@@ -619,14 +617,18 @@ public class ProcessorStateManagerTest {
         stateMgr.checkpoint(Collections.singletonMap(persistentStorePartition, 10L));
         LogCaptureAppender.unregister(appender);
 
-        final List<LogCaptureAppender.Event> messages = appender.getEvents();
+        boolean foundExpectedLogMessage = false;
+        for (final LogCaptureAppender.Event event : appender.getEvents()) {
+            if ("WARN".equals(event.getLevel())
+                && event.getMessage().startsWith("process-state-manager-test Failed
to write offset checkpoint file to [")
+                && event.getMessage().endsWith(".checkpoint]")
+                && event.getThrowableInfo().get().startsWith("java.io.FileNotFoundException:
")) {
 
-        final LogCaptureAppender.Event lastEvent = messages.get(messages.size() - 1);
-
-        assertThat(lastEvent.getLevel(), is("WARN"));
-        assertThat(lastEvent.getMessage(), startsWith("process-state-manager-test Failed
to write offset checkpoint file to ["));
-        assertThat(lastEvent.getMessage(), endsWith(".checkpoint]"));
-        assertThat(lastEvent.getThrowableInfo().get(), startsWith("java.io.FileNotFoundException:
"));
+                foundExpectedLogMessage = true;
+                break;
+            }
+        }
+        assertTrue(foundExpectedLogMessage);
     }
 
     @Test


Mime
View raw message