jsancio commented on code in PR #16637:
URL: https://github.com/apache/kafka/pull/16637#discussion_r1691540063
##########
raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java:
##########
@@ -2762,79 +2764,357 @@ public void testDescribeQuorumNonLeader(boolean
withKip853Rpc) throws Exception
assertEquals(Errors.NOT_LEADER_OR_FOLLOWER.message(),
partitionData.errorMessage());
}
+ @Test
+ public void testDescribeQuorumWithOnlyStaticVoters() throws Exception {
+ int localId = 0;
+ ReplicaKey local = replicaKey(localId, true);
+ ReplicaKey follower1 = replicaKey(1, true);
+ Set<Integer> voters = Utils.mkSet(localId, follower1.id());
+
+ RaftClientTestContext context = new
RaftClientTestContext.Builder(localId, local.directoryId().get())
+ .withStaticVoters(voters)
+ .withKip853Rpc(true)
+ .build();
+
+ context.becomeLeader();
+ int epoch = context.currentEpoch();
+
+ // Describe quorum response will not include directory ids
+ context.deliverRequest(context.describeQuorumRequest());
+ context.pollUntilResponse();
+ List<ReplicaState> expectedVoterStates = Arrays.asList(
+ new ReplicaState()
+ .setReplicaId(localId)
+ .setReplicaDirectoryId(ReplicaKey.NO_DIRECTORY_ID)
+ .setLogEndOffset(1L)
+ .setLastFetchTimestamp(context.time.milliseconds())
+ .setLastCaughtUpTimestamp(context.time.milliseconds()),
+ new ReplicaState()
+ .setReplicaId(follower1.id())
+ .setReplicaDirectoryId(ReplicaKey.NO_DIRECTORY_ID)
+ .setLogEndOffset(-1L)
+ .setLastFetchTimestamp(-1)
+ .setLastCaughtUpTimestamp(-1));
+ context.assertSentDescribeQuorumResponse(localId, epoch, -1L,
expectedVoterStates, Collections.emptyList());
+ }
+
+
@ParameterizedTest
@ValueSource(booleans = { true, false })
- public void testDescribeQuorum(boolean withKip853Rpc) throws Exception {
- int localId = randomReplicaId();
- ReplicaKey closeFollower = replicaKey(localId + 2, withKip853Rpc);
- ReplicaKey laggingFollower = replicaKey(localId + 1, withKip853Rpc);
- Set<Integer> voters = Utils.mkSet(localId, closeFollower.id(),
laggingFollower.id());
-
- RaftClientTestContext context = new
RaftClientTestContext.Builder(localId, voters)
- .withKip853Rpc(withKip853Rpc)
- .build();
+ public void testDescribeQuorumWithFollowers(boolean withKip853Rpc) throws
Exception {
+ int localId = 0;
+ ReplicaKey local = replicaKey(localId, true);
+ Uuid localDirectoryId = local.directoryId().get();
+ ReplicaKey follower1 = replicaKey(1, true);
+ Uuid followerDirectoryId1 = follower1.directoryId().get();
+ ReplicaKey follower2 = replicaKey(2, false);
+ Set<Integer> voters = Utils.mkSet(localId, follower1.id(),
follower2.id());
+ VoterSet voterSet = VoterSetTest.voterSet(Stream.of(local, follower1,
follower2));
+
+ RaftClientTestContext.Builder builder = new
RaftClientTestContext.Builder(localId, localDirectoryId)
+ .withStaticVoters(voters)
+ .withKip853Rpc(withKip853Rpc);
+
+ if (withKip853Rpc) {
+ builder.withBootstrapSnapshot(Optional.of(voterSet));
Review Comment:
Yes. If you want to test that case it should be an explicit tests. Having
said that, supporting both static voter and bootstrap voters has nothing to do
with the DescribeQuorum RPC.
--
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]