PartitionRegistration getPartition(Uuid topicId, int partitionId) {
        TopicControlInfo topic = topics.get(topicId);
        if (topic == null) {
            return null;
        }
        return topic.parts.get(partitionId);
    }
@Test
    public void testEligibleLeaderReplicas_UncleanShutdown() {
        ReplicationControlTestContext ctx = new ReplicationControlTestContext.Builder()
            .setIsElrEnabled(true)
            .build();
        ReplicationControlManager replicationControl = ctx.replicationControl;
        ctx.registerBrokers(0, 1, 2, 3);
        ctx.unfenceBrokers(0, 1, 2, 3);
        CreatableTopicResult createTopicResult = ctx.createTestTopic("foo",
                new int[][] {new int[] {0, 1, 2, 3}});

        TopicIdPartition topicIdPartition = new TopicIdPartition(createTopicResult.topicId(), 0);
        assertEquals(OptionalInt.of(0), ctx.currentLeader(topicIdPartition));
        ctx.alterTopicConfig("foo", TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, "3");

        ctx.fenceBrokers(Utils.mkSet(1, 2, 3));

        PartitionRegistration partition = replicationControl.getPartition(topicIdPartition.topicId(), topicIdPartition.partitionId());
        assertArrayEquals(new int[]{2, 3}, partition.elr, partition.toString());
        assertArrayEquals(new int[]{}, partition.lastKnownElr, partition.toString());

        // An unclean shutdown ELR member should be kicked out of ELR.
        ctx.handleBrokersUncleanShutdown(3);
        partition = replicationControl.getPartition(topicIdPartition.topicId(), topicIdPartition.partitionId());
        assertArrayEquals(new int[]{2}, partition.elr, partition.toString());
        assertArrayEquals(new int[]{}, partition.lastKnownElr, partition.toString());

        // An unclean shutdown last ISR member should be recognized as the last known leader.
        ctx.handleBrokersUncleanShutdown(0);
        partition = replicationControl.getPartition(topicIdPartition.topicId(), topicIdPartition.partitionId());
        assertArrayEquals(new int[]{2}, partition.elr, partition.toString());
        assertArrayEquals(new int[]{0}, partition.lastKnownElr, partition.toString());
    }