This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 74e112bb62e HDDS-16863. OM that stops during snapshot install after DB 
swap restarts pre-finalized although its DB is finalized (#12004)
74e112bb62e is described below

commit 74e112bb62e0f9fd7308b9600dde0004dfb1afd9
Author: Stephen O'Donnell <[email protected]>
AuthorDate: Thu Nov 12 14:40:27 2026 +0000

    HDDS-16863. OM that stops during snapshot install after DB swap restarts 
pre-finalized although its DB is finalized (#12004)
    
    Co-authored-by: Ethan Rose <[email protected]>
---
 .../AbstractRatisBasedVersionManagerTest.java      | 188 +++++++++++++++
 .../scm/server/upgrade/TestScmVersionManager.java  |  10 +-
 .../TestScmStartupVersionReconciliation.java       | 124 ++++++++++
 ...estScmStartupWithDifferentApparentVersions.java | 259 ---------------------
 .../hdds/scm/TestStorageContainerManagerHA.java    |   1 +
 .../om/TestOmStartupInvalidApparentVersion.java    |  84 -------
 .../org/apache/hadoop/ozone/om/OzoneManager.java   |   8 +
 .../om/TestOMStartupVersionReconciliation.java     | 114 +++++++++
 .../ozone/om/upgrade/TestOMVersionManager.java     |  10 +-
 9 files changed, 451 insertions(+), 347 deletions(-)

diff --git 
a/hadoop-hdds/framework/src/test/java/org/apache/hadoop/ozone/upgrade/AbstractRatisBasedVersionManagerTest.java
 
b/hadoop-hdds/framework/src/test/java/org/apache/hadoop/ozone/upgrade/AbstractRatisBasedVersionManagerTest.java
new file mode 100644
index 00000000000..34e1d2e864e
--- /dev/null
+++ 
b/hadoop-hdds/framework/src/test/java/org/apache/hadoop/ozone/upgrade/AbstractRatisBasedVersionManagerTest.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.upgrade;
+
+import static org.apache.hadoop.ozone.OzoneConsts.APPARENT_VERSION_KEY;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+import org.apache.hadoop.hdds.ComponentVersion;
+import org.apache.hadoop.hdds.utils.db.InMemoryTestTable;
+import org.apache.hadoop.hdds.utils.db.Table;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Shared tests for {@link RatisBasedVersionManager} implementations, covering 
how the apparent version in the VERSION
+ * file is reconciled with the apparent version recorded in the DB on startup.
+ *
+ * <p>A component that stops during a Ratis snapshot install after its DB was 
replaced, but before its VERSION file was
+ * updated, cannot replay the finalization from the Raft log, so it must 
finalize from the DB on restart. Component
+ * tests only need to verify that their real startup path calls
+ * {@link RatisBasedVersionManager#finalizeFromDBIfRequired}.
+ */
+public abstract class AbstractRatisBasedVersionManagerTest extends 
AbstractComponentVersionManagerTest {
+
+  @Override
+  protected abstract RatisBasedVersionManager createManager(int 
serializedApparentVersion) throws IOException;
+
+  /**
+   * @return The last legacy layout feature of this component. Serialized 
values between it and ZDU are not valid.
+   */
+  protected abstract ComponentVersion lastLayoutFeature();
+
+  @Test
+  public void testApparentVersionBetweenLastLayoutFeatureAndZduRejected() {
+    int serializedVersion = lastLayoutFeature().serialize() + 1;
+    IOException e = assertThrows(IOException.class, () -> 
createManager(serializedVersion));
+    assertTrue(e.getMessage().contains("unknown apparent version " + 
serializedVersion), e.getMessage());
+  }
+
+  /**
+   * The DB is ahead of the VERSION file, as an interrupted snapshot install 
leaves it. The component finalizes to the
+   * DB version.
+   */
+  @Test
+  public void testFinalizeFromDBFinalizesToSoftwareVersion() throws Exception {
+    Table<String, String> finalizationStore = 
storeWithVersion(expectedSoftwareVersion());
+    try (RatisBasedVersionManager versionManager = 
createManager(initialVersion().serialize())) {
+      versionManager.finalizeFromDBIfRequired(finalizationStore);
+      assertVersions(versionManager, finalizationStore, 
expectedSoftwareVersion(), expectedSoftwareVersion());
+      assertFalse(versionManager.needsFinalization());
+    }
+  }
+
+  /**
+   * The DB version is between the apparent version and the software version. 
This should not happen in practice,
+   * but if it does the safest recovery is to partially finalize up to the DB 
version to avoid mixed apparent versions
+   * in the quorum.
+   */
+  @Test
+  public void testFinalizeFromDBFinalizesToIntermediateDBVersion() throws 
Exception {
+    Table<String, String> finalizationStore = 
storeWithVersion(intermediateVersion());
+    try (RatisBasedVersionManager versionManager = 
createManager(initialVersion().serialize())) {
+      versionManager.finalizeFromDBIfRequired(finalizationStore);
+      assertVersions(versionManager, finalizationStore, intermediateVersion(), 
intermediateVersion());
+      assertTrue(versionManager.needsFinalization());
+    }
+  }
+
+  /**
+   * The VERSION file is ahead of the DB. This can happen if finalization 
wrote the VERSION file (inside Ratis
+   * applyTransaction) but the process crashed before the Ratis transaction 
buffer was flushed to RocksDB.
+   * Ratis log replay is async and may not have finished when this method 
runs, so this is treated as an expected
+   * case and no action is taken — log replay will correct the DB after 
startup.
+   */
+  @Test
+  public void testFinalizeFromDBNoOpWhenVersionFileAheadOfDB() throws 
Exception {
+    Table<String, String> finalizationStore = 
storeWithVersion(intermediateVersion());
+    try (RatisBasedVersionManager versionManager = 
createManager(expectedSoftwareVersion().serialize())) {
+      versionManager.finalizeFromDBIfRequired(finalizationStore);
+      assertVersions(versionManager, finalizationStore, 
expectedSoftwareVersion(), intermediateVersion());
+    }
+  }
+
+  /**
+   * When the DB has no apparent version, the component was never finalized. 
finalizeFromDBIfRequired takes no action.
+   */
+  @Test
+  public void testFinalizeFromDBNoOpWhenDBNull() throws Exception {
+    Table<String, String> finalizationStore = new InMemoryTestTable<>();
+    try (RatisBasedVersionManager versionManager = 
createManager(initialVersion().serialize())) {
+      versionManager.finalizeFromDBIfRequired(finalizationStore);
+      assertVersions(versionManager, finalizationStore, initialVersion(), 
null);
+    }
+  }
+
+  /**
+   * When the DB matches a pre-finalized apparent version, no finalization or 
update is needed.
+   */
+  @Test
+  public void testFinalizeFromDBNoOpWhenDBEqualsApparent() throws Exception {
+    Table<String, String> finalizationStore = 
storeWithVersion(intermediateVersion());
+    try (RatisBasedVersionManager versionManager = 
createManager(intermediateVersion().serialize())) {
+      versionManager.finalizeFromDBIfRequired(finalizationStore);
+      assertVersions(versionManager, finalizationStore, intermediateVersion(), 
intermediateVersion());
+      assertTrue(versionManager.needsFinalization());
+    }
+  }
+
+  /**
+   * The steady state of a finalized component: the DB and VERSION file both 
record the software version.
+   */
+  @Test
+  public void testFinalizeFromDBNoOpWhenFullyFinalized() throws Exception {
+    Table<String, String> finalizationStore = 
storeWithVersion(expectedSoftwareVersion());
+    try (RatisBasedVersionManager versionManager = 
createManager(expectedSoftwareVersion().serialize())) {
+      versionManager.finalizeFromDBIfRequired(finalizationStore);
+      assertVersions(versionManager, finalizationStore, 
expectedSoftwareVersion(), expectedSoftwareVersion());
+      assertFalse(versionManager.needsFinalization());
+    }
+  }
+
+  /**
+   * The DB version exceeds the software version. This cannot be supported and 
the process must crash without
+   * changing its apparent version.
+   */
+  @Test
+  public void testFinalizeFromDBThrowsWhenDBVersionExceedsSoftwareVersion() 
throws Exception {
+    String serializedDBVersion = 
String.valueOf(expectedSoftwareVersion().serialize() + 1);
+    Table<String, String> finalizationStore = new InMemoryTestTable<>();
+    finalizationStore.put(APPARENT_VERSION_KEY, serializedDBVersion);
+    try (RatisBasedVersionManager versionManager = 
createManager(initialVersion().serialize())) {
+      assertThrows(IOException.class, () -> 
versionManager.finalizeFromDBIfRequired(finalizationStore));
+      assertEquals(initialVersion(), versionManager.getApparentVersion());
+      assertEquals(initialVersion().serialize(), 
versionManager.getPersistedApparentVersion());
+      assertEquals(serializedDBVersion, 
finalizationStore.get(APPARENT_VERSION_KEY));
+    }
+  }
+
+  private ComponentVersion initialVersion() {
+    return allVersionsInOrder().get(0);
+  }
+
+  /**
+   * @return A version after the initial version and before the software 
version.
+   */
+  private ComponentVersion intermediateVersion() {
+    List<ComponentVersion> allVersions = allVersionsInOrder();
+    assertTrue(allVersions.size() >= 3, "Need at least three versions to have 
an intermediate version");
+    return allVersions.get(allVersions.size() - 2);
+  }
+
+  private static Table<String, String> storeWithVersion(ComponentVersion 
version) throws IOException {
+    Table<String, String> finalizationStore = new InMemoryTestTable<>();
+    finalizationStore.put(APPARENT_VERSION_KEY, 
String.valueOf(version.serialize()));
+    return finalizationStore;
+  }
+
+  private static void assertVersions(RatisBasedVersionManager versionManager, 
Table<String, String> finalizationStore,
+      ComponentVersion expectedApparentVersion, ComponentVersion 
expectedDBVersion) throws IOException {
+    assertEquals(expectedApparentVersion, versionManager.getApparentVersion());
+    assertEquals(expectedApparentVersion.serialize(), 
versionManager.getPersistedApparentVersion());
+    if (expectedDBVersion == null) {
+      assertNull(finalizationStore.get(APPARENT_VERSION_KEY));
+    } else {
+      assertEquals(String.valueOf(expectedDBVersion.serialize()), 
finalizationStore.get(APPARENT_VERSION_KEY));
+    }
+  }
+}
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/upgrade/TestScmVersionManager.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/upgrade/TestScmVersionManager.java
index 364a9310e9f..fe16afebe71 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/upgrade/TestScmVersionManager.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/upgrade/TestScmVersionManager.java
@@ -56,7 +56,7 @@
 import org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature;
 import org.apache.hadoop.hdds.upgrade.ScmUpgradeAction;
 import org.apache.hadoop.hdds.upgrade.ScmUpgradeActionProvider;
-import org.apache.hadoop.ozone.upgrade.AbstractComponentVersionManagerTest;
+import org.apache.hadoop.ozone.upgrade.AbstractRatisBasedVersionManagerTest;
 import org.apache.hadoop.ozone.upgrade.ComponentUpgradeActionProvider;
 import org.apache.hadoop.ozone.upgrade.UpgradeException;
 import org.junit.jupiter.api.BeforeEach;
@@ -68,7 +68,7 @@
  * Tests for {@link ScmVersionManager} using on-disk {@link SCMStorageConfig}
  * under a JUnit temp directory.
  */
-class TestScmVersionManager extends AbstractComponentVersionManagerTest {
+class TestScmVersionManager extends AbstractRatisBasedVersionManagerTest {
 
   private OzoneConfiguration conf;
 
@@ -130,6 +130,12 @@ protected ComponentVersion expectedSoftwareVersion() {
     return HDDSVersion.SOFTWARE_VERSION;
   }
 
+  @Override
+  protected ComponentVersion lastLayoutFeature() {
+    HDDSLayoutFeature[] features = HDDSLayoutFeature.values();
+    return features[features.length - 1];
+  }
+
   @Override
   @Test
   public void testClasspathScanDiscoversUpgradeActions() throws Exception {
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestScmStartupVersionReconciliation.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestScmStartupVersionReconciliation.java
new file mode 100644
index 00000000000..a587e9a16fe
--- /dev/null
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestScmStartupVersionReconciliation.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.scm.upgrade;
+
+import static org.apache.hadoop.hdds.HDDSVersion.SOFTWARE_VERSION;
+import static org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature.INITIAL_VERSION;
+import static org.apache.hadoop.ozone.OzoneConsts.APPARENT_VERSION_KEY;
+import static org.apache.hadoop.ozone.OzoneConsts.SCM_HA;
+import static org.apache.hadoop.ozone.OzoneConsts.SCM_ID;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Properties;
+import org.apache.hadoop.hdds.HddsConfigKeys;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.HddsTestUtils;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.ha.SCMContext;
+import org.apache.hadoop.hdds.scm.ha.SCMHAManagerStub;
+import org.apache.hadoop.hdds.scm.safemode.SCMSafeModeManager;
+import org.apache.hadoop.hdds.scm.server.SCMConfigurator;
+import org.apache.hadoop.hdds.scm.server.SCMStorageConfig;
+import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
+import org.apache.hadoop.ozone.container.common.SCMTestUtils;
+import org.apache.hadoop.ozone.upgrade.UpgradeTestUtils;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+/**
+ * Verifies that the real SCM startup path is wired to the version manager. 
The version manager logic itself is
+ * covered by {@link 
org.apache.hadoop.hdds.scm.server.upgrade.TestScmVersionManager}, which calls 
it directly and
+ * would still pass if these calls were removed from SCM startup.
+ */
+public class TestScmStartupVersionReconciliation {
+
+  @TempDir
+  private Path folder;
+
+  /**
+   * An SCM that crashed after replacing its DB with a finalized checkpoint, 
but before updating its VERSION file, must
+   * finalize from the DB in {@link StorageContainerManager#start()}.
+   */
+  @Test
+  public void testStartCallsFinalizeFromDB() throws Exception {
+    OzoneConfiguration conf = SCMTestUtils.getConf(folder.toFile());
+    // VERSION file starts at INITIAL_VERSION, simulating an SCM that has not 
yet been finalized.
+    conf.setInt(SCMStorageConfig.TESTING_INIT_APPARENT_VERSION_KEY, 
INITIAL_VERSION.serialize());
+
+    SCMConfigurator configurator = new SCMConfigurator();
+    configurator.setSCMHAManager(SCMHAManagerStub.getInstance(true));
+    configurator.setScmContext(SCMContext.emptyContext());
+    configurator.setScmSafeModeManager(mock(SCMSafeModeManager.class));
+    StorageContainerManager scm = HddsTestUtils.getScm(conf, configurator);
+    try {
+      // Simulate the crash state: DB is at SOFTWARE_VERSION, VERSION file is 
at INITIAL_VERSION.
+      
assertThat(scm.getVersionManager().getApparentVersion()).isEqualTo(INITIAL_VERSION);
+      scm.getScmMetadataStore().getMetaTable().put(APPARENT_VERSION_KEY, 
String.valueOf(SOFTWARE_VERSION.serialize()));
+
+      scm.start();
+
+      
assertThat(scm.getVersionManager().getApparentVersion()).isEqualTo(SOFTWARE_VERSION);
+      assertThat(new 
SCMStorageConfig(conf).getApparentVersion()).isEqualTo(SOFTWARE_VERSION.serialize());
+    } finally {
+      scm.stop();
+      scm.join();
+    }
+  }
+
+  @Test
+  public void testStartupRejectsUnknownApparentVersion() throws Exception {
+    int serializedApparentVersion = SOFTWARE_VERSION.serialize() + 1;
+    OzoneConfiguration conf = createScmStorage(serializedApparentVersion);
+
+    String expectedMessage = "Initialization failed. Disk contains unknown 
apparent version "
+        + serializedApparentVersion + " for software version " + 
SOFTWARE_VERSION
+        + ". Make sure this component was not downgraded after finalization";
+
+    IOException ioException = assertThrows(IOException.class, () -> new 
StorageContainerManager(conf));
+    assertEquals(expectedMessage, ioException.getMessage());
+  }
+
+  private OzoneConfiguration createScmStorage(int serializedApparentVersion) 
throws IOException {
+    File scmSubdir = folder.resolve("scm").resolve("current").toFile();
+    assertTrue(scmSubdir.mkdirs());
+
+    File ratisDir = folder.resolve("scm.ratis").toFile();
+    File snapshotDir = folder.resolve("scm.ratis.snapshot").toFile();
+    assertTrue(ratisDir.mkdirs());
+    assertTrue(snapshotDir.mkdirs());
+
+    OzoneConfiguration conf = new OzoneConfiguration();
+    conf.set(ScmConfigKeys.OZONE_SCM_DB_DIRS, 
folder.toAbsolutePath().toString());
+    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, 
folder.toAbsolutePath().toString());
+
+    Properties properties = new Properties();
+    properties.setProperty(SCM_ID, "scm");
+    properties.setProperty(SCM_HA, "true");
+
+    UpgradeTestUtils.createVersionFile(scmSubdir, HddsProtos.NodeType.SCM, 
serializedApparentVersion, properties);
+    return conf;
+  }
+}
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestScmStartupWithDifferentApparentVersions.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestScmStartupWithDifferentApparentVersions.java
deleted file mode 100644
index 643266211c7..00000000000
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestScmStartupWithDifferentApparentVersions.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hdds.scm.upgrade;
-
-import static org.apache.hadoop.hdds.HDDSVersion.SOFTWARE_VERSION;
-import static org.apache.hadoop.hdds.HDDSVersion.ZDU;
-import static org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature.INITIAL_VERSION;
-import static org.apache.hadoop.ozone.OzoneConsts.APPARENT_VERSION_KEY;
-import static org.apache.hadoop.ozone.OzoneConsts.SCM_HA;
-import static org.apache.hadoop.ozone.OzoneConsts.SCM_ID;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Properties;
-import org.apache.hadoop.hdds.ComponentVersion;
-import org.apache.hadoop.hdds.HDDSVersion;
-import org.apache.hadoop.hdds.HddsConfigKeys;
-import org.apache.hadoop.hdds.conf.OzoneConfiguration;
-import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
-import org.apache.hadoop.hdds.scm.HddsTestUtils;
-import org.apache.hadoop.hdds.scm.ScmConfigKeys;
-import org.apache.hadoop.hdds.scm.server.SCMConfigurator;
-import org.apache.hadoop.hdds.scm.server.SCMStorageConfig;
-import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
-import org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature;
-import org.apache.hadoop.ozone.upgrade.UpgradeTestUtils;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-
-/**
- * Ensures SCM does not start when the VERSION file records an apparent version
- * that is larger than the software version, and that it finalizes on startup
- * when the DB records a higher apparent version than the VERSION file.
- */
-public class TestScmStartupWithDifferentApparentVersions {
-
-  @TempDir
-  private Path folder;
-
-  @Test
-  public void 
testStartupFailsWhenApparentVersionBetweenLastLayoutFeatureAndZdu() throws 
Exception {
-    assertStartupFailsWithComponentVersionMessage(
-        HDDSLayoutFeature.STORAGE_SPACE_DISTRIBUTION.serialize() + 1);
-  }
-
-  @Test
-  public void 
testStartupFailsWhenApparentVersionBeyondLastKnownComponentVersion() throws 
Exception {
-    assertStartupFailsWithComponentVersionMessage(SOFTWARE_VERSION.serialize() 
+ 1);
-  }
-
-  /**
-   * An SCM that stops after replacing its DB with a finalized checkpoint, but 
before updating its VERSION file, cannot
-   * replay the finalization from the Raft log, so it should finalize up to 
the version in its DB on restart.
-   */
-  @Test
-  public void testStartupFinalizesToApparentVersionInDB() throws Exception {
-    OzoneConfiguration conf = createScmStorage(INITIAL_VERSION.serialize());
-    StorageContainerManager scm = HddsTestUtils.getScm(conf, new 
SCMConfigurator());
-    try {
-      // Without a version in the DB, startup leaves the SCM pre-finalized.
-      
assertThat(scm.getScmMetadataStore().getMetaTable().get(APPARENT_VERSION_KEY)).isNull();
-      
assertThat(scm.getVersionManager().getApparentVersion()).isEqualTo(INITIAL_VERSION);
-
-      // The DB is ahead of the VERSION file, as the interrupted install 
leaves it. The SCM finalizes to the
-      // software version
-      scm = restartWithDBVersion(scm, SOFTWARE_VERSION);
-      // finalizeFromDBIfRequired is called by scm.start(), but calling that 
here makes the tests slow and we would
-      // need more setup for safemode etc. As this test is unit testing 
finalizeFromDBIfRequired we call it directly
-      // to keep the tests simple.
-      
scm.getVersionManager().finalizeFromDBIfRequired(scm.getScmMetadataStore().getMetaTable());
-      assertVersions(scm, SOFTWARE_VERSION, SOFTWARE_VERSION);
-      assertThat(scm.getVersionManager().needsFinalization()).isFalse();
-    } finally {
-      scm.stop();
-      scm.join();
-    }
-  }
-
-  /**
-   * The VERSION file is ahead of the DB. This can happen if finalization 
wrote the VERSION file (inside Ratis
-   * applyTransaction) but the process crashed before the Ratis transaction 
buffer was flushed to RocksDB.
-   * Ratis log replay is async and may not have finished when this method 
runs, so this is treated as an expected
-   * case and no action is taken — log replay will correct the DB after 
startup.
-   */
-  @Test
-  public void testFinalizeFromDBNoOpWhenVersionFileAheadOfDB() throws 
Exception {
-    OzoneConfiguration conf = createScmStorage(SOFTWARE_VERSION.serialize());
-    StorageContainerManager scm = HddsTestUtils.getScm(conf, new 
SCMConfigurator());
-    try {
-      // Force the DB to a lower version to simulate the unflushed transaction 
buffer.
-      scm.getScmMetadataStore().getMetaTable().put(APPARENT_VERSION_KEY, 
String.valueOf(ZDU.serialize()));
-      scm.stop();
-      scm.join();
-
-      // On restart, finalizeFromDBIfRequired detects DB version < VERSION 
file version but takes no action.
-      // finalizeFromDBIfRequired is called by scm.start(), but calling that 
here makes the tests slow and we would
-      // need more setup for safemode etc. As this test is unit testing 
finalizeFromDBIfRequired we call it directly
-      // to keep the tests simple.
-      scm = HddsTestUtils.getScm(scm.getConfiguration(), new 
SCMConfigurator());
-      
scm.getVersionManager().finalizeFromDBIfRequired(scm.getScmMetadataStore().getMetaTable());
-      // Apparent version unchanged; DB version also unchanged (left for Ratis 
log replay to correct).
-      assertVersions(scm, SOFTWARE_VERSION, ZDU);
-    } finally {
-      scm.stop();
-      scm.join();
-    }
-  }
-
-  /**
-   * When the DB has no apparent version, the component was never finalized. 
finalizeFromDBIfRequired takes no action.
-   */
-  @Test
-  public void testFinalizeFromDBNoOpWhenDBNull() throws Exception {
-    OzoneConfiguration conf = createScmStorage(INITIAL_VERSION.serialize());
-    StorageContainerManager scm = HddsTestUtils.getScm(conf, new 
SCMConfigurator());
-    try {
-      
assertThat(scm.getScmMetadataStore().getMetaTable().get(APPARENT_VERSION_KEY)).isNull();
-      
scm.getVersionManager().finalizeFromDBIfRequired(scm.getScmMetadataStore().getMetaTable());
-      
assertThat(scm.getVersionManager().getApparentVersion()).isEqualTo(INITIAL_VERSION);
-      
assertThat(scm.getScmMetadataStore().getMetaTable().get(APPARENT_VERSION_KEY)).isNull();
-    } finally {
-      scm.stop();
-      scm.join();
-    }
-  }
-
-  /**
-   * When the DB matches the apparent version, no finalization or update is 
needed.
-   */
-  @Test
-  public void testFinalizeFromDBNoOpWhenDBEqualsApparent() throws Exception {
-    OzoneConfiguration conf = createScmStorage(SOFTWARE_VERSION.serialize());
-    StorageContainerManager scm = HddsTestUtils.getScm(conf, new 
SCMConfigurator());
-    try {
-      scm.getScmMetadataStore().getMetaTable().put(APPARENT_VERSION_KEY, 
String.valueOf(SOFTWARE_VERSION.serialize()));
-      
scm.getVersionManager().finalizeFromDBIfRequired(scm.getScmMetadataStore().getMetaTable());
-      assertVersions(scm, SOFTWARE_VERSION, SOFTWARE_VERSION);
-      assertFalse(scm.getVersionManager().needsFinalization());
-    } finally {
-      scm.stop();
-      scm.join();
-    }
-  }
-
-  /**
-   * The DB version is between the apparent version and the software version. 
This should not happen in practice,
-   * but if it does the safest recovery is to partially finalize up to the DB 
version to avoid mixed apparent versions
-   * in the quorum.
-   */
-  @Test
-  public void testFinalizeFromDBFinalizesToIntermediateDBVersion() throws 
Exception {
-    OzoneConfiguration conf = createScmStorage(INITIAL_VERSION.serialize());
-    StorageContainerManager scm = HddsTestUtils.getScm(conf, new 
SCMConfigurator());
-    try {
-      scm.getScmMetadataStore().getMetaTable().put(APPARENT_VERSION_KEY, 
String.valueOf(ZDU.serialize()));
-      
scm.getVersionManager().finalizeFromDBIfRequired(scm.getScmMetadataStore().getMetaTable());
-      assertVersions(scm, ZDU, ZDU);
-      // Component is not fully finalized: ZDU < SOFTWARE_VERSION.
-      assertTrue(scm.getVersionManager().needsFinalization());
-    } finally {
-      scm.stop();
-      scm.join();
-    }
-  }
-
-  /**
-   * The DB version exceeds the software version. This cannot be supported and 
the process must crash.
-   */
-  @Test
-  public void testFinalizeFromDBThrowsWhenDBVersionExceedsSoftwareVersion() 
throws Exception {
-    OzoneConfiguration conf = createScmStorage(INITIAL_VERSION.serialize());
-    StorageContainerManager scm = HddsTestUtils.getScm(conf, new 
SCMConfigurator());
-    try {
-      scm.getScmMetadataStore().getMetaTable().put(APPARENT_VERSION_KEY,
-          String.valueOf(SOFTWARE_VERSION.serialize() + 1));
-      assertThrows(IOException.class,
-          () -> 
scm.getVersionManager().finalizeFromDBIfRequired(scm.getScmMetadataStore().getMetaTable()));
-    } finally {
-      scm.stop();
-      scm.join();
-    }
-  }
-
-  /**
-   * Writes {@code dbVersion} to the DB of {@code scm}, stops it and creates a 
new SCM on the same storage.
-   */
-  private static StorageContainerManager 
restartWithDBVersion(StorageContainerManager scm, ComponentVersion dbVersion)
-      throws Exception {
-    scm.getScmMetadataStore().getMetaTable().put(APPARENT_VERSION_KEY, 
String.valueOf(dbVersion.serialize()));
-    scm.stop();
-    scm.join();
-    return HddsTestUtils.getScm(scm.getConfiguration(), new SCMConfigurator());
-  }
-
-  private static void assertVersions(StorageContainerManager scm, 
ComponentVersion expectedApparentVersion,
-      ComponentVersion expectedDBVersion) throws IOException {
-    
assertThat(scm.getVersionManager().getApparentVersion()).isEqualTo(expectedApparentVersion);
-    assertThat(new 
SCMStorageConfig(scm.getConfiguration()).getApparentVersion())
-        .isEqualTo(expectedApparentVersion.serialize());
-    
assertThat(scm.getScmMetadataStore().getMetaTable().get(APPARENT_VERSION_KEY))
-        .isEqualTo(String.valueOf(expectedDBVersion.serialize()));
-  }
-
-  private void assertStartupFailsWithComponentVersionMessage(int 
serializedApparentVersion)
-      throws Exception {
-    OzoneConfiguration conf = createScmStorage(serializedApparentVersion);
-
-    String expectedMessage =
-        "Initialization failed. Disk contains unknown apparent version " + 
serializedApparentVersion
-            + " for software version " + HDDSVersion.SOFTWARE_VERSION + ". 
Make sure this component was not" +
-            " downgraded after finalization";
-
-    IOException ioException =
-        assertThrows(IOException.class, () -> new 
StorageContainerManager(conf));
-    assertEquals(expectedMessage, ioException.getMessage());
-  }
-
-  private OzoneConfiguration createScmStorage(int serializedApparentVersion) 
throws IOException {
-    File scmSubdir = folder.resolve("scm").resolve("current").toFile();
-    assertTrue(scmSubdir.mkdirs());
-
-    File ratisDir = folder.resolve("scm.ratis").toFile();
-    File snapshotDir = folder.resolve("scm.ratis.snapshot").toFile();
-    assertTrue(ratisDir.mkdirs());
-    assertTrue(snapshotDir.mkdirs());
-
-    OzoneConfiguration conf = new OzoneConfiguration();
-    conf.set(ScmConfigKeys.OZONE_SCM_DB_DIRS, 
folder.toAbsolutePath().toString());
-    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, 
folder.toAbsolutePath().toString());
-
-    Properties properties = new Properties();
-    properties.setProperty(SCM_ID, "scm");
-    properties.setProperty(SCM_HA, "true");
-
-    UpgradeTestUtils.createVersionFile(scmSubdir, HddsProtos.NodeType.SCM, 
serializedApparentVersion, properties);
-    return conf;
-  }
-}
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHA.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHA.java
index 288d7807eef..017cbd1b03f 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHA.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHA.java
@@ -151,6 +151,7 @@ public void testSCMLeadershipMetric() throws IOException, 
InterruptedException {
     // started again, so the running SCM is left as is.
     List<StorageContainerManager> inactiveSCMs = new ArrayList<>();
     cluster.getInactiveSCM().forEachRemaining(inactiveSCMs::add);
+    assertEquals(2, inactiveSCMs.size());
     CountDownLatch scmInstancesCounter = new 
CountDownLatch(inactiveSCMs.size());
     AtomicInteger failedSCMs = new AtomicInteger();
     for (StorageContainerManager scm : inactiveSCMs) {
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmStartupInvalidApparentVersion.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmStartupInvalidApparentVersion.java
deleted file mode 100644
index d0aafe818d3..00000000000
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmStartupInvalidApparentVersion.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.ozone.om;
-
-import static org.apache.hadoop.ozone.OzoneManagerVersion.SOFTWARE_VERSION;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import org.apache.hadoop.hdds.conf.OzoneConfiguration;
-import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
-import org.apache.hadoop.ozone.MiniOzoneCluster;
-import org.apache.hadoop.ozone.MiniOzoneClusterImpl;
-import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
-import org.apache.hadoop.ozone.upgrade.UpgradeTestUtils;
-import org.apache.ozone.test.GenericTestUtils;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-
-/**
- * Ensures OM does not start when the VERSION file records an apparent version 
newer than the software version
- * baked into this process ({@link 
org.apache.hadoop.ozone.OzoneManagerVersion#SOFTWARE_VERSION}).
- */
-public class TestOmStartupInvalidApparentVersion {
-
-  @TempDir
-  private Path folder;
-
-  @Test
-  public void 
testStartupFailsWhenApparentVersionBetweenLastLayoutFeatureAndZdu()
-      throws Exception {
-    OMLayoutFeature[] features = OMLayoutFeature.values();
-    int lastLayoutVersion = features[features.length - 1].serialize();
-    assertStartupFailsWithComponentVersionMessage(lastLayoutVersion + 1);
-  }
-
-  @Test
-  public void 
testStartupFailsWhenApparentVersionBeyondLastKnownComponentVersion()
-      throws Exception {
-    assertStartupFailsWithComponentVersionMessage(SOFTWARE_VERSION.serialize() 
+ 1);
-  }
-
-  private void assertStartupFailsWithComponentVersionMessage(int 
serializedApparentVersion)
-      throws Exception {
-    String subDir = folder.toAbsolutePath() + "/om/current";
-    File omSubdir = Files.createDirectories(Paths.get(subDir)).toFile();
-
-    OzoneConfiguration conf = new OzoneConfiguration();
-    conf.set(OMConfigKeys.OZONE_OM_DB_DIRS, 
folder.toAbsolutePath().toString());
-
-    UpgradeTestUtils.createVersionFile(omSubdir, HddsProtos.NodeType.OM, 
serializedApparentVersion);
-
-    MiniOzoneCluster.Builder clusterBuilder = 
MiniOzoneCluster.newBuilder(conf).withoutDatanodes();
-
-    String expectedMessage =
-        "Initialization failed. Disk contains unknown apparent version " + 
serializedApparentVersion
-            + " for software version " + SOFTWARE_VERSION + ". Make sure OM 
was not downgraded after"
-            + " finalization";
-
-    GenericTestUtils.withLogDisabled(MiniOzoneClusterImpl.class, () -> {
-      IOException ioException = assertThrows(IOException.class, 
clusterBuilder::build);
-      assertEquals(expectedMessage, ioException.getMessage());
-    });
-  }
-}
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
index fee4e8e13e2..af2a775193d 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
@@ -2034,6 +2034,10 @@ public void start() throws IOException {
     LOG.info(buildRpcServerStartMessage("OzoneManager RPC server",
         omRpcAddress));
 
+    // If the OM stopped during a snapshot install after the DB was replaced, 
the VERSION file is behind the DB,
+    // and the finalization included in the snapshot is not in the Raft log to 
be replayed.
+    versionManager.finalizeFromDBIfRequired(metadataManager.getMetaTable());
+
     metadataManager.start(configuration);
 
     startSecretManagerIfNecessary();
@@ -2173,6 +2177,10 @@ public void restart() throws IOException {
     metrics.startSnapshotDirectoryMetrics(configuration, getMetadataManager());
 
     initializeRatisServer(false);
+    // If the OM stopped during a snapshot install after the DB was replaced, 
the VERSION file is behind the DB,
+    // and the finalization included in the snapshot is not in the Raft log to 
be replayed.
+    // Ratis must be initialized first so that upgrade actions (e.g. quota 
repair) can check leader status.
+    versionManager.finalizeFromDBIfRequired(metadataManager.getMetaTable());
     if (omRatisServer != null) {
       omRatisServer.start();
     }
diff --git 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMStartupVersionReconciliation.java
 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMStartupVersionReconciliation.java
new file mode 100644
index 00000000000..44ecc832a2a
--- /dev/null
+++ 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMStartupVersionReconciliation.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om;
+
+import static org.apache.hadoop.ozone.OzoneConsts.APPARENT_VERSION_KEY;
+import static org.apache.hadoop.ozone.OzoneManagerVersion.SOFTWARE_VERSION;
+import static 
org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature.INITIAL_VERSION;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.client.ScmTopologyClient;
+import org.apache.hadoop.hdds.scm.protocol.ScmBlockLocationProtocol;
+import 
org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationInternalInterface;
+import org.apache.hadoop.hdds.security.token.OzoneBlockTokenSecretManager;
+import org.apache.hadoop.hdds.server.ServerUtils;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.apache.ozone.test.HddsWhiteboxTestUtils;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+/**
+ * Verifies that the real OM startup path is wired to the version manager. The 
version manager logic itself is covered
+ * by {@link org.apache.hadoop.ozone.om.upgrade.TestOMVersionManager}, which 
calls it directly and would still pass if
+ * these calls were removed from OM startup.
+ */
+public class TestOMStartupVersionReconciliation {
+
+  @TempDir
+  private Path folder;
+
+  /**
+   * An OM that crashed after replacing its DB with a finalized checkpoint, 
but before updating its VERSION file, must
+   * finalize from the DB in {@link OzoneManager#start()}.
+   */
+  @Test
+  public void testStartCallsFinalizeFromDB() throws Exception {
+    // VERSION file starts at INITIAL_VERSION, simulating an OM that has not 
yet been finalized.
+    OzoneConfiguration conf = createOMStorage(INITIAL_VERSION.serialize());
+    OzoneManager om = OzoneManager.createOm(conf, 
OzoneManager.StartupOption.REGUALR);
+    try {
+      // Inject mock SCM dependencies (same pattern as OmTestManagers, split 
to allow DB seeding before start).
+      Object keyManager = HddsWhiteboxTestUtils.getInternalState(om, 
"keyManager");
+      ScmBlockLocationProtocol scmBlockClient = new 
ScmBlockLocationTestingClient(null, null, 0);
+      ScmClient scmClient = new ScmClient(scmBlockClient, 
mock(StorageContainerLocationInternalInterface.class), conf);
+      HddsWhiteboxTestUtils.setInternalState(om, "scmClient", scmClient);
+      HddsWhiteboxTestUtils.setInternalState(keyManager, "scmClient", 
scmClient);
+      HddsWhiteboxTestUtils.setInternalState(keyManager, "secretManager", 
mock(OzoneBlockTokenSecretManager.class));
+      HddsWhiteboxTestUtils.setInternalState(om, "scmTopologyClient", new 
ScmTopologyClient(scmBlockClient));
+
+      // Simulate the crash state: DB is at SOFTWARE_VERSION, VERSION file is 
at INITIAL_VERSION.
+      
assertThat(om.getVersionManager().getApparentVersion()).isEqualTo(INITIAL_VERSION);
+      om.getMetadataManager().getMetaTable().put(APPARENT_VERSION_KEY, 
String.valueOf(SOFTWARE_VERSION.serialize()));
+
+      om.start();
+
+      // Finalization in start() is synchronous, so check before Ratis has a 
chance to do anything else.
+      
assertThat(om.getVersionManager().getApparentVersion()).isEqualTo(SOFTWARE_VERSION);
+      assertThat(new 
OMStorage(conf).getApparentVersion()).isEqualTo(SOFTWARE_VERSION.serialize());
+    } finally {
+      om.stop();
+    }
+  }
+
+  @Test
+  public void testStartupRejectsUnknownApparentVersion() throws Exception {
+    int serializedApparentVersion = SOFTWARE_VERSION.serialize() + 1;
+    OzoneConfiguration conf = createOMStorage(serializedApparentVersion);
+
+    String expectedMessage = "Initialization failed. Disk contains unknown 
apparent version "
+        + serializedApparentVersion + " for software version " + 
SOFTWARE_VERSION
+        + ". Make sure OM was not downgraded after finalization";
+
+    IOException ioException =
+        assertThrows(IOException.class, () -> OzoneManager.createOm(conf, 
OzoneManager.StartupOption.REGUALR));
+    assertEquals(expectedMessage, ioException.getMessage());
+  }
+
+  private OzoneConfiguration createOMStorage(int serializedApparentVersion) 
throws IOException {
+    OzoneConfiguration conf = new OzoneConfiguration();
+    ServerUtils.setOzoneMetaDirPath(conf, folder.toAbsolutePath().toString());
+    conf.setInt(OMStorage.TESTING_INIT_APPARENT_VERSION_KEY, 
serializedApparentVersion);
+    conf.set(ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY, "127.0.0.1:0");
+    conf.setIfUnset(OMConfigKeys.OZONE_OM_S3_GPRC_SERVER_ENABLED, "false");
+    DefaultMetricsSystem.setMiniClusterMode(true);
+    OzoneManager.setTestSecureOmFlag(true);
+
+    OMStorage omStorage = new OMStorage(conf);
+    omStorage.setClusterId("omtest");
+    omStorage.setOmId("omtest");
+    omStorage.initialize();
+    return conf;
+  }
+}
diff --git 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/upgrade/TestOMVersionManager.java
 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/upgrade/TestOMVersionManager.java
index 6ec8a7d23aa..e09a7bbb0ed 100644
--- 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/upgrade/TestOMVersionManager.java
+++ 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/upgrade/TestOMVersionManager.java
@@ -57,7 +57,7 @@
 import org.apache.hadoop.ozone.om.OMConfigKeys;
 import org.apache.hadoop.ozone.om.OMStorage;
 import org.apache.hadoop.ozone.om.OzoneManager;
-import org.apache.hadoop.ozone.upgrade.AbstractComponentVersionManagerTest;
+import org.apache.hadoop.ozone.upgrade.AbstractRatisBasedVersionManagerTest;
 import org.apache.hadoop.ozone.upgrade.ComponentUpgradeActionProvider;
 import org.apache.hadoop.ozone.upgrade.UpgradeException;
 import org.junit.jupiter.api.BeforeEach;
@@ -70,7 +70,7 @@
  * Tests for {@link OMVersionManager}. Shared abstract tests use an empty 
upgrade-action map; action behavior is
  * covered with map-based providers and a required classpath discovery test.
  */
-class TestOMVersionManager extends AbstractComponentVersionManagerTest {
+class TestOMVersionManager extends AbstractRatisBasedVersionManagerTest {
 
   private static final List<ComponentVersion> ALL_VERSIONS;
 
@@ -124,6 +124,12 @@ protected ComponentVersion expectedSoftwareVersion() {
     return OzoneManagerVersion.SOFTWARE_VERSION;
   }
 
+  @Override
+  protected ComponentVersion lastLayoutFeature() {
+    OMLayoutFeature[] features = OMLayoutFeature.values();
+    return features[features.length - 1];
+  }
+
   @Override
   @Test
   public void testClasspathScanDiscoversUpgradeActions() throws Exception {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to