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

weichiu 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 8ced4a73d92 HDDS-13473. Amend validation for 
OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES (#8829)
8ced4a73d92 is described below

commit 8ced4a73d92ee3e59da03b8c5b9c0daf6b3dd3d1
Author: Siyao Meng <[email protected]>
AuthorDate: Tue Jul 22 10:44:16 2025 -0700

    HDDS-13473. Amend validation for OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES (#8829)
---
 .../apache/hadoop/ozone/om/OmSnapshotManager.java  |  4 +-
 .../org/apache/hadoop/ozone/om/OmTestManagers.java | 18 ++++++
 .../hadoop/ozone/om/TestOmSnapshotManager.java     | 10 ----
 .../ozone/om/TestOmSnapshotManagerConfig.java      | 67 ++++++++++++++++++++++
 .../src/test/resources/junit-platform.properties   | 27 +++++++++
 5 files changed, 114 insertions(+), 12 deletions(-)

diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java
index 80301fd47ba..c8a437e0302 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java
@@ -217,8 +217,8 @@ public OmSnapshotManager(OzoneManager ozoneManager) {
         OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES,
         OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES_DEFAULT
     );
-    Preconditions.checkArgument(this.maxOpenSstFilesInSnapshotDb > 0,
-        OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES + " must be positive.");
+    Preconditions.checkArgument(this.maxOpenSstFilesInSnapshotDb >= -1,
+        OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES + " value should be larger than or 
equal to -1.");
 
     ColumnFamilyHandle snapDiffJobCf;
     ColumnFamilyHandle snapDiffReportCf;
diff --git 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/OmTestManagers.java
 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/OmTestManagers.java
index 154f608d324..0e0088430ce 100644
--- 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/OmTestManagers.java
+++ 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/OmTestManagers.java
@@ -156,4 +156,22 @@ public KeyProviderCryptoExtension kmsProviderInit() {
     return kmsProvider;
   }
 
+  /**
+   * Stops all managed components and releases resources.
+   */
+  public void stop() {
+    try {
+      if (rpcClient != null) {
+        rpcClient.close();
+      }
+    } catch (IOException e) {
+      // Log but don't fail the stop operation
+      System.err.println("Error closing RPC client: " + e.getMessage());
+    }
+
+    if (om != null) {
+      om.stop();
+    }
+  }
+
 }
diff --git 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
index 62302f557be..5a688092023 100644
--- 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
+++ 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
@@ -719,14 +719,4 @@ private SnapshotInfo createSnapshotInfo(String volumeName,
         UUID.randomUUID(),
         Time.now());
   }
-
-  @Test
-  void testNegativeMaxOpenFiles(@TempDir File tempDir) throws Exception {
-    OzoneConfiguration conf = new OzoneConfiguration();
-    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, tempDir.getAbsolutePath());
-    conf.setInt(OMConfigKeys.OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES, 0);
-    conf.setBoolean(OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY, true);
-
-    assertThrows(IllegalArgumentException.class, () -> new 
OmTestManagers(conf));
-  }
 }
diff --git 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManagerConfig.java
 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManagerConfig.java
new file mode 100644
index 00000000000..aba81682c18
--- /dev/null
+++ 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManagerConfig.java
@@ -0,0 +1,67 @@
+/*
+ * 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.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.io.File;
+import org.apache.hadoop.hdds.HddsConfigKeys;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.parallel.Execution;
+import org.junit.jupiter.api.parallel.ExecutionMode;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+/**
+ * Unit test for OmSnapshotManager configuration validation.
+ */
+class TestOmSnapshotManagerConfig {
+
+  @ParameterizedTest
+  @CsvSource({
+      "-2, true,  'Invalid value: -2 should throw IllegalArgumentException'",
+      "-1, false, 'Valid value: -1 should not throw exception'",
+      "0,  false, 'Valid value: 0 should not throw exception'",
+      "1,  false, 'Valid value: 1 should not throw exception'",
+  })
+  @Execution(ExecutionMode.CONCURRENT)
+  void testMaxOpenFilesConfig(int maxOpenFiles, boolean shouldThrowException,
+      String description, @TempDir File tempDir) {
+    OzoneConfiguration conf = new OzoneConfiguration();
+
+    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, tempDir.getAbsolutePath());
+    conf.setBoolean(OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY, true);
+    conf.setInt(OMConfigKeys.OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES, 
maxOpenFiles);
+
+    // Configure dynamic ports to avoid conflicts during parallel execution
+    conf.set(OMConfigKeys.OZONE_OM_ADDRESS_KEY, "127.0.0.1:0");
+    conf.set(OMConfigKeys.OZONE_OM_HTTP_ADDRESS_KEY, "127.0.0.1:0");
+    conf.set(OMConfigKeys.OZONE_OM_HTTPS_ADDRESS_KEY, "127.0.0.1:0");
+    conf.set(OMConfigKeys.OZONE_OM_RATIS_PORT_KEY, "0");
+    conf.set(OMConfigKeys.OZONE_OM_GRPC_PORT_KEY, "0");
+
+    if (shouldThrowException) {
+      assertThrows(IllegalArgumentException.class, () -> new 
OmTestManagers(conf), description);
+    } else {
+      OmTestManagers testManagers = assertDoesNotThrow(() -> new 
OmTestManagers(conf), description);
+      testManagers.stop();
+    }
+  }
+}
diff --git 
a/hadoop-ozone/ozone-manager/src/test/resources/junit-platform.properties 
b/hadoop-ozone/ozone-manager/src/test/resources/junit-platform.properties
new file mode 100644
index 00000000000..2b0dc6d434f
--- /dev/null
+++ b/hadoop-ozone/ozone-manager/src/test/resources/junit-platform.properties
@@ -0,0 +1,27 @@
+# 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.
+
+# Enable parallel execution
+junit.jupiter.execution.parallel.enabled=true
+# Still, run test classes sequentially by default
+junit.jupiter.execution.parallel.mode.default=same_thread
+junit.jupiter.execution.parallel.mode.classes.default=same_thread
+
+# Configure the parallelism strategy
+junit.jupiter.execution.parallel.config.strategy=dynamic
+# See 
https://docs.junit.org/snapshot/user-guide/#writing-tests-parallel-execution-config
+junit.jupiter.execution.parallel.config.dynamic.factor=1


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

Reply via email to