Skip to content

Conversation

@RaidenE1
Copy link
Contributor

@RaidenE1 RaidenE1 commented Aug 12, 2025

The test uses regular consumer to commit offsets. New protocol requires
a streams consumer since we are using streams groups, otherwise we run
into group ID conflicts.

Followed the addition of the KafkaAdmin interface for setting offsets, a
Kafka Admin client is created and used the interface in to set the
committed offsets instead of instantiating a consumer.

Also enable all tests for stream new protocol.

Reviewers: Alieh Saeediasaeedi@confluent.io, Kirk True
ktrue@confluent.io, Matthias Sax mjsax@apache.org, Bill Bejeck
bbejeck@apache.org

@github-actions github-actions bot added triage PRs from the community streams tests Test fixes (including flaky tests) small Small PRs labels Aug 12, 2025
Copy link
Contributor

@aliehsaeedii aliehsaeedii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @RaidenE1. Except calling streams-related admin API, I don't see any other concern.


consumer.commitSync();
consumer.close();
admin.alterConsumerGroupOffsets(appId, offsetsToCommit).all().get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please call admin.alterStreamsGroupOffsets

Copy link
Contributor

@kirktrue kirktrue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @RaidenE1!

Any reason to re-throw the failure in setCommittedOffset() vs. calling fail() directly?

Comment on lines 141 to 143
if (admin != null) {
admin.close();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: there's a utility method in Kafka called Utils.closeQuietly() which can make closing resources a one-liner.

@mjsax mjsax added ci-approved and removed triage PRs from the community labels Aug 13, 2025

consumer.commitSync();
consumer.close();
admin.alterStreamsGroupOffsets(appId, offsetsToCommit).all().get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to make this configurable? If the test runs with classic protocol we would still need to use the corresponding consumer group admit-call?

In general, it seems that the whole test must be parametrized, to run with both classic and streams protocol? Atm, it seem that the test is only running with classic, and thus using this streams specific call, should actually break the test?

@github-actions github-actions bot removed the small Small PRs label Aug 13, 2025

consumer.commitSync();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be an else here?

@ParameterizedTest
@ValueSource(booleans = {true, false})
public void shouldRestoreStateFromSourceTopicForReadOnlyStore(final boolean stateUpdaterEnabled) throws Exception {
@CsvSource({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do the same for all other test case, like shouldRestoreNullRecord above. There is 8 test methods I did not miscount, but you enable the new protocol only for two.

Copy link
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @RaidenE1 I've made a pass


if (useNewProtocol) {
// For new protocol, we need to stop the streams instance before altering offsets
kafkaStreams.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to use close(Duration timeout) overload, otherwise the test can get stuck

}
});
kafkaStreams.setGlobalStateRestoreListener(new TrackingStateRestoreListener(restored));
kafkaStreams.start();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a IntegrationTestUtils.startApplicationAndWaitUntilRunning(KafkaStreams instance) method you can use that returns your KS instance once it's in a running state which will simplify your logic here - no need for CountDownLatch


// Restart the streams instance with a new startup latch
final CountDownLatch restartLatch = new CountDownLatch(1);
kafkaStreams = new KafkaStreams(builder.build(props), props);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

assertThat(CloseCountingInMemoryStore.numStoresClosed(), equalTo(expectedAfterStreams2Close));
} finally {
streams1.close();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was pre-existing but I have the same comment about closing with the overload that accepts a timeout.


admin.alterStreamsGroupOffsets(appId, offsetsToCommit).all().get();
} catch (final Exception e) {
throw new RuntimeException("Failed to set committed offsets", e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use fail(...._

Copy link
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @RaidenE1! LGTM

@bbejeck bbejeck merged commit b8bd50a into apache:trunk Aug 22, 2025
23 checks passed
@bbejeck
Copy link
Member

bbejeck commented Aug 22, 2025

merged #20347 into trunk

@RaidenE1 RaidenE1 deleted the commit-offset branch September 18, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved streams tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants