HDDS-1432. Ozone client list command truncates response without any indication. Contributed by Siddharth Wagle.

This commit is contained in:
Arpit Agarwal 2019-04-16 12:35:49 -07:00
parent b8086aed86
commit f2ab2795db
No known key found for this signature in database
GPG Key ID: E4B09E903FDF9E98
2 changed files with 12 additions and 0 deletions

View File

@ -1114,11 +1114,16 @@ public void testListKey() throws Exception {
}
out.reset();
String msgText = "Listing first 3 entries of the result. " +
"Use --length (-l) to override max returned keys.";
args =
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
"--length", "3"};
execute(shell, args);
commandOutput = out.toString();
assertTrue("Expecting output to start with " + msgText,
commandOutput.contains(msgText));
commandOutput = commandOutput.replace(msgText, "");
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
KeyInfo.class);

View File

@ -90,12 +90,19 @@ public Void call() throws Exception {
startKey);
List<KeyInfo> keyInfos = new ArrayList<>();
int maxKeyLimit = maxKeys;
while (maxKeys > 0 && keyIterator.hasNext()) {
KeyInfo key = OzoneClientUtils.asKeyInfo(keyIterator.next());
keyInfos.add(key);
maxKeys -= 1;
}
// More keys were returned notify about max length
if (keyIterator.hasNext()) {
System.out.println("Listing first " + maxKeyLimit + " entries of the " +
"result. Use --length (-l) to override max returned keys.");
}
if (isVerbose()) {
System.out.printf("Found : %d keys for bucket %s in volume : %s ",
keyInfos.size(), bucketName, volumeName);