@@ -914,11 +914,9 @@ private void initMetadata(MockClient mockClient, Map<String, Integer> partitionC
914
914
mockClient .updateMetadata (initialMetadata );
915
915
}
916
916
917
- // TODO: this test triggers a bug with the CONSUMER group protocol implementation.
918
- // The bug will be investigated and fixed so this test can use both group protocols.
919
917
@ ParameterizedTest
920
- @ EnumSource (value = GroupProtocol .class , names = "CLASSIC" )
921
- public void testMissingOffsetNoResetPolicy (GroupProtocol groupProtocol ) {
918
+ @ EnumSource (value = GroupProtocol .class )
919
+ public void testMissingOffsetNoResetPolicy (GroupProtocol groupProtocol ) throws InterruptedException {
922
920
SubscriptionState subscription = new SubscriptionState (new LogContext (), OffsetResetStrategy .NONE );
923
921
ConsumerMetadata metadata = createMetadata (subscription );
924
922
MockClient client = new MockClient (time , metadata );
@@ -935,7 +933,22 @@ public void testMissingOffsetNoResetPolicy(GroupProtocol groupProtocol) {
935
933
936
934
// lookup committed offset and find nothing
937
935
client .prepareResponseFrom (offsetResponse (Collections .singletonMap (tp0 , -1L ), Errors .NONE ), coordinator );
938
- assertThrows (NoOffsetForPartitionException .class , () -> consumer .poll (Duration .ZERO ));
936
+
937
+ if (groupProtocol == GroupProtocol .CONSUMER ) {
938
+ // New consumer poll(ZERO) needs to wait for the offset fetch event added by a call to poll, to be processed
939
+ // by the background thread, so it can realize there are no committed offsets and then
940
+ // throw the NoOffsetForPartitionException
941
+ TestUtils .waitForCondition (() -> {
942
+ try {
943
+ consumer .poll (Duration .ZERO );
944
+ return false ;
945
+ } catch (NoOffsetForPartitionException e ) {
946
+ return true ;
947
+ }
948
+ }, "Consumer was not able to update fetch positions on continuous calls with 0 timeout" );
949
+ } else {
950
+ assertThrows (NoOffsetForPartitionException .class , () -> consumer .poll (Duration .ZERO ));
951
+ }
939
952
}
940
953
941
954
@ ParameterizedTest
0 commit comments