xjrk58 commented on code in PR #24310:
URL: https://github.com/apache/kafka/pull/24310#discussion_r4676955640
##########
streams/test-utils/src/test/java/org/apache/kafka/streams/TopologyTestDriverTest.java:
##########
@@ -452,6 +459,147 @@ public void shouldCloseProcessor() {
testDriver = null;
}
+ @Test
+ public void shouldCloseStateStoreWhenProcessorFailsToInitialize() {
+ final Topology topology = new Topology();
+ topology.addSource("source", SOURCE_TOPIC_1);
+ topology.addProcessor("processor", failingProcessorSupplier("store"),
"source");
+ topology.addStateStore(
+
Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore("store"),
Serdes.String(), Serdes.Long()),
+ "processor");
+
+ assertThrows(StreamsException.class, () -> new
TopologyTestDriverBuilder(topology).withConfig(config).build());
+
+ assertFalse(store.isOpen());
+ assertFalse(stateDirectory().exists());
+ }
+
+ @Test
+ public void
shouldCloseGlobalStateStoreWhenProcessorFailsToInitializeOnRestore() {
+ final Topology topology = new Topology();
+ topology.addGlobalStore(
+
Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore("globalStore"),
Serdes.String(), Serdes.Long())
+ .withLoggingDisabled(),
+ "source",
+ new StringDeserializer(),
+ new LongDeserializer(),
+ SOURCE_TOPIC_1,
+ "processor",
+ failingProcessorSupplier("globalStore"));
+
+ assertThrows(IllegalStateException.class, () -> new
TopologyTestDriverBuilder(topology).withConfig(config).build());
+
+ assertFalse(store.isOpen());
+ assertFalse(stateDirectory().exists());
+ }
+
+ @Test
+ public void shouldWipeStateDirectoryWhenFirstStateStoreIsCorrupted() {
+ final Topology topology = new Topology();
+ topology.addSource("source", SOURCE_TOPIC_1);
+ topology.addProcessor("corruptedProcessor", new
MockProcessorSupplier(), "source");
+ topology.addStateStore(
+ Stores.keyValueStoreBuilder(
+ // fails as a RocksDB store that is found corrupted when it is
opened, before any store is registered
+ storeSupplier(() -> new
InMemoryKeyValueStore("corruptedStore") {
+ @Override
+ public void init(final StateStoreContext
stateStoreContext, final StateStore root) {
+ throw new
TaskCorruptedException(Set.of(stateStoreContext.taskId()));
+ }
+ }),
+ Serdes.String(),
+ Serdes.Long()),
+ "corruptedProcessor");
+ topology.addProcessor("persistentProcessor", new
MockProcessorSupplier(), "source");
+ topology.addStateStore(
+
Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore("persistentStore"),
Serdes.String(), Serdes.Long()),
+ "persistentProcessor");
+
+ assertThrows(TaskCorruptedException.class, () -> new
TopologyTestDriverBuilder(topology).withConfig(config).build());
Review Comment:
That test only covered the cleaning of the state directory and is removed
together with it. The driver no longer deletes anything itself on a failed
construction, so there is no transactional case left to protect.
--
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]