@Test
    void testDirectoryAssignmentState() {
        MetadataVersion outputMetadataVersion = MetadataVersion.IBP_3_7_IV0;
        MetadataVersion inputMetadataVersion = outputMetadataVersion;
        PartitionRecord testPartitionRecord = (PartitionRecord) TEST_RECORDS.get(1).message();
        writeWithExpectedLosses(outputMetadataVersion,
            Collections.singletonList(
                    "the directory assignment state of one or more replicas"),
            Arrays.asList(
                metadataVersionRecord(inputMetadataVersion),
                TEST_RECORDS.get(0),
                new ApiMessageAndVersion(
                    testPartitionRecord.duplicate().setDirectories(Arrays.asList(
                        Uuid.fromString("c7QfSi6xSIGQVh3Qd5RJxA"),
                        Uuid.fromString("rWaCHejCRRiptDMvW5Xw0g"))),
                    (short) 2)),
            Arrays.asList(
                metadataVersionRecord(outputMetadataVersion),
                new ApiMessageAndVersion(new ZkMigrationStateRecord(), (short) 0),
                TEST_RECORDS.get(0),
                new ApiMessageAndVersion(
                    testPartitionRecord.duplicate().setDirectories(Collections.emptyList()),
                    (short) 0))
        );
    }
Test downgrading to a MetadataVersion that doesn't support ZK migration.
metadata/src/test/java/org/apache/kafka/image/ImageDowngradeTest.java