jsancio commented on code in PR #16563:
URL: https://github.com/apache/kafka/pull/16563#discussion_r1676026264
##########
raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java:
##########
@@ -746,9 +764,9 @@ public void
testCannotResignWithLargerEpochThanCurrentEpoch(boolean withKip853Rp
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void testCannotResignIfNotLeader(boolean withKip853Rpc) throws
Exception {
- int localId = 0;
- int otherNodeId = 1;
- int leaderEpoch = 2;
+ int localId = randomReplicaId();
+ int otherNodeId = localId + 1;
+ int leaderEpoch = localId + 2;
Review Comment:
The leader epoch should stay as 2. No need to randomize the leader epoch for
now. E.g. `int leaderEpoch = 2;`.
##########
raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java:
##########
@@ -3768,8 +3779,8 @@ public void
testHandleLeaderChangeFiresAfterFollowerRegistration(boolean withKip
public void testObserverFetchWithNoLocalId(boolean withKip853Rpc) throws
Exception {
// When no `localId` is defined, the client will behave as an observer.
// This is designed for tooling/debugging use cases.
-
- Set<Integer> voters = Utils.mkSet(1, 2);
+ int localId = randomReplicaId();
Review Comment:
The local replica doesn't have an id. Notice that this test has `new
RaftClientTestContext.Builder(OptionalInt.empty(), ...)`.
You can change this line to `int leaderId = randomReplicaId()`, remove the
line below `int leaderId = localId` and replace all usage of `localId` with
`leaderId`.
##########
raft/src/test/java/org/apache/kafka/raft/RaftClientTestContext.java:
##########
@@ -759,7 +774,12 @@ void assertSentBeginQuorumEpochResponse(
assertEquals(epoch, partitionResponse.leaderEpoch());
assertEquals(leaderId.orElse(-1), partitionResponse.leaderId());
- assertEquals(partitionError,
Errors.forCode(partitionResponse.errorCode()));
+ assertEquals(
+ partitionError,
+ Errors.forCode(partitionResponse.errorCode()),
+ "Lead Id: " + leaderId +
+ " Partition response leader Id: " +
partitionResponse.leaderId()
Review Comment:
I think this is the correct indentation.
```java
"Lead Id: " + leaderId +
" Partition response leader Id: " + partitionResponse.leaderId()
```
##########
raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java:
##########
@@ -929,9 +951,9 @@ public void testHandleBeginQuorumRequest(boolean
withKip853Rpc) throws Exception
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void testHandleBeginQuorumResponse(boolean withKip853Rpc) throws
Exception {
- int localId = 0;
- int otherNodeId = 1;
- int leaderEpoch = 2;
+ int localId = randomReplicaId();
+ int otherNodeId = localId + 1;
+ int leaderEpoch = localId + 2;
Review Comment:
The leader epoch should stay as 2. No need to randomize the leader epoch for
now. E.g. `int leaderEpoch = 2;`.
--
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]