HDDS-1432. Ozone client list command truncates response without any indication. Contributed by Siddharth Wagle.
This commit is contained in:
parent
b8086aed86
commit
f2ab2795db
|
@ -1114,11 +1114,16 @@ public class TestOzoneShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
out.reset();
|
out.reset();
|
||||||
|
String msgText = "Listing first 3 entries of the result. " +
|
||||||
|
"Use --length (-l) to override max returned keys.";
|
||||||
args =
|
args =
|
||||||
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
new String[] {"key", "list", url + "/" + volumeName + "/" + bucketName,
|
||||||
"--length", "3"};
|
"--length", "3"};
|
||||||
execute(shell, args);
|
execute(shell, args);
|
||||||
commandOutput = out.toString();
|
commandOutput = out.toString();
|
||||||
|
assertTrue("Expecting output to start with " + msgText,
|
||||||
|
commandOutput.contains(msgText));
|
||||||
|
commandOutput = commandOutput.replace(msgText, "");
|
||||||
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
keys = (List<KeyInfo>) JsonUtils.toJsonList(commandOutput,
|
||||||
KeyInfo.class);
|
KeyInfo.class);
|
||||||
|
|
||||||
|
|
|
@ -90,12 +90,19 @@ public class ListKeyHandler extends Handler {
|
||||||
startKey);
|
startKey);
|
||||||
List<KeyInfo> keyInfos = new ArrayList<>();
|
List<KeyInfo> keyInfos = new ArrayList<>();
|
||||||
|
|
||||||
|
int maxKeyLimit = maxKeys;
|
||||||
while (maxKeys > 0 && keyIterator.hasNext()) {
|
while (maxKeys > 0 && keyIterator.hasNext()) {
|
||||||
KeyInfo key = OzoneClientUtils.asKeyInfo(keyIterator.next());
|
KeyInfo key = OzoneClientUtils.asKeyInfo(keyIterator.next());
|
||||||
keyInfos.add(key);
|
keyInfos.add(key);
|
||||||
maxKeys -= 1;
|
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()) {
|
if (isVerbose()) {
|
||||||
System.out.printf("Found : %d keys for bucket %s in volume : %s ",
|
System.out.printf("Found : %d keys for bucket %s in volume : %s ",
|
||||||
keyInfos.size(), bucketName, volumeName);
|
keyInfos.size(), bucketName, volumeName);
|
||||||
|
|
Loading…
Reference in New Issue