Browse Source

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>
pull/5770/merge
Matthias J. Sax 6 years ago committed by Guozhang Wang
parent
commit
2fb9b03d6f
  1. 20
      streams/src/test/java/org/apache/kafka/streams/processor/internals/ProcessorStateManagerTest.java

20
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 java.util.concurrent.atomic.AtomicBoolean;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -619,14 +617,18 @@ public class ProcessorStateManagerTest {
stateMgr.checkpoint(Collections.singletonMap(persistentStorePartition, 10L)); stateMgr.checkpoint(Collections.singletonMap(persistentStorePartition, 10L));
LogCaptureAppender.unregister(appender); 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); foundExpectedLogMessage = true;
break;
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]")); assertTrue(foundExpectedLogMessage);
assertThat(lastEvent.getThrowableInfo().get(), startsWith("java.io.FileNotFoundException: "));
} }
@Test @Test

Loading…
Cancel
Save