chia7712 commented on code in PR #16291:
URL: https://github.com/apache/kafka/pull/16291#discussion_r1635556134


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/CommitRequestManagerTest.java:
##########
@@ -122,6 +123,48 @@ public void setup() {
         this.props.put(VALUE_DESERIALIZER_CLASS_CONFIG, 
StringDeserializer.class);
     }
 
+    @Test
+    public void testOffsetFetchRequestStateToStringBase() {
+        ConsumerConfig config = mock(ConsumerConfig.class);
+        CommitRequestManager.MemberInfo memberInfo = new 
CommitRequestManager.MemberInfo();
+
+        CommitRequestManager commitRequestManager = new CommitRequestManager(
+                time,
+                logContext,
+                subscriptionState,
+                config,
+                coordinatorRequestManager,
+                offsetCommitCallbackInvoker,
+                "groupId",
+                Optional.of("groupInstanceId"),
+                metrics);
+
+        commitRequestManager.onMemberEpochUpdated(Optional.of(1), 
Optional.empty());
+        Set<TopicPartition> requestedPartitions = Collections.singleton(new 
TopicPartition("topic-1", 1));
+
+        CommitRequestManager.OffsetFetchRequestState offsetFetchRequestState = 
commitRequestManager.new OffsetFetchRequestState(
+                requestedPartitions,
+                retryBackoffMs,
+                retryBackoffMaxMs,
+                1000,
+                memberInfo);

Review Comment:
   in the line#142 - The `memberInfo`  updated by `onMemberEpochUpdated` is the 
inner variable of `commitRequestManager`. Hence, this `memberInfo` used to 
create `OffsetFetchRequestState` is NOT updated by `onMemberEpochUpdated`
   
   If we want to complete the test, maybe we can remove `MemberInfo` from 
constructor of `OffsetFetchRequestState`. After all, both 
`RetriableRequestState` and `OffsetFetchRequestState` are the inner class of 
`CommitRequestManager`, so it is valid to share the `MemberInfo` between those 
classes.



##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/CommitRequestManagerTest.java:
##########
@@ -122,6 +123,48 @@ public void setup() {
         this.props.put(VALUE_DESERIALIZER_CLASS_CONFIG, 
StringDeserializer.class);
     }
 
+    @Test
+    public void testOffsetFetchRequestStateToStringBase() {
+        ConsumerConfig config = mock(ConsumerConfig.class);
+        CommitRequestManager.MemberInfo memberInfo = new 
CommitRequestManager.MemberInfo();
+
+        CommitRequestManager commitRequestManager = new CommitRequestManager(
+                time,
+                logContext,
+                subscriptionState,
+                config,
+                coordinatorRequestManager,
+                offsetCommitCallbackInvoker,
+                "groupId",
+                Optional.of("groupInstanceId"),
+                metrics);
+
+        commitRequestManager.onMemberEpochUpdated(Optional.of(1), 
Optional.empty());
+        Set<TopicPartition> requestedPartitions = Collections.singleton(new 
TopicPartition("topic-1", 1));
+
+        CommitRequestManager.OffsetFetchRequestState offsetFetchRequestState = 
commitRequestManager.new OffsetFetchRequestState(
+                requestedPartitions,
+                retryBackoffMs,
+                retryBackoffMaxMs,
+                1000,
+                memberInfo);
+
+        TimedRequestState timedRequestState = new TimedRequestState(
+                logContext,
+                "CommitRequestManager",
+                retryBackoffMs,
+                retryBackoffMaxMs,
+                TimedRequestState.deadlineTimer(time, 0)
+        );
+
+        String target = timedRequestState.toStringBase() +
+                ", " + memberInfo +
+                ", requestedPartitions=" + 
offsetFetchRequestState.requestedPartitions;
+
+        assertDoesNotThrow(timedRequestState::toString);
+        assertEquals(target, offsetFetchRequestState.toStringBase());
+    }

Review Comment:
   Maybe we can add `assertFalse(target.contains("Optional"));` to make sure we 
unwrap the optional variables?



-- 
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]

Reply via email to