UladzislauBlok commented on code in PR #23390:
URL: https://github.com/apache/kafka/pull/23390#discussion_r3951509012
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/GlobalStreamThreadTest.java:
##########
@@ -292,6 +296,60 @@ public Set<TopicPartition> partitions() {
assertFalse(new File(baseDirectoryName + File.separator + "testAppId"
+ File.separator + "global").exists());
}
+ @Test
+ public void
shouldWipeGlobalStateDirectoryOnTaskCorruptedExceptionDuringStartup() throws
Exception {
+ final InternalTopologyBuilder corruptedBuilder = new
InternalTopologyBuilder();
Review Comment:
This builder is not corrupted :)
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/GlobalStreamThreadTest.java:
##########
@@ -292,6 +296,60 @@ public Set<TopicPartition> partitions() {
assertFalse(new File(baseDirectoryName + File.separator + "testAppId"
+ File.separator + "global").exists());
}
+ @Test
+ public void
shouldWipeGlobalStateDirectoryOnTaskCorruptedExceptionDuringStartup() throws
Exception {
+ final InternalTopologyBuilder corruptedBuilder = new
InternalTopologyBuilder();
+
+ final ProcessorSupplier<Object, Object, Void, Void> processorSupplier
= () ->
+ new ContextualProcessor<>() {
+ @Override
+ public void process(final Record<Object, Object> record) {
+ }
+ };
+
+ corruptedBuilder.addGlobalStore(
+ "sourceName",
+ null,
+ null,
+ null,
+ GLOBAL_STORE_TOPIC_NAME,
+ "processorName",
+ new StoreDelegatingProcessorSupplier<>(
+ processorSupplier,
+ Set.of(new CorruptedStoreBuilder())
+ ),
+ false
+ );
+
+ globalStreamThread = new GlobalStreamThread(
+
corruptedBuilder.rewriteTopology(config).buildGlobalStateTopology(),
+ config,
+ mockConsumer,
+ new StateDirectory(config, time, true, false),
+ 0,
+ -1L,
+ new StreamsMetricsImpl(new Metrics(), "test-client", time),
+ time,
+ "clientId",
+ stateRestoreListener,
+ e -> { }
+ );
+
+ final File globalStateDir =
+ new File(baseDirectoryName + File.separator + "testAppId" +
File.separator + "global");
+
+ initializeConsumer();
+
+ assertThrows(
+ StreamsException.class,
+ () -> globalStreamThread.start(),
+ "Should have thrown StreamsException if start up failed."
+ );
+ globalStreamThread.join();
Review Comment:
formatting doesn't look particularly right. Can you run spotless?
`./gradlew spotlessApply`
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/GlobalStreamThreadTest.java:
##########
@@ -493,4 +551,72 @@ private void startAndSwallowError() {
} catch (final IllegalStateException ignored) {
}
}
+
+ private static class CorruptedStore implements StateStore {
Review Comment:
this is a lot of code. May be we can just mock store, instead of fully
implement it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]