-
Notifications
You must be signed in to change notification settings - Fork 621
HDDS-12417. Reduce duplication of createKey variants in TestDataUtil #7999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -105,12 +105,6 @@ public static OzoneVolume createVolume(OzoneClient client, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void createKey(OzoneBucket bucket, String keyName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String content) throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createKey(bucket, keyName, ReplicationFactor.ONE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ReplicationType.RATIS, content.getBytes(UTF_8)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void createKey(OzoneBucket bucket, String keyName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| byte[] content) throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createKey(bucket, keyName, ReplicationFactor.ONE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -140,20 +134,6 @@ public static void createKey(OzoneBucket bucket, String keyName, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void createKey(OzoneBucket bucket, String keyName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ReplicationFactor repFactor, ReplicationType repType, String content) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ReplicationConfig repConfig = ReplicationConfig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .fromTypeAndFactor(repType, repFactor); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createKey(bucket, keyName, repConfig, content.getBytes(UTF_8)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void createKey(OzoneBucket bucket, String keyName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ReplicationConfig repConfig, String content) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createKey(bucket, keyName, repConfig, content.getBytes(UTF_8)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
-151
to
-155
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also remove this one: ozone/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java Lines 115 to 125 in df1f35b
ozone/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java Lines 444 to 452 in bb16f66
callers can be changed to use the variant that accepts a ozone/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/RatisReplicationConfig.java Lines 46 to 58 in bb16f66
And this one can also be removed: ozone/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java Lines 137 to 147 in df1f35b
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void createKey(OzoneBucket bucket, String keyName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ReplicationFactor repFactor, ReplicationType repType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ByteBuffer data) throws IOException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -258,7 +238,7 @@ public static Map<String, OmKeyInfo> createKeys(MiniOzoneCluster cluster, int nu | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OzoneBucket bucket = createVolumeAndBucket(client); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (int i = 0; i < numOfKeys; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String keyName = RandomStringUtils.randomAlphabetic(5) + i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createKey(bucket, keyName, RandomStringUtils.randomAlphabetic(5)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createKey(bucket, keyName, RandomStringUtils.randomAlphabetic(5).getBytes(UTF_8)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keyLocationMap.put(keyName, lookupOmKeyInfo(cluster, bucket, keyName)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1092,18 +1092,18 @@ public void testDeleteAuditLog() throws Exception { | |
|
|
||
| // create a three replica file | ||
| String keyName1 = "key1"; | ||
| TestDataUtil.createKey(bucket, keyName1, THREE, RATIS, value); | ||
| TestDataUtil.createKey(bucket, keyName1, THREE, RATIS, value.getBytes(UTF_8)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change |
||
|
|
||
| // create a EC replica file | ||
| String keyName2 = "key2"; | ||
| ReplicationConfig replicationConfig = new ECReplicationConfig("rs-3-2-1024k"); | ||
| TestDataUtil.createKey(bucket, keyName2, replicationConfig, value); | ||
| TestDataUtil.createKey(bucket, keyName2, replicationConfig, value.getBytes(UTF_8)); | ||
|
|
||
| // create a directory and a file | ||
| String dirName = "dir1"; | ||
| bucket.createDirectory(dirName); | ||
| String keyName3 = "key3"; | ||
| TestDataUtil.createKey(bucket, keyName3, THREE, RATIS, value); | ||
| TestDataUtil.createKey(bucket, keyName3, THREE, RATIS, value.getBytes(UTF_8)); | ||
|
|
||
| // delete files and directory | ||
| output.reset(); | ||
|
|
@@ -1113,10 +1113,10 @@ public void testDeleteAuditLog() throws Exception { | |
|
|
||
| // create keys for deleteKeys case | ||
| String keyName4 = "key4"; | ||
| TestDataUtil.createKey(bucket, dirName + "/" + keyName4, THREE, RATIS, value); | ||
| TestDataUtil.createKey(bucket, dirName + "/" + keyName4, THREE, RATIS, value.getBytes(UTF_8)); | ||
|
|
||
| String keyName5 = "key5"; | ||
| TestDataUtil.createKey(bucket, dirName + "/" + keyName5, replicationConfig, value); | ||
| TestDataUtil.createKey(bucket, dirName + "/" + keyName5, replicationConfig, value.getBytes(UTF_8)); | ||
|
|
||
| List<String> keysToDelete = new ArrayList<>(); | ||
| keysToDelete.add(dirName + "/" + keyName4); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess
"".getBytes(UTF_8)can be replaced withnew byte[0].