public static int getMinimumCompatibleLayoutVersion(
      LayoutFeature[] features) {
    return getLastNonReservedFeature(features).getInfo()
        .getMinimumCompatibleLayoutVersion();
  }
@Test
  public void testNameNodeFeatureMinimumCompatibleLayoutVersions() {
    int baseLV = NameNodeLayoutVersion.Feature.TRUNCATE.getInfo()
        .getLayoutVersion();
    EnumSet<NameNodeLayoutVersion.Feature> compatibleFeatures = EnumSet.of(
        NameNodeLayoutVersion.Feature.TRUNCATE,
        NameNodeLayoutVersion.Feature.APPEND_NEW_BLOCK,
        NameNodeLayoutVersion.Feature.QUOTA_BY_STORAGE_TYPE,
        NameNodeLayoutVersion.Feature.ERASURE_CODING,
        NameNodeLayoutVersion.Feature.EXPANDED_STRING_TABLE,
        NameNodeLayoutVersion.Feature.SNAPSHOT_MODIFICATION_TIME,
        NameNodeLayoutVersion.Feature.NVDIMM_SUPPORT);
    for (LayoutFeature f : compatibleFeatures) {
      assertEquals(String.format("Expected minimum compatible layout version " +
          "%d for feature %s.", baseLV, f), baseLV,
          f.getInfo().getMinimumCompatibleLayoutVersion());
    }
    List<LayoutFeature> features = new ArrayList<>();
    features.addAll(EnumSet.allOf(LayoutVersion.Feature.class));
    features.addAll(EnumSet.allOf(NameNodeLayoutVersion.Feature.class));
    for (LayoutFeature f : features) {
      if (!compatibleFeatures.contains(f)) {
        assertEquals(String.format("Expected feature %s to have minimum " +
            "compatible layout version set to itself.", f),
            f.getInfo().getLayoutVersion(),
            f.getInfo().getMinimumCompatibleLayoutVersion());
      }
    }
  }