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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static org.apache.hadoop.ozone.OzoneConsts.ETAG;
import static org.apache.hadoop.ozone.OzoneConsts.MD5_HASH;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_SCHEME;
import static org.apache.hadoop.ozone.TestDataUtil.createKey;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.NOT_A_FILE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -352,13 +351,9 @@ public void testListKeysWithNotNormalizedPath() throws Exception {
keys.add(OmUtils.normalizeKey(key2, false));
keys.add(OmUtils.normalizeKey(key3, false));

int length = 10;
byte[] input = new byte[length];
Arrays.fill(input, (byte)96);

createAndAssertKey(ozoneBucket, key1, 10, input);
createAndAssertKey(ozoneBucket, key2, 10, input);
createAndAssertKey(ozoneBucket, key3, 10, input);
createAndAssertKey(ozoneBucket, key1, 10);
createAndAssertKey(ozoneBucket, key2, 10);
createAndAssertKey(ozoneBucket, key3, 10);

// Iterator with key name as prefix.

Expand Down Expand Up @@ -403,10 +398,10 @@ private void checkKeyList(Iterator<? extends OzoneKey > ozoneKeyIterator,
assertEquals(keys, outputKeys);
}

private void createAndAssertKey(OzoneBucket ozoneBucket, String key, int length, byte[] input)
private void createAndAssertKey(OzoneBucket ozoneBucket, String key, int length)
throws Exception {

createKey(ozoneBucket, key, input);
byte[] input = TestDataUtil.createStringKey(ozoneBucket, key, length);
// Read the key with given key name.
readKey(ozoneBucket, key, length, input);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ public static OzoneVolume createVolume(OzoneClient client,

}

public static byte[] createStringKey(OzoneBucket bucket, String keyName, int length)
throws IOException {
byte[] content = RandomStringUtils.secure().nextAlphanumeric(length).getBytes(UTF_8);
createKey(bucket, keyName, content);
return content;
}

public static void createKey(OzoneBucket bucket, String keyName,
byte[] content) throws IOException {
createKey(bucket, keyName, null, content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static com.google.common.collect.Lists.newLinkedList;
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.hadoop.ozone.TestDataUtil.createKey;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.params.provider.Arguments.of;

Expand Down Expand Up @@ -371,13 +370,10 @@ private void checkKeyShallowList(String keyPrefix, String startKey,

private static void createAndAssertKeys(OzoneBucket ozoneBucket, List<String> keys)
throws Exception {
int length = 10;
byte[] input = new byte[length];
Arrays.fill(input, (byte) 96);
for (String key : keys) {
createKey(ozoneBucket, key, input);
byte[] input = TestDataUtil.createStringKey(ozoneBucket, key, 10);
// Read the key with given key name.
readkey(ozoneBucket, key, length, input);
readkey(ozoneBucket, key, 10, input);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@

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.hadoop.ozone.TestDataUtil.createKey;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -643,13 +641,10 @@ private void checkKeyShallowList(String keyPrefix, String startKey,

private static void createAndAssertKeys(OzoneBucket ozoneBucket, List<String> keys)
throws Exception {
int length = 10;
byte[] input = new byte[length];
Arrays.fill(input, (byte) 96);
for (String key : keys) {
createKey(ozoneBucket, key, input);
byte[] input = TestDataUtil.createStringKey(ozoneBucket, key, 10);
// Read the key with given key name.
readkey(ozoneBucket, key, length, input);
readkey(ozoneBucket, key, 10, input);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_ITERATE_BATCH_SIZE;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_SCHEME;
import static org.apache.hadoop.ozone.TestDataUtil.createKey;
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.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -559,14 +558,10 @@ private void checkKeyList(Iterator<? extends OzoneKey > ozoneKeyIterator,
private void createAndAssertKeys(OzoneBucket ozoneBucket, List<String> keys)
throws Exception {

int length = 10;
byte[] input = new byte[length];
Arrays.fill(input, (byte) 96);

for (String key : keys) {
createKey(ozoneBucket, key, input);
byte[] input = TestDataUtil.createStringKey(ozoneBucket, key, 10);
// Read the key with given key name.
readKey(ozoneBucket, key, length, input);
readKey(ozoneBucket, key, 10, input);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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;
import org.apache.hadoop.ozone.client.BucketArgs;
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.client.OzoneBucket;
Expand Down Expand Up @@ -329,12 +330,11 @@ private void setKeyAcl(ObjectStore objectStore, String volumeName,

private void createKeys(ObjectStore objectStore, OzoneBucket ozoneBucket,
List<String> keys) throws Exception {
int length = 10;

String aclWorldAll = "world::a";
byte[] input = new byte[length];
Arrays.fill(input, (byte) 96);

for (String key : keys) {
createKey(ozoneBucket, key, input);
TestDataUtil.createStringKey(ozoneBucket, key, 10);
setKeyAcl(objectStore, ozoneBucket.getVolumeName(), ozoneBucket.getName(),
key, aclWorldAll);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,18 +349,15 @@ private void checkKeyList(Iterator<? extends OzoneKey> ozoneKeyIterator,

private void createKeys(OzoneBucket ozoneBucket, List<String> keys)
throws Exception {
int length = 10;
byte[] input = new byte[length];
Arrays.fill(input, (byte) 96);
for (String key : keys) {
createKey(ozoneBucket, key, 10, input);
createKey(ozoneBucket, key, 10);
}
}

private void createKey(OzoneBucket ozoneBucket, String key, int length,
byte[] input) throws Exception {
private void createKey(OzoneBucket ozoneBucket, String key, int length)
throws Exception {

TestDataUtil.createKey(ozoneBucket, key, input);
byte[] input = TestDataUtil.createStringKey(ozoneBucket, key, length);
// Read the key with given key name.
readkey(ozoneBucket, key, length, input);
}
Expand Down