mjsax commented on code in PR #18115:
URL: https://github.com/apache/kafka/pull/18115#discussion_r1880746671
##########
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/FineGrainedAutoResetIntegrationTest.java:
##########
@@ -251,14 +263,108 @@ private void commitInvalidOffsets() {
consumer.close();
}
+ @Test
+ public void shouldFailForResetNone() throws Exception {
+ final Properties props = new Properties();
+ props.put(ConsumerConfig.METADATA_MAX_AGE_CONFIG, "1000");
+
+ final Properties localConfig = StreamsTestUtils.getStreamsConfig(
+ "testConfigAutoOffsetWithNone",
+ CLUSTER.bootstrapServers(),
+ STRING_SERDE_CLASSNAME,
+ STRING_SERDE_CLASSNAME,
+ props);
+
+ final StreamsBuilder builder = new StreamsBuilder();
+ final KStream<String, String> exceptionStream = builder.stream(NOOP,
Consumed.with(AutoOffsetReset.none()));
+
+ exceptionStream.to(DEFAULT_OUTPUT_TOPIC, Produced.with(stringSerde,
stringSerde));
+
+ try (final KafkaStreams streams = new KafkaStreams(builder.build(),
localConfig)) {
+ final TestingUncaughtExceptionHandler uncaughtExceptionHandler =
new TestingUncaughtExceptionHandler();
+ streams.setUncaughtExceptionHandler(uncaughtExceptionHandler);
+
+ streams.start();
+
+ waitForCondition(
+ () -> uncaughtExceptionHandler.correctExceptionThrown,
+ "The expected NoOffsetForPartitionException was never thrown"
+ );
+ }
+ }
+
+ @Test
+ public void shouldResetByDuration() throws Exception {
+ final StreamsBuilder builder = new StreamsBuilder();
+
+ builder.<String, String>stream(TOPIC_DURATION_1,
Consumed.with(AutoOffsetReset.byDuration(Duration.ofHours(6L).plus(Duration.ofMinutes(40L)))))
+ .to(OUTPUT_TOPIC_3, Produced.with(stringSerde, stringSerde));
+ builder.<String, String>stream(TOPIC_DURATION_2,
Consumed.with(AutoOffsetReset.byDuration(Duration.ofMillis(mockTime.milliseconds()).minus(Duration.ofDays(1L)))))
+ .to(OUTPUT_TOPIC_4, Produced.with(stringSerde, stringSerde));
+ builder.<String, String>stream(TOPIC_DURATION_3,
Consumed.with(AutoOffsetReset.byDuration(Duration.ZERO)))
+ .to(OUTPUT_TOPIC_5, Produced.with(stringSerde, stringSerde));
+
+ final Properties producerConfig =
TestUtils.producerConfig(CLUSTER.bootstrapServers(), StringSerializer.class,
StringSerializer.class);
+
+ for (int i = 0; i < 10; ++i) {
+ mockTime.sleep(Duration.ofHours(1L).toMillis());
Review Comment:
This is mock time, so there is no actual sleep. This test run just few
seconds locally.
I used "an hour" because there is still some jitter (even with mock time),
to ensure the test is stable.
--
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]