|
@@ -283,6 +283,33 @@ public class TestOzoneShell {
|
|
GenericTestUtils.assertExceptionContains(
|
|
GenericTestUtils.assertExceptionContains(
|
|
"Info Volume failed, error:VOLUME_NOT_FOUND", e);
|
|
"Info Volume failed, error:VOLUME_NOT_FOUND", e);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ volumeName = "volume" + RandomStringUtils.randomNumeric(5);
|
|
|
|
+ volumeArgs = VolumeArgs.newBuilder()
|
|
|
|
+ .setOwner("bilbo")
|
|
|
|
+ .setQuota("100TB")
|
|
|
|
+ .build();
|
|
|
|
+ client.createVolume(volumeName, volumeArgs);
|
|
|
|
+ volume = client.getVolumeDetails(volumeName);
|
|
|
|
+ assertNotNull(volume);
|
|
|
|
+
|
|
|
|
+ //volumeName prefixed with /
|
|
|
|
+ String volumeNameWithSlashPrefix = "/" + volumeName;
|
|
|
|
+ args = new String[] {"volume", "delete",
|
|
|
|
+ url + "/" + volumeNameWithSlashPrefix};
|
|
|
|
+ execute(shell, args);
|
|
|
|
+ output = out.toString();
|
|
|
|
+ assertTrue(output.contains("Volume " + volumeName + " is deleted"));
|
|
|
|
+
|
|
|
|
+ // verify if volume has been deleted
|
|
|
|
+ try {
|
|
|
|
+ client.getVolumeDetails(volumeName);
|
|
|
|
+ fail("Get volume call should have thrown.");
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ GenericTestUtils.assertExceptionContains(
|
|
|
|
+ "Info Volume failed, error:VOLUME_NOT_FOUND", e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -295,6 +322,7 @@ public class TestOzoneShell {
|
|
.build();
|
|
.build();
|
|
client.createVolume(volumeName, volumeArgs);
|
|
client.createVolume(volumeName, volumeArgs);
|
|
|
|
|
|
|
|
+ //volumeName supplied as-is
|
|
String[] args = new String[] {"volume", "info", url + "/" + volumeName};
|
|
String[] args = new String[] {"volume", "info", url + "/" + volumeName};
|
|
execute(shell, args);
|
|
execute(shell, args);
|
|
|
|
|
|
@@ -303,6 +331,17 @@ public class TestOzoneShell {
|
|
assertTrue(output.contains("createdOn")
|
|
assertTrue(output.contains("createdOn")
|
|
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
|
&& output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
|
|
|
|
|
|
|
+ //volumeName prefixed with /
|
|
|
|
+ String volumeNameWithSlashPrefix = "/" + volumeName;
|
|
|
|
+ args = new String[] {"volume", "info",
|
|
|
|
+ url + "/" + volumeNameWithSlashPrefix};
|
|
|
|
+ execute(shell, args);
|
|
|
|
+
|
|
|
|
+ output = out.toString();
|
|
|
|
+ assertTrue(output.contains(volumeName));
|
|
|
|
+ assertTrue(output.contains("createdOn")
|
|
|
|
+ && output.contains(OzoneConsts.OZONE_TIME_ZONE));
|
|
|
|
+
|
|
// test infoVolume with invalid volume name
|
|
// test infoVolume with invalid volume name
|
|
args = new String[] {"volume", "info",
|
|
args = new String[] {"volume", "info",
|
|
url + "/" + volumeName + "/invalid-name"};
|
|
url + "/" + volumeName + "/invalid-name"};
|
|
@@ -365,6 +404,15 @@ public class TestOzoneShell {
|
|
vol = client.getVolumeDetails(volumeName);
|
|
vol = client.getVolumeDetails(volumeName);
|
|
assertEquals(newUser, vol.getOwner());
|
|
assertEquals(newUser, vol.getOwner());
|
|
|
|
|
|
|
|
+ //volume with / prefix
|
|
|
|
+ String volumeWithPrefix = "/" + volumeName;
|
|
|
|
+ String newUser2 = "new-user2";
|
|
|
|
+ args = new String[] {"volume", "update", url + "/" + volumeWithPrefix,
|
|
|
|
+ "--user", newUser2};
|
|
|
|
+ execute(shell, args);
|
|
|
|
+ vol = client.getVolumeDetails(volumeName);
|
|
|
|
+ assertEquals(newUser2, vol.getOwner());
|
|
|
|
+
|
|
// test error conditions
|
|
// test error conditions
|
|
args = new String[] {"volume", "update", url + "/invalid-volume",
|
|
args = new String[] {"volume", "update", url + "/invalid-volume",
|
|
"--user", newUser};
|
|
"--user", newUser};
|