@Test
  public void getDeletedDevicesWithSameNameFromSeqFilesWithFourLayersInNodeTreeTest()
      throws MetadataException, IOException, WriteProcessException {
    TSFileDescriptor.getInstance().getConfig().setMaxDegreeOfIndexNode(3);
    int oldAlignedDeviceOffset = TsFileGeneratorUtils.alignDeviceOffset;
    TsFileGeneratorUtils.alignDeviceOffset = 0;
    registerTimeseriesInMManger(30, 5, false);
    createFiles(3, 10, 5, 100, 0, 0, 50, 50, false, true);
    createFiles(4, 30, 5, 100, 1000, 0, 50, 50, false, true);

    // generate mods file, delete d0 ~ d14
    List<String> seriesPaths = new ArrayList<>();
    for (int i = 0; i < 15; i++) {
      for (int j = 0; j < 5; j++) {
        seriesPaths.add(COMPACTION_TEST_SG + PATH_SEPARATOR + "d" + i + PATH_SEPARATOR + "s" + j);
      }
    }
    generateModsFile(seriesPaths, seqResources, Long.MIN_VALUE, Long.MAX_VALUE);
    generateModsFile(seriesPaths, unseqResources, Long.MIN_VALUE, Long.MAX_VALUE);
    deleteTimeseriesInMManager(seriesPaths);

    createFiles(2, 10, 5, 100, 2000, 2000, 50, 50, true, true);
    resetFileName(seqResources.get(7), 100);
    resetFileName(seqResources.get(8), 101);

    // sort the deviceId in lexicographical order from small to large
    List<IDeviceID> deviceIds = new ArrayList<>();
    for (int i = 0; i < 30; i++) {
      deviceIds.add(
          IDeviceID.Factory.DEFAULT_FACTORY.create(
              "root.testsg.d" + (i + TsFileGeneratorUtils.getAlignDeviceOffset())));
    }
    deviceIds.sort(IDeviceID::compareTo);

    int deviceNum = 0;
    try (MultiTsFileDeviceIterator multiTsFileDeviceIterator =
        new MultiTsFileDeviceIterator(seqResources)) {
      while (multiTsFileDeviceIterator.hasNextDevice()) {
        Pair<IDeviceID, Boolean> deviceInfo = multiTsFileDeviceIterator.nextDevice();
        Assert.assertEquals(deviceIds.get(deviceNum), deviceInfo.left);
        if (Integer.parseInt(deviceInfo.left.toString().substring(13)) < 10) {
          Assert.assertTrue(deviceInfo.right);
        } else {
          Assert.assertFalse(deviceInfo.right);
        }
        deviceNum++;
      }
    }
    Assert.assertEquals(30, deviceNum);
    TsFileGeneratorUtils.alignDeviceOffset = oldAlignedDeviceOffset;
  }
Create device with nonAligned property. Deleted it and create new device with same deviceID but
aligned property. Check whether the deviceID and its property can be obtained correctly.
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/MultiTsFileDeviceIteratorTest.java