HDDS-315. ozoneShell infoKey does not work for directories created as key and throws 'KEY_NOT_FOUND' error. Contributed by Dinesh Chitlangia.
This commit is contained in:
parent
85c3fe341a
commit
c7403a448d
@ -815,6 +815,41 @@ public void testInfoKeyDetails() throws Exception {
|
||||
"Lookup key failed, error:KEY_NOT_FOUND"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfoDirKey() throws Exception {
|
||||
LOG.info("Running testInfoKey for Dir Key");
|
||||
String dirKeyName = "test/";
|
||||
String keyNameOnly = "test";
|
||||
OzoneBucket bucket = creatBucket();
|
||||
String volumeName = bucket.getVolumeName();
|
||||
String bucketName = bucket.getName();
|
||||
String dataStr = "test-data";
|
||||
OzoneOutputStream keyOutputStream =
|
||||
bucket.createKey(dirKeyName, dataStr.length());
|
||||
keyOutputStream.write(dataStr.getBytes());
|
||||
keyOutputStream.close();
|
||||
String[] args = new String[] {"-infoKey",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + dirKeyName};
|
||||
// verify the response output
|
||||
int a = ToolRunner.run(shell, args);
|
||||
String output = out.toString();
|
||||
assertEquals(0, a);
|
||||
assertTrue(output.contains(dirKeyName));
|
||||
assertTrue(output.contains("createdOn") &&
|
||||
output.contains("modifiedOn") &&
|
||||
output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
||||
args = new String[] {"-infoKey",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyNameOnly};
|
||||
a = ToolRunner.run(shell, args);
|
||||
output = out.toString();
|
||||
assertEquals(1, a);
|
||||
assertTrue(err.toString().contains(
|
||||
"Lookup key failed, error:KEY_NOT_FOUND"));
|
||||
// reset stream
|
||||
out.reset();
|
||||
err.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListKey() throws Exception {
|
||||
LOG.info("Running testListKey");
|
||||
|
@ -25,6 +25,7 @@
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.hadoop.ozone.OzoneConsts;
|
||||
import org.apache.hadoop.ozone.client.*;
|
||||
import org.apache.hadoop.ozone.client.rest.OzoneException;
|
||||
import org.apache.hadoop.ozone.web.ozShell.Handler;
|
||||
@ -64,8 +65,12 @@ protected void execute(CommandLine cmd)
|
||||
|
||||
volumeName = path.getName(0).toString();
|
||||
bucketName = path.getName(1).toString();
|
||||
keyName = path.getName(2).toString();
|
||||
|
||||
String searchString = volumeName + OzoneConsts.OZONE_URI_DELIMITER +
|
||||
bucketName + OzoneConsts.OZONE_URI_DELIMITER;
|
||||
|
||||
keyName = ozoneURIString.substring(ozoneURIString.indexOf(searchString) +
|
||||
searchString.length());
|
||||
|
||||
if (cmd.hasOption(Shell.VERBOSE)) {
|
||||
System.out.printf("Volume Name : %s%n", volumeName);
|
||||
|
Loading…
Reference in New Issue
Block a user