@Test
  public void testSerialId() throws InterruptedException {
    AbstractCompactionTask[] compactionTasks = new AbstractCompactionTask[100];
    TsFileManager[] tsFileManagers = new TsFileManager[10];
    for (int i = 0; i < 10; ++i) {
      tsFileManagers[i] = new TsFileManager("fakeSg" + i, "0", "/");
      for (int j = 0; j < 10; ++j) {
        List<TsFileResource> resources = new ArrayList<>();
        // the j th compaction task for i th sg
        for (int k = 0; k < 10; ++k) {
          resources.add(
              new FakedTsFileResource(
                  new File(String.format("%d-%d-0-0.tsfile", j * 10 + k, j * 10 + k)), 10));
        }
        compactionTaskQueue.put(
            new FakedInnerSpaceCompactionTask(
                "fakeSg" + i, 0, tsFileManagers[i], true, resources, j));
      }
    }
    Map<String, AtomicInteger> taskCount = new HashMap<>();
    for (int i = 0; i < 10; ++i) {
      taskCount.put("fakeSg" + i + "-0", new AtomicInteger(0));
    }
    long cnt = 0;
    while (compactionTaskQueue.size() > 0) {
      for (int i = 0; i < 10; ++i) {
        AbstractCompactionTask task = compactionTaskQueue.take();
        String id =
            CompactionTaskManager.getSgWithRegionId(
                task.getStorageGroupName(), task.getDataRegionId());
        taskCount.get(id).incrementAndGet();
      }
      cnt++;
      for (int i = 0; i < 10; ++i) {
        assertEquals(cnt, taskCount.get("fakeSg" + i + "-0").get());
      }
    }
  }
Test the comparation of cross space compaction task
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/CompactionTaskComparatorTest.java