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 398709d6b68 HDDS-15709. Replace random name suffix with
uniqueObjectName (#10773)
398709d6b68 is described below
commit 398709d6b68312306149144795c5796d4d3fa8b3
Author: Prathmesh Sapate <[email protected]>
AuthorDate: Wed Jul 15 20:35:08 2026 +0530
HDDS-15709. Replace random name suffix with uniqueObjectName (#10773)
---
.../ozone/AbstractRootedOzoneFileSystemTest.java | 14 +++----
.../java/org/apache/hadoop/fs/ozone/TestHSync.java | 4 +-
.../apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java | 6 +--
.../hdds/scm/TestContainerReportWithKeys.java | 7 ++--
.../java/org/apache/hadoop/ozone/TestDataUtil.java | 9 +++--
.../ozone/client/rpc/OzoneRpcClientTests.java | 25 +++++++------
.../rpc/TestOzoneRpcClientForAclAuditLog.java | 6 +--
.../ozone/om/AbstractOzoneManagerHATest.java | 11 +++---
.../apache/hadoop/ozone/om/BucketForTesting.java | 6 +--
.../hadoop/ozone/om/TestAddRemoveOzoneManager.java | 6 +--
.../hadoop/ozone/om/TestListKeysWithFSO.java | 12 +++---
.../apache/hadoop/ozone/om/TestOMBootstrap.java | 5 ++-
.../TestOMDbCheckpointServletInodeBasedXfer.java | 22 +++++------
.../ozone/om/TestOMRatisSnapshotTransfer.java | 5 ++-
.../hadoop/ozone/om/TestOMRatisSnapshots.java | 5 ++-
.../hadoop/ozone/om/TestObjectStoreWithFSO.java | 8 ++--
.../hadoop/ozone/om/TestOmBlockVersioning.java | 13 ++++---
...stOzoneManagerHAFollowerReadWithAllRunning.java | 7 ++--
.../ozone/om/TestOzoneManagerHAWithAllRunning.java | 13 ++++---
.../om/TestOzoneManagerHAWithStoppedNodes.java | 9 +++--
.../hadoop/ozone/om/TestOzoneManagerRestart.java | 20 +++++-----
.../hadoop/ozone/om/TestRecursiveAclWithFSO.java | 6 +--
.../apache/hadoop/ozone/om/TestScmSafeMode.java | 8 ++--
...TestSnapshotDeletingServiceIntegrationTest.java | 6 +--
.../hadoop/ozone/om/snapshot/OmSnapshotTests.java | 43 +++++++++++-----------
.../ozone/om/snapshot/TestOmSnapshotDisabled.java | 8 ++--
.../om/snapshot/TestOmSnapshotDisabledRestart.java | 8 ++--
.../om/snapshot/TestOzoneManagerHASnapshot.java | 25 +++++++------
.../snapshot/TestOzoneManagerSnapshotProvider.java | 5 ++-
29 files changed, 168 insertions(+), 154 deletions(-)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
index 8c3e7c94c2d..44d9baec556 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
@@ -36,6 +36,7 @@
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.READ;
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.WRITE;
import static
org.apache.hadoop.security.UserGroupInformation.createUserForTesting;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -415,11 +416,10 @@ void testListStatusIteratorOnSubDirs() throws Exception {
* OFS: Helper function for tests. Return a volume name that doesn't exist.
*/
protected String getRandomNonExistVolumeName() throws IOException {
- final int numDigit = 5;
long retriesLeft = Math.round(Math.pow(10, 5));
String name = null;
while (name == null && retriesLeft-- > 0) {
- name = "volume-" + RandomStringUtils.secure().nextNumeric(numDigit);
+ name = uniqueObjectName("volume-");
// Check volume existence.
Iterator<? extends OzoneVolume> iter =
objectStore.listVolumesByUser(null, name, null);
@@ -447,7 +447,7 @@ void testMkdirOnNonExistentVolumeBucketDir() throws
Exception {
"tuned for FS Path yet");
String volumeNameLocal = getRandomNonExistVolumeName();
- String bucketNameLocal = "bucket-" +
RandomStringUtils.secure().nextNumeric(5);
+ String bucketNameLocal = uniqueObjectName("bucket-");
Path root = new Path("/" + volumeNameLocal + "/" + bucketNameLocal);
Path dir1 = new Path(root, "dir1");
Path dir12 = new Path(dir1, "dir12");
@@ -488,7 +488,7 @@ void testMkdirOnNonExistentVolumeBucketDir() throws
Exception {
@Test
void testMkdirNonExistentVolumeBucket() throws Exception {
String volumeNameLocal = getRandomNonExistVolumeName();
- String bucketNameLocal = "bucket-" +
RandomStringUtils.secure().nextNumeric(5);
+ String bucketNameLocal = uniqueObjectName("bucket-");
Path newVolBucket = new Path(
"/" + volumeNameLocal + "/" + bucketNameLocal);
fs.mkdirs(newVolBucket);
@@ -654,7 +654,7 @@ protected OzoneKeyDetails getKey(Path keyPath, boolean
isDirectory)
*/
private Path createRandomVolumeBucketWithDirs() throws IOException {
String volume1 = getRandomNonExistVolumeName();
- String bucket1 = "bucket-" + RandomStringUtils.secure().nextNumeric(5);
+ String bucket1 = uniqueObjectName("bucket-");
Path bucketPath1 = new Path(OZONE_URI_DELIMITER + volume1 +
OZONE_URI_DELIMITER + bucket1);
@@ -693,7 +693,7 @@ void testListStatusWithDifferentBucketOwner() throws
IOException {
objectStore.createVolume(volName);
OzoneVolume ozoneVolume = objectStore.getVolume(volName);
- String buckName = "bucket-" + RandomStringUtils.secure().nextNumeric(5);
+ String buckName = uniqueObjectName("bucket-");
UserGroupInformation currUgi = UserGroupInformation.getCurrentUser();
String bucketOwner = currUgi.getUserName() +
RandomStringUtils.secure().nextNumeric(5);
BucketArgs bucketArgs = BucketArgs.newBuilder()
@@ -2157,7 +2157,7 @@ private void verifyCopy(Path dstBucketPath, Job distcpJob,
private List<String> createFiles(Path srcBucketPath, int fileCount, short
factor) throws IOException {
List<String> createdFiles = new ArrayList<>();
for (int i = 1; i <= fileCount; i++) {
- String keyName = "key" + RandomStringUtils.secure().nextNumeric(5);
+ String keyName = uniqueObjectName("key");
Path file = new Path(srcBucketPath, keyName);
try (FSDataOutputStream fsDataOutputStream = fs.create(file, factor)) {
fsDataOutputStream.writeBytes("Hello");
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestHSync.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestHSync.java
index 9643598e7e9..ec5887fff0e 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestHSync.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestHSync.java
@@ -34,6 +34,7 @@
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_LEASE_HARD_LIMIT;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_OPEN_KEY_CLEANUP_SERVICE_INTERVAL;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_OPEN_KEY_EXPIRE_THRESHOLD;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -719,8 +720,7 @@ public void testHsyncKeyCallCount() throws Exception {
// test file with all blocks pre-allocated
omMetrics.resetNumKeyHSyncs();
long writtenSize = 0;
- try (OzoneOutputStream outputStream = bucket.createKey("key-" +
- RandomStringUtils.secure().nextNumeric(5),
+ try (OzoneOutputStream outputStream =
bucket.createKey(uniqueObjectName("key-"),
BLOCK_SIZE * 2, ReplicationType.RATIS, ReplicationFactor.THREE, new
HashMap<>())) {
// make sure at least writing 2 blocks data
while (writtenSize <= BLOCK_SIZE) {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java
index 4647605a01c..3c0615c41c6 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java
@@ -19,13 +19,13 @@
import static org.apache.hadoop.hdds.HddsUtils.getHostName;
import static org.apache.hadoop.hdds.HddsUtils.getHostPort;
+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.assertNotNull;
import java.util.Optional;
import java.util.OptionalInt;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FsShell;
@@ -102,12 +102,12 @@ public void init() throws Exception {
assertEquals(LifeCycle.State.RUNNING, om.getOmRatisServerState());
- volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ volumeName = uniqueObjectName("volume");
ObjectStore objectStore = client.getObjectStore();
objectStore.createVolume(volumeName);
OzoneVolume retVolumeinfo = objectStore.getVolume(volumeName);
- bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ bucketName = uniqueObjectName("bucket");
retVolumeinfo.createBucket(bucketName);
rootPath = String.format("%s://%s.%s.%s/", OzoneConsts.OZONE_URI_SCHEME,
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestContainerReportWithKeys.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestContainerReportWithKeys.java
index 28c60a76e58..57be313bcde 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestContainerReportWithKeys.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestContainerReportWithKeys.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.hdds.scm;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -69,9 +70,9 @@ void cleanup() {
@Test
public void testContainerReportKeyWrite() throws Exception {
- final String volumeName = "volume" +
RandomStringUtils.secure().nextNumeric(5);
- final String bucketName = "bucket" +
RandomStringUtils.secure().nextNumeric(5);
- final String keyName = "key" + RandomStringUtils.secure().nextNumeric(5);
+ final String volumeName = uniqueObjectName("volume");
+ final String bucketName = uniqueObjectName("bucket");
+ final String keyName = uniqueObjectName("key");
final int keySize = 100;
ObjectStore objectStore = client.getObjectStore();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java
index 7ac80ef4058..dc0735c8f2e 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java
@@ -20,6 +20,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT_DEFAULT;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import com.google.common.collect.Maps;
@@ -193,7 +194,7 @@ public static OzoneBucket createBucket(OzoneClient client,
OzoneVolume volume = objectStore.getVolume(vol);
String sourceBucket = bukName;
if (createLinkedBucket) {
- sourceBucket = bukName + RandomStringUtils.secure().nextNumeric(5);
+ sourceBucket = uniqueObjectName(bukName);
}
volume.createBucket(sourceBucket, bucketArgs);
OzoneBucket ozoneBucket = volume.getBucket(sourceBucket);
@@ -232,12 +233,12 @@ public static OzoneBucket
createVolumeAndBucket(OzoneClient client, BucketLayout
final int attempts = 5;
for (int i = 0; i < attempts; i++) {
try {
- String volumeName = "volume" +
RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" +
RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
OzoneBucket ozoneBucket = createVolumeAndBucket(client, volumeName,
bucketName,
bucketLayout, replicationConfig);
if (createLinkedBucket) {
- String targetBucketName = ozoneBucket.getName() +
RandomStringUtils.secure().nextNumeric(5);
+ String targetBucketName = uniqueObjectName(ozoneBucket.getName());
ozoneBucket = createLinkedBucket(client, volumeName, bucketName,
targetBucketName);
}
return ozoneBucket;
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/OzoneRpcClientTests.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/OzoneRpcClientTests.java
index 8beb5d01118..9f20507f75b 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/OzoneRpcClientTests.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/OzoneRpcClientTests.java
@@ -55,6 +55,7 @@
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.READ;
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.WRITE;
import static org.apache.ozone.test.GenericTestUtils.getTestStartTime;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
@@ -2917,8 +2918,8 @@ public void testListVolume() throws IOException {
@Test
public void testListBucket()
throws IOException {
- String volumeA = "vol-a-" + RandomStringUtils.secure().nextNumeric(5);
- String volumeB = "vol-b-" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeA = uniqueObjectName("vol-a-");
+ String volumeB = uniqueObjectName("vol-b-");
store.createVolume(volumeA);
store.createVolume(volumeB);
OzoneVolume volA = store.getVolume(volumeA);
@@ -3014,10 +3015,10 @@ public void testListBucketsReplicationConfig()
@Test
public void testListKey()
throws IOException {
- String volumeA = "vol-a-" + RandomStringUtils.secure().nextNumeric(5);
- String volumeB = "vol-b-" + RandomStringUtils.secure().nextNumeric(5);
- String bucketA = "buc-a-" + RandomStringUtils.secure().nextNumeric(5);
- String bucketB = "buc-b-" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeA = uniqueObjectName("vol-a-");
+ String volumeB = uniqueObjectName("vol-b-");
+ String bucketA = uniqueObjectName("buc-a-");
+ String bucketB = uniqueObjectName("buc-b-");
store.createVolume(volumeA);
store.createVolume(volumeB);
OzoneVolume volA = store.getVolume(volumeA);
@@ -3165,8 +3166,8 @@ public void testListKeyDirectoriesAreNotFiles()
@Test
public void testListKeyOnEmptyBucket()
throws IOException {
- String volume = "vol-" + RandomStringUtils.secure().nextNumeric(5);
- String bucket = "buc-" + RandomStringUtils.secure().nextNumeric(5);
+ String volume = uniqueObjectName("vol-");
+ String bucket = uniqueObjectName("buc-");
store.createVolume(volume);
OzoneVolume vol = store.getVolume(volume);
vol.createBucket(bucket);
@@ -5166,10 +5167,10 @@ private void assertBucketCount(OzoneVolume volume,
@Test
public void testListSnapshot() throws IOException {
- String volumeA = "vol-a-" + RandomStringUtils.secure().nextNumeric(5);
- String volumeB = "vol-b-" + RandomStringUtils.secure().nextNumeric(5);
- String bucketA = "buc-a-" + RandomStringUtils.secure().nextNumeric(5);
- String bucketB = "buc-b-" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeA = uniqueObjectName("vol-a-");
+ String volumeB = uniqueObjectName("vol-b-");
+ String bucketA = uniqueObjectName("buc-a-");
+ String bucketB = uniqueObjectName("buc-b-");
store.createVolume(volumeA);
store.createVolume(volumeB);
OzoneVolume volA = store.getVolume(volumeA);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientForAclAuditLog.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientForAclAuditLog.java
index 2fe0dfa6672..596144b030c 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientForAclAuditLog.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientForAclAuditLog.java
@@ -25,6 +25,7 @@
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ADMINISTRATORS_WILDCARD;
import static
org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType.VOLUME;
import static org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType.OZONE;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -36,7 +37,6 @@
import java.util.List;
import net.jcip.annotations.NotThreadSafe;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import
org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB;
import org.apache.hadoop.ozone.MiniOzoneCluster;
@@ -163,7 +163,7 @@ public void testXXXAclSuccessAudits() throws Exception {
String userName = ugi.getUserName();
String adminName = ugi.getUserName();
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setAdmin(adminName)
@@ -211,7 +211,7 @@ public void testXXXAclFailureAudits() throws Exception {
String userName = "bilbo";
String adminName = "bilbo";
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setAdmin(adminName)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/AbstractOzoneManagerHATest.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/AbstractOzoneManagerHATest.java
index 4b25d66756b..8550b033ab5 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/AbstractOzoneManagerHATest.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/AbstractOzoneManagerHATest.java
@@ -30,6 +30,7 @@
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_KEY_DELETING_LIMIT_PER_TASK;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_S3_GPRC_SERVER_ENABLED;
+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;
@@ -220,7 +221,7 @@ public static void shutdown() {
* @return the key name.
*/
public static String createKey(OzoneBucket ozoneBucket) throws IOException {
- String keyName = "key" + RandomStringUtils.secure().nextNumeric(5);
+ String keyName = uniqueObjectName("key");
createKey(ozoneBucket, keyName);
return keyName;
}
@@ -234,7 +235,7 @@ public static void createKey(OzoneBucket ozoneBucket,
String keyName) throws IOE
}
public static String createPrefixName() {
- return "prefix" + RandomStringUtils.secure().nextNumeric(5) +
OZONE_URI_DELIMITER;
+ return uniqueObjectName("prefix") + OZONE_URI_DELIMITER;
}
public static void createPrefix(OzoneObj prefixObj) throws IOException {
@@ -272,7 +273,7 @@ protected OzoneBucket setupBucket() throws Exception {
protected OzoneBucket linkBucket(OzoneBucket srcBuk) throws Exception {
String userName = "user" + RandomStringUtils.secure().nextNumeric(5);
String adminName = "admin" + RandomStringUtils.secure().nextNumeric(5);
- String linkedVolName = "volume-link-" +
RandomStringUtils.secure().nextNumeric(5);
+ String linkedVolName = uniqueObjectName("volume-link-");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner(userName)
@@ -309,7 +310,7 @@ protected OzoneBucket linkBucket(OzoneBucket srcBuk) throws
Exception {
protected void createVolumeTest(boolean checkSuccess) throws Exception {
String userName = "user" + RandomStringUtils.secure().nextNumeric(5);
String adminName = "admin" + RandomStringUtils.secure().nextNumeric(5);
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner(userName)
@@ -399,7 +400,7 @@ protected void testCreateFile(OzoneBucket ozoneBucket,
String keyName,
protected void createKeyTest(boolean checkSuccess) throws Exception {
String userName = "user" + RandomStringUtils.secure().nextNumeric(5);
String adminName = "admin" + RandomStringUtils.secure().nextNumeric(5);
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner(userName)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/BucketForTesting.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/BucketForTesting.java
index 1720d58ee79..4c07c091d58 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/BucketForTesting.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/BucketForTesting.java
@@ -19,12 +19,12 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.THREE;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.ozone.TestDataUtil;
@@ -121,13 +121,13 @@ public BucketForTesting build() throws IOException {
ObjectStore objectStore = client.getObjectStore();
if (volume == null) { // TODO add setVolume
if (volumeName == null) { // TODO add setVolumeName
- volumeName = "vol" + RandomStringUtils.secure().nextNumeric(10);
+ volumeName = uniqueObjectName("vol");
}
objectStore.createVolume(volumeName);
volume = objectStore.getVolume(volumeName);
}
if (bucketName == null) { // TODO add setBucketName
- bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(10);
+ bucketName = uniqueObjectName("bucket");
}
volume.createBucket(bucketName);
return new BucketForTesting(volume.getBucket(bucketName));
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestAddRemoveOzoneManager.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestAddRemoveOzoneManager.java
index fe5269a1924..5f5dfea4fd5 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestAddRemoveOzoneManager.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestAddRemoveOzoneManager.java
@@ -22,6 +22,7 @@
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_DECOMMISSIONED_NODES_KEY;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RATIS_SERVER_REQUEST_TIMEOUT_DEFAULT;
import static org.apache.hadoop.ozone.om.OzoneManagerHATests.createKey;
+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;
@@ -38,7 +39,6 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.hdfs.server.common.Storage;
@@ -83,8 +83,8 @@ public class TestAddRemoveOzoneManager {
private static final String BUCKET_NAME;
static {
- VOLUME_NAME = "volume" + RandomStringUtils.secure().nextNumeric(5);
- BUCKET_NAME = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ VOLUME_NAME = uniqueObjectName("volume");
+ BUCKET_NAME = uniqueObjectName("bucket");
}
private OzoneClient client;
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java
index fc51c7f7609..30d38a6abbb 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java
@@ -19,6 +19,7 @@
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_LIST_CACHE_SIZE;
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_ITERATE_BATCH_SIZE;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -31,7 +32,6 @@
import java.util.List;
import java.util.Optional;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.StorageType;
@@ -96,15 +96,15 @@ void init() throws Exception {
builder.setBucketLayout(BucketLayout.FILE_SYSTEM_OPTIMIZED);
omBucketArgs = builder.build();
- String fsoBucketName = "bucket" +
RandomStringUtils.secure().nextNumeric(5);
+ String fsoBucketName = uniqueObjectName("bucket");
ozoneVolume.createBucket(fsoBucketName, omBucketArgs);
fsoOzoneBucket = ozoneVolume.getBucket(fsoBucketName);
- fsoBucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ fsoBucketName = uniqueObjectName("bucket");
ozoneVolume.createBucket(fsoBucketName, omBucketArgs);
fsoOzoneBucket2 = ozoneVolume.getBucket(fsoBucketName);
- fsoBucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ fsoBucketName = uniqueObjectName("bucket");
ozoneVolume.createBucket(fsoBucketName, omBucketArgs);
emptyFsoOzoneBucket = ozoneVolume.getBucket(fsoBucketName);
@@ -112,11 +112,11 @@ void init() throws Exception {
builder.setStorageType(StorageType.DISK);
builder.setBucketLayout(BucketLayout.LEGACY);
omBucketArgs = builder.build();
- String legacyBucketName = "bucket" +
RandomStringUtils.secure().nextNumeric(5);
+ String legacyBucketName = uniqueObjectName("bucket");
ozoneVolume.createBucket(legacyBucketName, omBucketArgs);
legacyOzoneBucket2 = ozoneVolume.getBucket(legacyBucketName);
- legacyBucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ legacyBucketName = uniqueObjectName("bucket");
ozoneVolume.createBucket(legacyBucketName, omBucketArgs);
emptyLegacyOzoneBucket = ozoneVolume.getBucket(legacyBucketName);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBootstrap.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBootstrap.java
index 2f63f0b6278..12e70bd2df0 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBootstrap.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBootstrap.java
@@ -22,6 +22,7 @@
import static org.apache.hadoop.ozone.om.TestOMRatisSnapshots.checkSnapshot;
import static
org.apache.hadoop.ozone.om.TestOMRatisSnapshots.createOzoneSnapshot;
import static org.apache.hadoop.ozone.om.TestOMRatisSnapshots.writeKeys;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.List;
@@ -106,8 +107,8 @@ public void init() throws Exception {
client = OzoneClientFactory.getRpcClient(OM_SERVICE_ID, conf);
objectStore = client.getObjectStore();
- volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ volumeName = uniqueObjectName("volume");
+ bucketName = uniqueObjectName("bucket");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner("user" + RandomStringUtils.secure().nextNumeric(5))
.setAdmin("admin" + RandomStringUtils.secure().nextNumeric(5))
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java
index 0e902ffa4e2..791b8e91a86 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java
@@ -29,6 +29,7 @@
import static
org.apache.hadoop.ozone.OzoneConsts.OZONE_DB_CHECKPOINT_INCLUDE_SNAPSHOT_DATA;
import static
org.apache.hadoop.ozone.OzoneConsts.OZONE_DB_CHECKPOINT_REQUEST_FLUSH;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RATIS_SNAPSHOT_MAX_TOTAL_SST_SIZE_KEY;
+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;
@@ -86,7 +87,6 @@
import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationFactor;
@@ -284,8 +284,8 @@ public void write(int b) throws IOException {
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void testTarballBatching(boolean includeSnapshots) throws Exception {
- String volumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "buck" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("vol");
+ String bucketName = uniqueObjectName("buck");
AtomicReference<DBCheckpoint> realCheckpoint = new AtomicReference<>();
setupClusterAndMocks(volumeName, bucketName, realCheckpoint,
includeSnapshots);
long maxFileSizeLimit = 4096;
@@ -346,8 +346,8 @@ public void testWriteDBToArchiveClosesFilesListStream()
throws Exception {
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void testContentsOfTarballWithSnapshot(boolean includeSnapshot)
throws Exception {
- String volumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "buck" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("vol");
+ String bucketName = uniqueObjectName("buck");
AtomicReference<DBCheckpoint> realCheckpoint = new AtomicReference<>();
setupClusterAndMocks(volumeName, bucketName, realCheckpoint,
includeSnapshot);
DBStore dbStore = om.getMetadataManager().getStore();
@@ -448,8 +448,8 @@ public void testContentsOfTarballWithSnapshot(boolean
includeSnapshot) throws Ex
*/
@Test
public void testSnapshotDBConsistency() throws Exception {
- String volumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "buck" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("vol");
+ String bucketName = uniqueObjectName("buck");
AtomicReference<DBCheckpoint> realCheckpoint = new AtomicReference<>();
setupClusterAndMocks(volumeName, bucketName, realCheckpoint, true);
List<OzoneSnapshot> snapshots = new ArrayList<>();
@@ -540,8 +540,8 @@ public void testWriteDBToArchive(boolean
expectOnlySstFiles) throws Exception {
*/
@Test
public void testBootstrapOnFollowerConsistency() throws Exception {
- String volumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "buck" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("vol");
+ String bucketName = uniqueObjectName("buck");
setupCluster();
om.getKeyManager().getSnapshotSstFilteringService().pause();
om.getKeyManager().getSnapshotDeletingService().suspend();
@@ -804,8 +804,8 @@ public void testBootstrapLockBlocksMultipleServices()
throws Exception {
*/
@Test
public void testCheckpointIncludesSnapshotsFromFrozenState() throws
Exception {
- String volumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "buck" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("vol");
+ String bucketName = uniqueObjectName("buck");
setupCluster();
om.getKeyManager().getSnapshotSstFilteringService().pause();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshotTransfer.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshotTransfer.java
index e283c81e162..ba5d3401a8d 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshotTransfer.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshotTransfer.java
@@ -23,6 +23,7 @@
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL;
import static org.apache.hadoop.ozone.om.OmSnapshotManager.OM_HARDLINK_FILE;
import static
org.apache.hadoop.ozone.om.TestOzoneManagerHAWithStoppedNodes.createKey;
+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;
@@ -164,8 +165,8 @@ public void init(TestInfo testInfo) throws Exception {
client = OzoneClientFactory.getRpcClient(OM_SERVICE_ID, conf);
objectStore = client.getObjectStore();
- volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ volumeName = uniqueObjectName("volume");
+ bucketName = uniqueObjectName("bucket");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner("user" + RandomStringUtils.secure().nextNumeric(5))
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java
index 40696f386d4..cb9d0d821bd 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java
@@ -22,6 +22,7 @@
import static org.apache.hadoop.ozone.TestDataUtil.readFully;
import static org.apache.hadoop.ozone.om.OmSnapshotManager.getSnapshotPath;
import static
org.apache.hadoop.ozone.om.TestOzoneManagerHAWithStoppedNodes.createKey;
+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.assertNotNull;
@@ -141,8 +142,8 @@ public void init() throws Exception {
client = OzoneClientFactory.getRpcClient(OM_SERVICE_ID, conf);
objectStore = client.getObjectStore();
- volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ volumeName = uniqueObjectName("volume");
+ bucketName = uniqueObjectName("bucket");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner("user" + RandomStringUtils.secure().nextNumeric(5))
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestObjectStoreWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestObjectStoreWithFSO.java
index e6d3985a34d..08023120f9f 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestObjectStoreWithFSO.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestObjectStoreWithFSO.java
@@ -24,6 +24,7 @@
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_SCHEME;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_ALREADY_EXISTS;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -44,7 +45,6 @@
import java.util.UUID;
import java.util.concurrent.TimeoutException;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -148,7 +148,7 @@ private void deleteRootRecursively(FileStatus[]
fileStatuses)
@Test
public void testCreateKey() throws Exception {
String parent = "a/b/c/";
- String file = "key" + RandomStringUtils.secure().nextNumeric(5);
+ String file = uniqueObjectName("key");
String key = parent + file;
ObjectStore objectStore = client.getObjectStore();
@@ -216,7 +216,7 @@ public void testDeleteBucketWithKeys() throws Exception {
String testBucketName = testBucket.getName();
String parent = "a/b/c/";
- String file = "key" + RandomStringUtils.secure().nextNumeric(5);
+ String file = uniqueObjectName("key");
String key = parent + file;
ObjectStore objectStore = client.getObjectStore();
@@ -268,7 +268,7 @@ public void testDeleteBucketWithKeys() throws Exception {
@Test
public void testLookupKey() throws Exception {
String parent = "a/b/c/";
- String fileName = "key" + RandomStringUtils.secure().nextNumeric(5);
+ String fileName = uniqueObjectName("key");
String key = parent + fileName;
ObjectStore objectStore = client.getObjectStore();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmBlockVersioning.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmBlockVersioning.java
index 243f7674ee7..85ba7c95b00 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmBlockVersioning.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmBlockVersioning.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.ozone.om;
import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.charset.StandardCharsets;
@@ -67,9 +68,9 @@ void cleanup() {
@Test
public void testAllocateCommit() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
- String keyName = "key" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
+ String keyName = uniqueObjectName("key");
OzoneBucket bucket =
TestDataUtil.createVolumeAndBucket(client, volumeName, bucketName);
@@ -149,9 +150,9 @@ private OmKeyLocationInfoGroup checkVersions(
@Test
public void testReadLatestVersion() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
- String keyName = "key" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
+ String keyName = uniqueObjectName("key");
OzoneBucket bucket =
TestDataUtil.createVolumeAndBucket(client, volumeName, bucketName);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAFollowerReadWithAllRunning.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAFollowerReadWithAllRunning.java
index 06fdcc1674a..0e97b249420 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAFollowerReadWithAllRunning.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAFollowerReadWithAllRunning.java
@@ -26,6 +26,7 @@
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.FILE_ALREADY_EXISTS;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.NOT_A_FILE;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.PARTIAL_DELETE;
+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;
@@ -419,7 +420,7 @@ private OzoneVolume createAndCheckVolume(String volumeName)
@Test
public void testAllVolumeOperations() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
createAndCheckVolume(volumeName);
@@ -435,8 +436,8 @@ public void testAllVolumeOperations() throws Exception {
@Test
public void testAllBucketOperations() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
OzoneVolume retVolume = createAndCheckVolume(volumeName);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithAllRunning.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithAllRunning.java
index a2f37e0db17..746f99d6495 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithAllRunning.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithAllRunning.java
@@ -29,6 +29,7 @@
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLIdentityType.USER;
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.READ;
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.WRITE;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static
org.apache.ratis.metrics.RatisMetrics.RATIS_APPLICATION_NAME_METRICS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -235,7 +236,7 @@ private OzoneVolume createAndCheckVolume(String volumeName)
@Test
public void testAllVolumeOperations() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
createAndCheckVolume(volumeName);
@@ -251,8 +252,8 @@ public void testAllVolumeOperations() throws Exception {
@Test
public void testAllBucketOperations() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
OzoneVolume retVolume = createAndCheckVolume(volumeName);
@@ -354,7 +355,7 @@ public void testFailoverWithSuggestedLeader() throws
Exception {
@Test
public void testReadRequest() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
ObjectStore objectStore = getObjectStore();
objectStore.createVolume(volumeName);
@@ -1034,8 +1035,8 @@ private void testRemoveAcl(String remoteUserName,
OzoneObj ozoneObj,
void testOMRatisSnapshot() throws Exception {
String userName = "user" + RandomStringUtils.secure().nextNumeric(5);
String adminName = "admin" + RandomStringUtils.secure().nextNumeric(5);
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner(userName)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithStoppedNodes.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithStoppedNodes.java
index 5913578fcd0..014e4dc06f6 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithStoppedNodes.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithStoppedNodes.java
@@ -20,6 +20,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL;
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_WAIT_BETWEEN_RETRIES_MILLIS_DEFAULT;
+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;
@@ -279,8 +280,8 @@ void testOMRestart() throws Exception {
// Do some transactions so that the log index increases
String userName = "user" + RandomStringUtils.secure().nextNumeric(5);
String adminName = "admin" + RandomStringUtils.secure().nextNumeric(5);
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner(userName)
@@ -585,7 +586,7 @@ void testListVolumes() throws Exception {
String userName = UserGroupInformation.getCurrentUser().getUserName();
ObjectStore objectStore = getObjectStore();
- String prefix = "vol-" + RandomStringUtils.secure().nextNumeric(10) + "-";
+ String prefix = uniqueObjectName("vol-") + "-";
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner(userName)
.setAdmin(userName)
@@ -614,7 +615,7 @@ void testRetryCacheWithDownedOM() throws Exception {
// Create a volume, a bucket and a key
String userName = "user" + RandomStringUtils.secure().nextNumeric(5);
String adminName = "admin" + RandomStringUtils.secure().nextNumeric(5);
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
String bucketName = UUID.randomUUID().toString();
String keyTo = UUID.randomUUID().toString();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerRestart.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerRestart.java
index 86d96cc1d1c..160e8e4e45e 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerRestart.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerRestart.java
@@ -26,12 +26,12 @@
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.PARTIAL_RENAME;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_ALREADY_EXISTS;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.client.ReplicationFactor;
import org.apache.hadoop.hdds.client.ReplicationType;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
@@ -82,7 +82,7 @@ public static void shutdown() {
@Test
public void testRestartOMWithVolumeOperation() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
ObjectStore objectStore = client.getObjectStore();
@@ -106,8 +106,8 @@ public void testRestartOMWithVolumeOperation() throws
Exception {
@Test
public void testRestartOMWithBucketOperation() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
ObjectStore objectStore = client.getObjectStore();
@@ -136,13 +136,13 @@ public void testRestartOMWithBucketOperation() throws
Exception {
@Test
public void testRestartOMWithKeyOperation() throws Exception {
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
- String key1 = "key1" + RandomStringUtils.secure().nextNumeric(5);
- String key2 = "key2" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
+ String key1 = uniqueObjectName("key1");
+ String key2 = uniqueObjectName("key2");
- String newKey1 = "key1new" + RandomStringUtils.secure().nextNumeric(5);
- String newKey2 = "key2new" + RandomStringUtils.secure().nextNumeric(5);
+ String newKey1 = uniqueObjectName("key1new");
+ String newKey2 = uniqueObjectName("key2new");
ObjectStore objectStore = client.getObjectStore();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestRecursiveAclWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestRecursiveAclWithFSO.java
index 1f652cd1220..70f2ff5e158 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestRecursiveAclWithFSO.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestRecursiveAclWithFSO.java
@@ -19,6 +19,7 @@
import static org.apache.hadoop.ozone.TestDataUtil.createKey;
import static org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType.OZONE;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -29,7 +30,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.protocol.StorageType;
import org.apache.hadoop.ozone.OzoneAcl;
import org.apache.hadoop.ozone.TestDataUtil;
@@ -123,8 +123,8 @@ public void testKeyDeleteAndRenameWithoutPermission()
throws Exception {
String keyf4 = "a/b2/d2/d21/f4";
String keyf5 = "/a/b3/e1/f5";
String keyf6 = "/a/b3/e2/f6";
- String file1 = "a/" + "file" + RandomStringUtils.secure().nextNumeric(5);
- String file2 = "a/b2/d2/" + "file" +
RandomStringUtils.secure().nextNumeric(5);
+ String file1 = "a/" + uniqueObjectName("file");
+ String file2 = "a/b2/d2/" + uniqueObjectName("file");
keys.add(keyf1);
keys.add(keyf2);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java
index 79a096f2dea..fcb7478e26b 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java
@@ -27,6 +27,7 @@
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_STALENODE_INTERVAL;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OFS_URI_SCHEME;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
+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;
@@ -38,7 +39,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeoutException;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
@@ -129,9 +129,9 @@ void testSafeModeOperations() throws Exception {
.getStorageContainerManager().getContainerManager().getContainers();
GenericTestUtils.waitFor(() -> containers.size() >= 3, 100, 1000);
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
- String keyName = "key" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
+ String keyName = uniqueObjectName("key");
ObjectStore store = client.getObjectStore();
store.createVolume(volumeName);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/service/TestSnapshotDeletingServiceIntegrationTest.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/service/TestSnapshotDeletingServiceIntegrationTest.java
index ec9479e242b..d0b1ccbae68 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/service/TestSnapshotDeletingServiceIntegrationTest.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/service/TestSnapshotDeletingServiceIntegrationTest.java
@@ -24,6 +24,7 @@
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SNAPSHOT_DELETING_SERVICE_TIMEOUT;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_SNAPSHOT_DEEP_CLEANING_ENABLED;
import static
org.apache.hadoop.ozone.om.lock.DAGLeveledResource.SNAPSHOT_GC_LOCK;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -50,7 +51,6 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.conf.StorageUnit;
import org.apache.hadoop.hdds.utils.IOUtils;
@@ -681,8 +681,8 @@ public void
testSnapshotDeletingServiceWaitsForKeyDeletingService(boolean kdsRun
om.getKeyManager().getDirDeletingService().suspend();
om.getKeyManager().getDeletingService().suspend();
om.getKeyManager().getSnapshotDeletingService().suspend();
- String volume = "vol" + RandomStringUtils.secure().nextNumeric(3),
- bucket = "bucket" + RandomStringUtils.secure().nextNumeric(3);
+ String volume = uniqueObjectName("vol");
+ String bucket = uniqueObjectName("bucket");
client.getObjectStore().createVolume(volume);
OzoneVolume ozoneVolume = client.getObjectStore().getVolume(volume);
ozoneVolume.createBucket(bucket);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotTests.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotTests.java
index 79d041b7a33..44131d81c88 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotTests.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotTests.java
@@ -55,6 +55,7 @@
import static org.apache.hadoop.ozone.upgrade.UpgradeFinalization.isStarting;
import static
org.apache.ozone.rocksdiff.RocksDBCheckpointDiffer.COLUMN_FAMILIES_TO_TRACK_IN_DAG;
import static org.apache.ozone.test.LambdaTestUtils.await;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -650,7 +651,7 @@ private void getOmKeyInfo(String volume, String bucket,
*/
@Test
public void testSnapDiffHandlingReclaimWithLatestUse() throws Exception {
- String testVolumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
+ String testVolumeName = uniqueObjectName("vol");
String testBucketName = "bucket1";
store.createVolume(testVolumeName);
OzoneVolume volume = store.getVolume(testVolumeName);
@@ -688,7 +689,7 @@ public void testSnapDiffHandlingReclaimWithLatestUse()
throws Exception {
*/
@Test
public void testSnapDiffHandlingReclaimWithPreviousUse() throws Exception {
- String testVolumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
+ String testVolumeName = uniqueObjectName("vol");
String testBucketName = "bucket1";
store.createVolume(testVolumeName);
OzoneVolume volume = store.getVolume(testVolumeName);
@@ -735,7 +736,7 @@ public void testSnapDiffHandlingReclaimWithPreviousUse()
throws Exception {
*/
@Test
public void testSnapDiffReclaimWithKeyRecreation() throws Exception {
- String testVolumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
+ String testVolumeName = uniqueObjectName("vol");
String testBucketName = "bucket1";
store.createVolume(testVolumeName);
OzoneVolume volume = store.getVolume(testVolumeName);
@@ -789,7 +790,7 @@ public void testSnapDiffReclaimWithKeyRecreation() throws
Exception {
*/
@Test
public void testSnapDiffReclaimWithKeyRename() throws Exception {
- String testVolumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
+ String testVolumeName = uniqueObjectName("vol");
String testBucketName = "bucket1";
store.createVolume(testVolumeName);
OzoneVolume volume = store.getVolume(testVolumeName);
@@ -1669,7 +1670,7 @@ public void testSnapDiffNonExistentUrl() throws Exception
{
*/
@Test
public void testSnapDiffWithKeyOverwrite() throws Exception {
- String testVolumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
+ String testVolumeName = uniqueObjectName("vol");
String testBucketName = "bucket1";
store.createVolume(testVolumeName);
OzoneVolume volume = store.getVolume(testVolumeName);
@@ -1758,8 +1759,8 @@ public void testSnapDiffMultipleBuckets() throws
Exception {
@Test
public void testListSnapshotDiffWithInvalidParameters()
throws Exception {
- String volume = "vol-" + RandomStringUtils.secure().nextNumeric(5);
- String bucket = "buck-" + RandomStringUtils.secure().nextNumeric(5);
+ String volume = uniqueObjectName("vol-");
+ String bucket = uniqueObjectName("buck-");
String volErrorMessage = "Volume not found: " + volume;
@@ -1781,14 +1782,14 @@ public void testListSnapshotDiffWithInvalidParameters()
OzoneBucket ozBucket = ozVolume.getBucket(bucket);
// Create keys and take snapshots.
- String key1 = "key-1-" + RandomStringUtils.secure().nextNumeric(5);
+ String key1 = uniqueObjectName("key-1-");
createFileKey(ozBucket, key1);
- String snap1 = "snap-1-" + RandomStringUtils.secure().nextNumeric(5);
+ String snap1 = uniqueObjectName("snap-1-");
createSnapshot(volume, bucket, snap1);
- String key2 = "key-2-" + RandomStringUtils.secure().nextNumeric(5);
+ String key2 = uniqueObjectName("key-2-");
createFileKey(ozBucket, key2);
- String snap2 = "snap-2-" + RandomStringUtils.secure().nextNumeric(5);
+ String snap2 = uniqueObjectName("snap-2-");
createSnapshot(volume, bucket, snap2);
store.snapshotDiff(volume, bucket, snap1, snap2, null, 0,
@@ -2082,8 +2083,8 @@ public void testSnapshotOpensWithDisabledAutoCompaction()
throws Exception {
// in_progress when it restarts.
@Test
public void testSnapshotDiffWhenOmRestart() throws Exception {
- String snapshot1 = "snap-" + RandomStringUtils.secure().nextNumeric(5);
- String snapshot2 = "snap-" + RandomStringUtils.secure().nextNumeric(5);
+ String snapshot1 = uniqueObjectName("snap-");
+ String snapshot2 = uniqueObjectName("snap-");
createSnapshots(snapshot1, snapshot2);
SnapshotDiffResponse response = store.snapshotDiff(volumeName, bucketName,
@@ -2127,8 +2128,8 @@ public void testSnapshotDiffWhenOmRestart() throws
Exception {
public void testSnapshotDiffWhenOmRestartAndReportIsPartiallyFetched()
throws Exception {
int pageSize = 10;
- String snapshot1 = "snap-" + RandomStringUtils.secure().nextNumeric(5);
- String snapshot2 = "snap-" + RandomStringUtils.secure().nextNumeric(5);
+ String snapshot1 = uniqueObjectName("snap-");
+ String snapshot2 = uniqueObjectName("snap-");
createSnapshots(snapshot1, snapshot2);
SnapshotDiffReportOzone diffReport = fetchReportPage(volumeName,
@@ -2209,8 +2210,8 @@ public void testCompactionDagDisableForSnapshotMetadata()
throws Exception {
@Test
@Slow("HDDS-9299")
public void testDayWeekMonthSnapshotCreationAndExpiration() throws Exception
{
- String volumeA = "vol-a-" + RandomStringUtils.secure().nextNumeric(5);
- String bucketA = "buc-a-" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeA = uniqueObjectName("vol-a-");
+ String bucketA = uniqueObjectName("buc-a-");
store.createVolume(volumeA);
OzoneVolume volA = store.getVolume(volumeA);
createBucket(volA, bucketA);
@@ -2416,10 +2417,10 @@ private String getKeySuffix(int index) {
@Test
public void testSnapshotCompactionDag() throws Exception {
assumeCanonicalConfig(true);
- String volume1 = "volume-1-" + RandomStringUtils.secure().nextNumeric(5);
- String bucket1 = "bucket-1-" + RandomStringUtils.secure().nextNumeric(5);
- String bucket2 = "bucket-2-" + RandomStringUtils.secure().nextNumeric(5);
- String bucket3 = "bucket-3-" + RandomStringUtils.secure().nextNumeric(5);
+ String volume1 = uniqueObjectName("volume-1-");
+ String bucket1 = uniqueObjectName("bucket-1-");
+ String bucket2 = uniqueObjectName("bucket-2-");
+ String bucket3 = uniqueObjectName("bucket-3-");
store.createVolume(volume1);
OzoneVolume ozoneVolume = store.getVolume(volume1);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOmSnapshotDisabled.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOmSnapshotDisabled.java
index b942f3200c7..6c4289ccf1e 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOmSnapshotDisabled.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOmSnapshotDisabled.java
@@ -19,10 +19,10 @@
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_DB_PROFILE;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.FEATURE_NOT_ENABLED;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.hdds.utils.db.DBProfile;
@@ -76,9 +76,9 @@ public static void tearDown() throws Exception {
@Test
public void testExceptionThrown() throws Exception {
- String volumeName = "vol-" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "buck-" + RandomStringUtils.secure().nextNumeric(5);
- String snapshotName = "snap-" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("vol-");
+ String bucketName = uniqueObjectName("buck-");
+ String snapshotName = uniqueObjectName("snap-");
store.createVolume(volumeName);
OzoneVolume volume = store.getVolume(volumeName);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOmSnapshotDisabledRestart.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOmSnapshotDisabledRestart.java
index 30ff484e9ff..30909a9c111 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOmSnapshotDisabledRestart.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOmSnapshotDisabledRestart.java
@@ -17,11 +17,11 @@
package org.apache.hadoop.ozone.om.snapshot;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.ozone.MiniOzoneCluster;
@@ -76,9 +76,9 @@ public void testSnapshotFeatureFlag() throws Exception {
// Verify that OM start up will indeed fail when there are still snapshots
// while snapshot feature is disabled.
- String volumeName = "vol-" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "buck-" + RandomStringUtils.secure().nextNumeric(5);
- String snapshotName = "snap-" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("vol-");
+ String bucketName = uniqueObjectName("buck-");
+ String snapshotName = uniqueObjectName("snap-");
store.createVolume(volumeName);
OzoneVolume volume = store.getVolume(volumeName);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java
index f444da964b5..cd461b7e88a 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java
@@ -22,6 +22,7 @@
import static
org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobStatus.DONE;
import static
org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobStatus.IN_PROGRESS;
import static org.apache.ozone.test.LambdaTestUtils.await;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -106,14 +107,14 @@ public static void cleanUp() {
@Test
public void testSnapshotDiffWhenOmLeaderRestart()
throws Exception {
- String snapshot1 = "snap-" + RandomStringUtils.secure().nextNumeric(10);
- String snapshot2 = "snap-" + RandomStringUtils.secure().nextNumeric(10);
+ String snapshot1 = uniqueObjectName("snap-");
+ String snapshot2 = uniqueObjectName("snap-");
- createFileKey(ozoneBucket, "key-" +
RandomStringUtils.secure().nextNumeric(10));
+ createFileKey(ozoneBucket, uniqueObjectName("key-"));
store.createSnapshot(volumeName, bucketName, snapshot1);
for (int i = 0; i < 100; i++) {
- createFileKey(ozoneBucket, "key-" +
RandomStringUtils.secure().nextNumeric(10));
+ createFileKey(ozoneBucket, uniqueObjectName("key-"));
}
store.createSnapshot(volumeName, bucketName, snapshot2);
@@ -161,9 +162,9 @@ public void testSnapshotDiffWhenOmLeaderRestart()
@Test
public void testSnapshotIdConsistency() throws Exception {
- createFileKey(ozoneBucket, "key-" +
RandomStringUtils.secure().nextNumeric(10));
+ createFileKey(ozoneBucket, uniqueObjectName("key-"));
- String snapshotName = "snap-" + RandomStringUtils.secure().nextNumeric(10);
+ String snapshotName = uniqueObjectName("snap-");
store.createSnapshot(volumeName, bucketName, snapshotName);
List<OzoneManager> ozoneManagers = cluster.getOzoneManagersList();
@@ -247,8 +248,8 @@ public void testSnapshotChainManagerRestore() throws
Exception {
for (int j = 0; j < 10; j++) {
OzoneBucket bucket = ozoneBuckets.get(j);
// Create a new key to generate state change.
- createFileKey(bucket, "key-" +
RandomStringUtils.secure().nextNumeric(10));
- String snapshotName = "snapshot-" +
RandomStringUtils.secure().nextNumeric(10);
+ createFileKey(bucket, uniqueObjectName("key-"));
+ String snapshotName = uniqueObjectName("snapshot-");
store.createSnapshot(volumeNames.get(j), bucketNames.get(j),
snapshotName);
snapshotNamesList.get(j).add(snapshotName);
}
@@ -317,8 +318,8 @@ public void testSnapshotDeletingServiceDuringOMFailover(int
numSnapshots)
// Create numSnapshots snapshots, each capturing distinct state.
for (int i = 0; i < numSnapshots; i++) {
- createFileKey(ozoneBucket, "key-" +
RandomStringUtils.secure().nextNumeric(10));
- String snapshotName = "snap-" +
RandomStringUtils.secure().nextNumeric(10);
+ createFileKey(ozoneBucket, uniqueObjectName("key-"));
+ String snapshotName = uniqueObjectName("snap-");
createSnapshot(volumeName, bucketName, snapshotName);
snapshotNames.add(snapshotName);
tableKeys.add(SnapshotInfo.getTableKey(volumeName, bucketName,
snapshotName));
@@ -401,7 +402,7 @@ public void testKeyAndSnapshotDeletionService()
int numKeys = 5;
List<String> keys = new ArrayList<>();
for (int i = 0; i < numKeys; i++) {
- String keyName = "key-" + RandomStringUtils.secure().nextNumeric(10);
+ String keyName = uniqueObjectName("key-");
createFileKey(ozoneBucket, keyName);
keys.add(keyName);
}
@@ -416,7 +417,7 @@ public void testKeyAndSnapshotDeletionService()
ozoneBucket.deleteKey(keys.get(i));
}
- String snapshotName = "snap-" + RandomStringUtils.secure().nextNumeric(10);
+ String snapshotName = uniqueObjectName("snap-");
createSnapshot(volumeName, bucketName, snapshotName);
// Wait for double buffer flush on follower to ensure that
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerSnapshotProvider.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerSnapshotProvider.java
index 0b89eb1b67c..115ad9b2fbb 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerSnapshotProvider.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerSnapshotProvider.java
@@ -17,6 +17,7 @@
package org.apache.hadoop.ozone.om.snapshot;
+import static org.apache.ozone.test.OzoneTestBase.uniqueObjectName;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -83,8 +84,8 @@ public void shutdown() {
public void testDownloadCheckpoint() throws Exception {
String userName = "user" + RandomStringUtils.secure().nextNumeric(5);
String adminName = "admin" + RandomStringUtils.secure().nextNumeric(5);
- String volumeName = "volume" + RandomStringUtils.secure().nextNumeric(5);
- String bucketName = "bucket" + RandomStringUtils.secure().nextNumeric(5);
+ String volumeName = uniqueObjectName("volume");
+ String bucketName = uniqueObjectName("bucket");
VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
.setOwner(userName)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]