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 ac4278ac630 HDDS-16090. Parameterize TestOzoneShellHA with follower
read (#10954)
ac4278ac630 is described below
commit ac4278ac630d346a23985c312376374d9437d788
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Thu Aug 6 07:25:15 2026 +0200
HDDS-16090. Parameterize TestOzoneShellHA with follower read (#10954)
---
.../hadoop/ozone/shell/TestOzoneShellHA.java | 109 +++++++++++++--------
.../ozone/shell/TestOzoneShellHAWithFSO.java | 43 --------
.../shell/TestOzoneShellHAWithFollowerRead.java | 42 ++++----
3 files changed, 87 insertions(+), 107 deletions(-)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
index 12f3929277d..00b070e29d2 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
@@ -34,6 +34,7 @@
import static
org.apache.hadoop.ozone.om.helpers.BucketLayout.FILE_SYSTEM_OPTIMIZED;
import static org.apache.hadoop.ozone.om.helpers.BucketLayout.LEGACY;
import static org.apache.hadoop.ozone.om.helpers.BucketLayout.OBJECT_STORE;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -96,10 +97,12 @@
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus;
+import org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServerConfig;
import org.apache.hadoop.ozone.om.service.OpenKeyCleanupService;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.ToolRunner;
import org.apache.ozone.test.GenericTestUtils;
+import org.apache.ratis.server.RaftServerConfigKeys;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
@@ -110,6 +113,10 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.AfterParameterizedClassInvocation;
+import org.junit.jupiter.params.BeforeParameterizedClassInvocation;
+import org.junit.jupiter.params.Parameter;
+import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.slf4j.Logger;
@@ -126,6 +133,8 @@
* This class tests Ozone sh shell command.
* Inspired by TestS3Shell
*/
+@ParameterizedClass
+@ValueSource(booleans = {true, false})
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@TestMethodOrder(OrderAnnotation.class)
public class TestOzoneShellHA {
@@ -140,9 +149,9 @@ public class TestOzoneShellHA {
private static File kmsDir;
private static File testFile;
private static String testFilePathString;
- private static MiniOzoneHAClusterImpl cluster = null;
+ private MiniOzoneHAClusterImpl cluster;
private static MiniKMS miniKMS;
- private static OzoneClient client;
+ private OzoneClient client;
private OzoneShell ozoneShell = null;
private OzoneAdmin ozoneAdminShell = null;
@@ -154,59 +163,67 @@ public class TestOzoneShellHA {
private static String omServiceId;
private static int numOfOMs;
- private static OzoneConfiguration ozoneConfiguration;
+ @Parameter
+ private boolean followerReadEnabled;
- @BeforeAll
+ @BeforeParameterizedClassInvocation
public void init() throws Exception {
- OzoneConfiguration conf = new OzoneConfiguration();
- conf.setBoolean(OZONE_HBASE_ENHANCEMENTS_ALLOWED, true);
- conf.setBoolean(OZONE_FS_HSYNC_ENABLED, true);
- startKMS();
- startCluster(conf);
+ cluster = startCluster(followerReadEnabled);
+ cluster.waitForClusterToBeReady();
+ client = cluster.newClient();
}
- protected static void startKMS() throws Exception {
+ @BeforeAll
+ static void startKMS() throws Exception {
+ testFilePathString = path + OZONE_URI_DELIMITER + "testFile";
+ testFile = new File(testFilePathString);
+ FileUtils.touch(testFile);
+
MiniKMS.Builder miniKMSBuilder = new MiniKMS.Builder();
miniKMS = miniKMSBuilder.setKmsConfDir(kmsDir).build();
miniKMS.start();
}
- protected static void startCluster(OzoneConfiguration conf) throws Exception
{
-
- testFilePathString = path + OZONE_URI_DELIMITER + "testFile";
- testFile = new File(testFilePathString);
- FileUtils.touch(testFile);
-
+ static MiniOzoneHAClusterImpl startCluster(boolean followerReadEnabled)
throws Exception {
// Init HA cluster
- omServiceId = "om-service-test1";
+ omServiceId = uniqueObjectName("om-service-test");
numOfOMs = 3;
final int numDNs = 5;
+ OzoneConfiguration conf = new OzoneConfiguration();
+ conf.setBoolean(OZONE_HBASE_ENHANCEMENTS_ALLOWED, true);
+ conf.setBoolean("ozone.client.hbase.enhancements.allowed", true);
+ conf.setBoolean(OZONE_FS_HSYNC_ENABLED, true);
conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH,
getKeyProviderURI(miniKMS));
conf.setInt(OMConfigKeys.OZONE_DIR_DELETING_SERVICE_INTERVAL, 10);
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, true);
conf.setInt(ScmConfigKeys.OZONE_SCM_CONTAINER_LIST_MAX_COUNT, 1);
conf.setBoolean(OMConfigKeys.OZONE_KEY_LIFECYCLE_SERVICE_ENABLED, true);
- ozoneConfiguration = conf;
+
+ conf.setBoolean("ozone.om.allow.leader.skip.linearizable.read",
followerReadEnabled);
+ conf.setBoolean("ozone.client.follower.read.enabled", followerReadEnabled);
+ OzoneManagerRatisServerConfig omRatisConfig =
conf.getObject(OzoneManagerRatisServerConfig.class);
+ omRatisConfig.setReadLeaderLeaseEnabled(followerReadEnabled);
+ RaftServerConfigKeys.Read.Option option = followerReadEnabled
+ ? RaftServerConfigKeys.Read.Option.LINEARIZABLE
+ : RaftServerConfigKeys.Read.Option.DEFAULT;
+ omRatisConfig.setReadOption(option.name());
+ conf.setFromObject(omRatisConfig);
+
MiniOzoneHAClusterImpl.Builder builder =
MiniOzoneCluster.newHABuilder(conf);
builder.setOMServiceId(omServiceId)
.setNumOfOzoneManagers(numOfOMs)
.setNumDatanodes(numDNs);
- cluster = builder.build();
- cluster.waitForClusterToBeReady();
- client = cluster.newClient();
+ return builder.build();
}
- /**
- * shutdown MiniOzoneCluster.
- */
- @AfterAll
+ @AfterParameterizedClassInvocation
public void shutdown() {
- IOUtils.closeQuietly(client);
- if (cluster != null) {
- cluster.shutdown();
- }
+ IOUtils.closeQuietly(client, cluster);
+ }
+ @AfterAll
+ void stopKMS() {
if (miniKMS != null) {
miniKMS.stop();
}
@@ -231,7 +248,11 @@ public void reset() {
System.setErr(OLD_ERR);
}
- protected void execute(GenericCli shell, String[] args) {
+ private void execute(GenericCli shell, String[] args) {
+ execute(cluster.getConf(), shell, args);
+ }
+
+ static void execute(OzoneConfiguration conf, GenericCli shell, String[]
args) {
LOG.info("Executing OzoneShell command with args {}", Arrays.asList(args));
CommandLine cmd = shell.getCmd();
@@ -252,7 +273,7 @@ public List<Object>
handleExecutionException(ExecutionException ex,
// Since there is no elegant way to pass Ozone config to the shell,
// the idea is to use 'set' to place those OM HA configs.
- String[] argsWithHAConf = getHASetConfStrings(args);
+ String[] argsWithHAConf = getHASetConfStrings(args, conf);
cmd.parseWithHandlers(new RunLast(), exceptionHandler, argsWithHAConf);
}
@@ -286,11 +307,11 @@ private String getLeaderOMNodeId() {
return omLeader.getOMNodeId();
}
- private String getSetConfStringFromConf(String key) {
- return String.format("--set=%s=%s", key, cluster.getConf().get(key));
+ static String getSetConfStringFromConf(String key, OzoneConfiguration conf) {
+ return generateSetConfString(key, conf.get(key));
}
- private String generateSetConfString(String key, String value) {
+ static String generateSetConfString(String key, String value) {
return String.format("--set=%s=%s", key, value);
}
@@ -299,9 +320,10 @@ private String generateSetConfString(String key, String
value) {
* @param numOfArgs Additional number of arguments after the HA conf string,
* this translates into the number of empty array elements
* after the HA conf string.
+ * @param conf
* @return String array.
*/
- private String[] getHASetConfStrings(int numOfArgs) {
+ static String[] getHASetConfStrings(int numOfArgs, OzoneConfiguration conf) {
assert (numOfArgs >= 0);
String[] res = new String[1 + 1 + numOfOMs + numOfArgs];
final int indexOmServiceIds = 0;
@@ -309,11 +331,11 @@ private String[] getHASetConfStrings(int numOfArgs) {
final int indexOmAddressStart = 2;
res[indexOmServiceIds] = getSetConfStringFromConf(
- OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY);
+ OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY, conf);
String omNodesKey = ConfUtils.addKeySuffixes(
OMConfigKeys.OZONE_OM_NODES_KEY, omServiceId);
- String omNodesVal = cluster.getConf().get(omNodesKey);
+ String omNodesVal = conf.get(omNodesKey);
res[indexOmNodes] = generateSetConfString(omNodesKey, omNodesVal);
String[] omNodesArr = omNodesVal.split(",");
@@ -322,7 +344,7 @@ private String[] getHASetConfStrings(int numOfArgs) {
for (int i = 0; i < numOfOMs; i++) {
res[indexOmAddressStart + i] =
getSetConfStringFromConf(ConfUtils.addKeySuffixes(
- OMConfigKeys.OZONE_OM_ADDRESS_KEY, omServiceId, omNodesArr[i]));
+ OMConfigKeys.OZONE_OM_ADDRESS_KEY, omServiceId, omNodesArr[i]),
conf);
}
return res;
@@ -331,11 +353,12 @@ private String[] getHASetConfStrings(int numOfArgs) {
/**
* Helper function to create a new set of arguments that contains HA configs.
* @param existingArgs Existing arguments to be fed into OzoneShell command.
+ * @param conf
* @return String array.
*/
- private String[] getHASetConfStrings(String[] existingArgs) {
+ static String[] getHASetConfStrings(String[] existingArgs,
OzoneConfiguration conf) {
// Get a String array populated with HA configs first
- String[] res = getHASetConfStrings(existingArgs.length);
+ String[] res = getHASetConfStrings(existingArgs.length, conf);
int indexCopyStart = res.length - existingArgs.length;
// Then copy the existing args to the returned String array
@@ -1810,7 +1833,7 @@ public void testSetEncryptionKey() throws Exception {
client.getObjectStore().getVolume(volumeName);
OzoneBucket bucket = volume.getBucket("bucket0");
assertNull(bucket.getEncryptionKeyName());
- String newEncKey = "enckey1";
+ String newEncKey = uniqueObjectName("enckey");
KeyProvider provider = cluster.getOzoneManager().getKmsProvider();
KeyProvider.Options options = KeyProvider.options(cluster.getConf());
@@ -2379,8 +2402,8 @@ public void testVolumeListKeys()
@ValueSource(ints = {1, 5})
public void testRecursiveVolumeDelete(int threadCount)
throws Exception {
- String volume1 = "volume10";
- String volume2 = "volume20";
+ String volume1 = uniqueObjectName("volume10");
+ String volume2 = uniqueObjectName("volume20");
// Create volume volume1
// Create bucket bucket1 with layout FILE_SYSTEM_OPTIMIZED
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHAWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHAWithFSO.java
deleted file mode 100644
index 027d2851de8..00000000000
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHAWithFSO.java
+++ /dev/null
@@ -1,43 +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.shell;
-
-import org.apache.hadoop.hdds.conf.OzoneConfiguration;
-import org.apache.hadoop.ozone.OzoneConfigKeys;
-import org.apache.hadoop.ozone.om.OMConfigKeys;
-import org.junit.jupiter.api.BeforeAll;
-
-/**
- * This class tests Ozone sh shell command with FSO.
- * Inspired by TestS3Shell
- */
-public class TestOzoneShellHAWithFSO extends TestOzoneShellHA {
-
- @BeforeAll
- @Override
- public void init() throws Exception {
- OzoneConfiguration conf = new OzoneConfiguration();
- conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
- OMConfigKeys.OZONE_BUCKET_LAYOUT_FILE_SYSTEM_OPTIMIZED);
- conf.setBoolean(OzoneConfigKeys.OZONE_HBASE_ENHANCEMENTS_ALLOWED, true);
- conf.setBoolean("ozone.client.hbase.enhancements.allowed", true);
- conf.setBoolean(OzoneConfigKeys.OZONE_FS_HSYNC_ENABLED, true);
- startKMS();
- startCluster(conf);
- }
-}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHAWithFollowerRead.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHAWithFollowerRead.java
index 605ed82b89c..41770a829ab 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHAWithFollowerRead.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHAWithFollowerRead.java
@@ -21,38 +21,30 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.apache.hadoop.hdds.cli.GenericCli;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
-import org.apache.hadoop.ozone.OzoneConfigKeys;
+import org.apache.hadoop.hdds.utils.IOUtils;
+import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl;
import org.apache.hadoop.ozone.om.OzoneManager;
-import org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServerConfig;
-import org.apache.ratis.server.RaftServerConfigKeys;
+import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
/**
* This class tests Ozone sh shell command with FollowerRead.
- * Inspired by TestS3Shell
*/
-public class TestOzoneShellHAWithFollowerRead extends TestOzoneShellHA {
+public class TestOzoneShellHAWithFollowerRead {
- @BeforeAll
- @Override
- public void init() throws Exception {
- OzoneConfiguration conf = new OzoneConfiguration();
+ private static MiniOzoneHAClusterImpl cluster;
- OzoneManagerRatisServerConfig omHAConfig =
- conf.getObject(OzoneManagerRatisServerConfig.class);
-
omHAConfig.setReadOption(RaftServerConfigKeys.Read.Option.LINEARIZABLE.name());
+ @BeforeAll
+ static void init() throws Exception {
+ cluster = TestOzoneShellHA.startCluster(true);
+ }
- conf.setFromObject(omHAConfig);
- conf.setBoolean(OzoneConfigKeys.OZONE_HBASE_ENHANCEMENTS_ALLOWED, true);
- conf.setBoolean("ozone.client.hbase.enhancements.allowed", true);
- conf.setBoolean("ozone.om.ha.raft.server.read.leader.lease.enabled", true);
- conf.setBoolean("ozone.om.allow.leader.skip.linearizable.read", true);
- conf.setBoolean("ozone.client.follower.read.enabled", true);
- conf.setBoolean(OzoneConfigKeys.OZONE_FS_HSYNC_ENABLED, true);
- startKMS();
- startCluster(conf);
+ @AfterAll
+ static void shutdown() {
+ IOUtils.closeQuietly(cluster);
}
@Test
@@ -137,4 +129,12 @@ public void testAllowFollowerReadLocalLease() throws
Exception {
}
}
}
+
+ private static MiniOzoneHAClusterImpl getCluster() {
+ return cluster;
+ }
+
+ private static void execute(GenericCli shell, String[] args) {
+ TestOzoneShellHA.execute(cluster.getConf(), shell, args);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]