Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -749,14 +749,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));
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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
junit.jupiter.execution.parallel.mode.default=concurrent

# Still, run test classes sequentially by default
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
Loading