smengcl commented on a change in pull request #2713:
URL: https://github.com/apache/ozone/pull/2713#discussion_r723002688



##########
File path: 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
##########
@@ -855,4 +861,36 @@ public void testShQuota() throws Exception {
     objectStore.getVolume("vol4").deleteBucket("buck4");
     objectStore.deleteVolume("vol4");
   }
+
+  @Test
+  public void testListVolumeShouldPrintValidJson()
+      throws UnsupportedEncodingException {
+
+    final List<String> volumesForThisTest =
+        Arrays.asList("random-vol1", "random-vol2", "random-vol3");
+
+    // Create test volumes
+    volumesForThisTest.forEach(vol ->
+        execute(ozoneShell, new String[] {"volume", "create", vol}));
+    out.reset();
+
+    execute(ozoneShell, new String[] {"volume", "list"});
+
+    // Expect proper JSON output
+    final ArrayList<LinkedTreeMap<String, String>> outArray =
+        new Gson().fromJson(out.toString(DEFAULT_ENCODING), ArrayList.class);
+    // Might have s3v and volumes from other test cases that aren't clean up.
+    Assert.assertTrue(outArray.size() >= 3);
+    final HashSet<String> volumesSet = new HashSet<>(volumesForThisTest);
+    outArray.forEach(treeMap -> volumesSet.remove(treeMap.get("name")));
+
+    // Should have found all 3 volumes we created for this test
+    Assert.assertEquals(0, volumesSet.size());
+
+    // Clean up
+    volumesForThisTest.forEach(vol ->
+        execute(ozoneShell, new String[] {"volume", "delete", vol}));
+    out.reset();
+    err.reset();

Review comment:
       Good point. Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to