@ParameterizedTest
    @MethodSource("partitionChangeRecordVersions")
    public void testEligibleLeaderReplicas_IsrExpandAboveMinISR(short version) {
        PartitionRegistration partition = new PartitionRegistration.Builder()
            .setReplicas(new int[] {1, 2, 3, 4})
            .setDirectories(new Uuid[]{
                Uuid.fromString("CWgRKBKkToGn1HKzNb2qqQ"),
                Uuid.fromString("SCnk7zfSQSmlKqvV702d3A"),
                Uuid.fromString("9tO0QHlJRhimjKfH8m9d8A"),
                Uuid.fromString("JaaqVOxNT2OGVNCCIFA2JQ")
            })
            .setIsr(new int[] {1, 2})
            .setElr(new int[] {3})
            .setLastKnownElr(new int[] {4})
            .setLeader(1)
            .setLeaderRecoveryState(LeaderRecoveryState.RECOVERED)
            .setLeaderEpoch(100)
            .setPartitionEpoch(200)
            .build();
        Uuid topicId = Uuid.fromString("FbrrdcfiR-KC2CPSTHaJrg");
        // Min ISR is 3.
        PartitionChangeBuilder builder = new PartitionChangeBuilder(partition, topicId, 0, r -> r != 3,
                metadataVersionForPartitionChangeRecordVersion(version), 3)
            .setElection(Election.PREFERRED)
            .setEligibleLeaderReplicasEnabled(isElrEnabled(version))
            .setDefaultDirProvider(DEFAULT_DIR_PROVIDER)
            .setUseLastKnownLeaderInBalancedRecovery(false);

        builder.setTargetIsrWithBrokerStates(AlterPartitionRequest.newIsrToSimpleNewIsrWithBrokerEpochs(Arrays.asList(1, 2, 3)));
        PartitionChangeRecord record = new PartitionChangeRecord()
            .setTopicId(topicId)
            .setPartitionId(0)
            .setIsr(Arrays.asList(1, 2, 3))
            .setLeader(-2)
            .setLeaderRecoveryState(LeaderRecoveryState.NO_CHANGE);

        // Both versions will set the elr and lastKnownElr as empty list.
        record.setEligibleLeaderReplicas(Collections.emptyList())
            .setLastKnownElr(Collections.emptyList());
        ApiMessageAndVersion expectedRecord = new ApiMessageAndVersion(record, version);
        assertEquals(Optional.of(expectedRecord), builder.build());
        partition = partition.merge((PartitionChangeRecord) builder.build().get().message());
        assertEquals(0, partition.elr.length);
        assertEquals(0, partition.lastKnownElr.length);
    }
Regression test for KAFKA-16624. Tests that when targetIsr is the empty list, but we
cannot actually change the ISR, triggerLeaderEpochBumpForIsrShrinkIfNeeded does not engage.
metadata/src/test/java/org/apache/kafka/controller/PartitionChangeBuilderTest.java