Skip to content
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

HDDS-12075. Update read replica command to handle slash character in key names #7693

Closed
wants to merge 5 commits into from
Closed
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
3 changes: 2 additions & 1 deletion hadoop-ozone/dist/src/main/compose/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,13 @@ execute_debug_tests() {

local volume="cli-debug-volume${prefix}"
local bucket="cli-debug-bucket"
local key="testfile"
local key="testfileprefix/testfile"

execute_robot_test ${SCM} -v "PREFIX:${prefix}" debug/ozone-debug-tests.robot

# get block locations for key
local chunkinfo="${key}-blocks-${prefix}"
mkdir -p $(dirname "$chunkinfo")
docker-compose exec -T ${SCM} bash -c "ozone debug chunkinfo ${volume}/${bucket}/${key}" > "$chunkinfo"
local host="$(jq -r '.KeyLocations[0][0]["Datanode-HostName"]' ${chunkinfo})"
local container="${host%%.*}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ Test Timeout 5 minute
${PREFIX} ${EMPTY}
${VOLUME} cli-debug-volume${PREFIX}
${BUCKET} cli-debug-bucket
${TESTFILE} testfile
${TESTFILEPREFIX} testfileprefix/
${TESTFILE} ${TESTFILEPREFIX}testfile
${CORRUPT_DATANODE} ozone_datanode_1.ozone_default

*** Test Cases ***
Test ozone debug read-replicas with corrupt block replica
${directory} = Execute read-replicas CLI tool
Set Test Variable ${DIR} ${directory}

${count_files} = Count Files In Directory ${directory}
${count_files} = Count Files In Directory Recursively ${directory}
Should Be Equal As Integers ${count_files} 7

${json} = Read Replicas Manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ Test Timeout 5 minute
${PREFIX} ${EMPTY}
${VOLUME} cli-debug-volume${PREFIX}
${BUCKET} cli-debug-bucket
${TESTFILE} testfile
${TESTFILEPREFIX} testfileprefix/
${TESTFILE} ${TESTFILEPREFIX}testfile

*** Test Cases ***
Test ozone debug read-replicas with one datanode DEAD
${directory} = Execute read-replicas CLI tool
Set Test Variable ${DIR} ${directory}

${count_files} = Count Files In Directory ${directory}
${count_files} = Count Files In Directory Recursively ${directory}
Should Be Equal As Integers ${count_files} 5

${json} = Read Replicas Manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ Test Timeout 5 minute
${PREFIX} ${EMPTY}
${VOLUME} cli-debug-volume${PREFIX}
${BUCKET} cli-debug-bucket
${TESTFILE} testfile
${TESTFILEPREFIX} testfileprefix/
${TESTFILE} ${TESTFILEPREFIX}testfile
${STALE_DATANODE} ozone_datanode_1.ozone_default

*** Test Cases ***
Test ozone debug read-replicas with one datanode STALE
${directory} = Execute read-replicas CLI tool
Set Test Variable ${DIR} ${directory}

${count_files} = Count Files In Directory ${directory}
${count_files} = Count Files In Directory Recursively ${directory}
Should Be Equal As Integers ${count_files} 7

${json} = Read Replicas Manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ ${PREFIX} ${EMPTY}
${VOLUME} cli-debug-volume${PREFIX}
${BUCKET} cli-debug-bucket
${DEBUGKEY} debugKey
${TESTFILE} testfile
${TESTFILEPREFIX} testfileprefix/
${TESTFILE} ${TESTFILEPREFIX}testfile

*** Keywords ***
Write keys
Execute ozone sh volume create o3://om/${VOLUME} --space-quota 100TB --namespace-quota 100
Execute ozone sh bucket create o3://om/${VOLUME}/${BUCKET} --space-quota 1TB
Execute mkdir -p ${TEMP_DIR}/${TESTFILEPREFIX}
Execute dd if=/dev/urandom of=${TEMP_DIR}/${TESTFILE} bs=100000 count=15
Execute ozone sh key put o3://om/${VOLUME}/${BUCKET}/${TESTFILE} ${TEMP_DIR}/${TESTFILE}

Expand All @@ -40,7 +42,7 @@ Test ozone debug read-replicas
${directory} = Execute read-replicas CLI tool
Set Test Variable ${DIR} ${directory}

${count_files} = Count Files In Directory ${directory}
${count_files} = Count Files In Directory Recursively ${directory}
Should Be Equal As Integers ${count_files} 7

${json} = Read Replicas Manifest
Expand Down
5 changes: 5 additions & 0 deletions hadoop-ozone/dist/src/main/smoketest/lib/os.robot
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ Get Random Filename
List All Processes
${output} = Execute ps aux
[return] ${output}

Count Files In Directory Recursively
[Arguments] ${PATH}
${count_files} = Execute find ${PATH} -type f | wc -l
[Return] ${count_files}
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ protected void execute(OzoneClient client, OzoneAddress address)
String prettyJson = JsonUtils.toJsonStringWithDefaultPrettyPrinter(result);

String manifestFileName = keyName + "_manifest";
System.out.println("Writing manifest file : " + manifestFileName);
File manifestFile
= new File(dir, manifestFileName);
System.out.println("Writing manifest file: " + manifestFile.getAbsolutePath());
Path parentPath = manifestFile.getParentFile() != null ? manifestFile.getParentFile().toPath() : null;
if (parentPath != null) {
Files.createDirectories(parentPath);
}
Files.write(manifestFile.toPath(),
prettyJson.getBytes(StandardCharsets.UTF_8));
} finally {
Expand Down Expand Up @@ -182,8 +186,12 @@ private void downloadReplicasAndCreateManifest(

String fileName = keyName + "_block" + blockIndex + "_" +
datanode.getHostName();
System.out.println("Writing : " + fileName);
Path path = new File(dir, fileName).toPath();
Path parentPath = path.getParent();
if (parentPath != null) {
Files.createDirectories(parentPath);
}
System.out.println("Writing block file: " + path.toAbsolutePath());

try (InputStream is = replica.getValue()) {
Files.copy(is, path, StandardCopyOption.REPLACE_EXISTING);
Expand Down Expand Up @@ -231,11 +239,11 @@ private File createDirectory(String volumeName, String bucketName,
= new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
String directoryName = volumeName + "_" + bucketName + "_" + keyName +
"_" + fileSuffix;
System.out.println("Creating directory : " + directoryName);
File dir = new File(outputDir, directoryName);
System.out.println("Creating directory: " + dir.getAbsolutePath());
if (!dir.exists()) {
if (dir.mkdir()) {
System.out.println("Successfully created!");
if (dir.mkdirs()) {
System.out.println("Successfully created directory: " + dir.getAbsolutePath());
} else {
throw new IOException(String.format(
"Failed to create directory %s.", dir));
Expand Down
Loading