use of org.apache.kafka.streams.processor.internals.testutil.LogCaptureAppender in project kafka by apache.
the class AdjustStreamThreadCountTest method shouldResizeCacheAfterThreadRemovalTimesOut.
@Test
public void shouldResizeCacheAfterThreadRemovalTimesOut() throws InterruptedException {
final long totalCacheBytes = 10L;
final Properties props = new Properties();
props.putAll(properties);
props.put(StreamsConfig.NUM_STREAM_THREADS_CONFIG, 2);
props.put(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG, totalCacheBytes);
try (final KafkaStreams kafkaStreams = new KafkaStreams(builder.build(), props)) {
addStreamStateChangeListener(kafkaStreams);
startStreamsAndWaitForRunning(kafkaStreams);
try (final LogCaptureAppender appender = LogCaptureAppender.createAndRegister(KafkaStreams.class)) {
assertThrows(TimeoutException.class, () -> kafkaStreams.removeStreamThread(Duration.ofSeconds(0)));
for (final String log : appender.getMessages()) {
// all 10 bytes should be available for remaining thread
if (log.endsWith("Resizing thread cache due to thread removal, new cache size per thread is 10")) {
return;
}
}
}
}
fail();
}
use of org.apache.kafka.streams.processor.internals.testutil.LogCaptureAppender in project kafka by apache.
the class StreamsConfigTest method shouldLogWarningWhenRetriesIsUsed.
@SuppressWarnings("deprecation")
@Test
public void shouldLogWarningWhenRetriesIsUsed() {
props.put(StreamsConfig.RETRIES_CONFIG, 0);
LogCaptureAppender.setClassLoggerToDebug(StreamsConfig.class);
try (final LogCaptureAppender appender = LogCaptureAppender.createAndRegister(StreamsConfig.class)) {
new StreamsConfig(props);
assertThat(appender.getMessages(), hasItem("Configuration parameter `" + StreamsConfig.RETRIES_CONFIG + "` is deprecated and will be removed in the 4.0.0 release."));
}
}
use of org.apache.kafka.streams.processor.internals.testutil.LogCaptureAppender in project kafka by apache.
the class StoreChangelogReaderTest method shouldNotThrowOnUnknownRevokedPartition.
@Test
public void shouldNotThrowOnUnknownRevokedPartition() {
LogCaptureAppender.setClassLoggerToDebug(StoreChangelogReader.class);
try (final LogCaptureAppender appender = LogCaptureAppender.createAndRegister(StoreChangelogReader.class)) {
changelogReader.unregister(Collections.singletonList(new TopicPartition("unknown", 0)));
assertThat(appender.getMessages(), hasItem("test-reader Changelog partition unknown-0 could not be found," + " it could be already cleaned up during the handling of task corruption and never restore again"));
}
}
use of org.apache.kafka.streams.processor.internals.testutil.LogCaptureAppender in project kafka by apache.
the class InternalTopicManagerTest method shouldLogWhenTopicNotFoundAndNotThrowException.
@Test
public void shouldLogWhenTopicNotFoundAndNotThrowException() {
mockAdminClient.addTopic(false, topic1, Collections.singletonList(new TopicPartitionInfo(0, broker1, cluster, Collections.emptyList())), null);
final InternalTopicConfig internalTopicConfig = new RepartitionTopicConfig(topic1, Collections.emptyMap());
internalTopicConfig.setNumberOfPartitions(1);
final InternalTopicConfig internalTopicConfigII = new RepartitionTopicConfig("internal-topic", Collections.emptyMap());
internalTopicConfigII.setNumberOfPartitions(1);
final Map<String, InternalTopicConfig> topicConfigMap = new HashMap<>();
topicConfigMap.put(topic1, internalTopicConfig);
topicConfigMap.put("internal-topic", internalTopicConfigII);
LogCaptureAppender.setClassLoggerToDebug(InternalTopicManager.class);
try (final LogCaptureAppender appender = LogCaptureAppender.createAndRegister(InternalTopicManager.class)) {
internalTopicManager.makeReady(topicConfigMap);
assertThat(appender.getMessages(), hasItem("stream-thread [" + threadName + "] Topic internal-topic is unknown or not found, hence not existed yet.\n" + "Error message was: org.apache.kafka.common.errors.UnknownTopicOrPartitionException: Topic internal-topic not found."));
}
}
use of org.apache.kafka.streams.processor.internals.testutil.LogCaptureAppender in project kafka by apache.
the class StateDirectoryTest method shouldLogManualUserCallMessage.
@Test
public void shouldLogManualUserCallMessage() {
final TaskId taskId = new TaskId(0, 0);
final File taskDirectory = directory.getOrCreateDirectoryForTask(taskId);
final File testFile = new File(taskDirectory, "testFile");
assertThat(testFile.mkdir(), is(true));
assertThat(directory.directoryForTaskIsEmpty(taskId), is(false));
try (final LogCaptureAppender appender = LogCaptureAppender.createAndRegister(StateDirectory.class)) {
directory.clean();
assertThat(appender.getMessages(), hasItem(endsWith("as user calling cleanup.")));
}
}
Aggregations