void appendEndOfSegmentEvent(ByteBuffer record, int subpartitionId) {
        subpartitionCacheManagers[subpartitionId].appendEndOfSegmentEvent(record);
        increaseNumCachedBytesAndCheckFlush(record.remaining(), true);
    }
@Test
    void testAppendEndOfSegmentEvent() throws IOException {
        TestingTieredStorageMemoryManager memoryManager =
                new TestingTieredStorageMemoryManager.Builder().build();

        List<PartitionFileWriter.SubpartitionBufferContext> receivedBuffers = new ArrayList<>();
        TestingPartitionFileWriter partitionFileWriter =
                new TestingPartitionFileWriter.Builder()
                        .setWriteFunction(
                                (partitionId, subpartitionBufferContexts) -> {
                                    receivedBuffers.addAll(subpartitionBufferContexts);
                                    return FutureUtils.completedVoidFuture();
                                })
                        .build();
        DiskCacheManager diskCacheManager =
                new DiskCacheManager(
                        TieredStorageIdMappingUtils.convertId(new ResultPartitionID()),
                        1,
                        1024,
                        memoryManager,
                        partitionFileWriter);
        diskCacheManager.appendEndOfSegmentEvent(
                EventSerializer.toSerializedEvent(EndOfSegmentEvent.INSTANCE), 0);

        diskCacheManager.close();
        assertThat(receivedBuffers).hasSize(1);
        List<PartitionFileWriter.SegmentBufferContext> segmentBufferContexts =
                receivedBuffers.get(0).getSegmentBufferContexts();
        assertThat(segmentBufferContexts).hasSize(1);
        List<Tuple2<Buffer, Integer>> bufferAndIndexes =
                segmentBufferContexts.get(0).getBufferAndIndexes();
        assertThat(bufferAndIndexes).hasSize(1);
        Buffer buffer = bufferAndIndexes.get(0).f0;

        assertThat(buffer.isBuffer()).isFalse();
        AbstractEvent event =
                EventSerializer.fromSerializedEvent(
                        buffer.readOnlySlice().getNioBufferReadable(), getClass().getClassLoader());
        assertThat(event).isInstanceOf(EndOfSegmentEvent.class);
    }