This is an automated email from the ASF dual-hosted git repository.
siyao pushed a commit to branch HDDS-6517-Snapshot
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/HDDS-6517-Snapshot by this
push:
new 1a52ae199a HDDS-7571. [snapshot] Add unit-testcases for Ozone Snapshot
create API name validation. (#4023)
1a52ae199a is described below
commit 1a52ae199a8b1ec7c413662a08e442354924039e
Author: jyotirmoy-gh <[email protected]>
AuthorDate: Fri Dec 2 03:16:07 2022 +0530
HDDS-7571. [snapshot] Add unit-testcases for Ozone Snapshot create API name
validation. (#4023)
---
.../snapshot/TestOMSnapshotCreateRequest.java | 37 +++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java
index dd3cc2c14b..35f51bf1d5 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java
@@ -147,7 +147,42 @@ public class TestOMSnapshotCreateRequest {
"Invalid snapshot name: " + badName,
() -> doPreExecute(omRequest));
}
-
+
+ @Test
+ public void testPreExecuteNameOnlyNumbers() throws Exception {
+ // check invalid snapshot name containing only numbers
+ String badNameON = "1234";
+ OMRequest omRequest =
+ OMRequestTestUtils.createSnapshotRequest(
+ volumeName, bucketName, badNameON);
+ LambdaTestUtils.intercept(OMException.class,
+ "Invalid snapshot name: " + badNameON,
+ () -> doPreExecute(omRequest));
+ }
+
+ @Test
+ public void testPreExecuteNameLength() throws Exception {
+ // check snapshot name length
+ String name63 =
+ "snap75795657617173401188448010125899089001363595171500499231286";
+ String name64 =
+ "snap156808943643007724443266605711479126926050896107709081166294";
+
+ // name length = 63
+ when(ozoneManager.isOwner(any(), any())).thenReturn(true);
+ OMRequest omRequest = OMRequestTestUtils.createSnapshotRequest(
+ volumeName, bucketName, name63);
+ // should not throw any error
+ doPreExecute(omRequest);
+
+ // name length = 64
+ OMRequest omRequest2 = OMRequestTestUtils.createSnapshotRequest(
+ volumeName, bucketName, name64);
+ LambdaTestUtils.intercept(OMException.class,
+ "Invalid snapshot name: " + name64,
+ () -> doPreExecute(omRequest2));
+ }
+
@Test
public void testValidateAndUpdateCache() throws Exception {
when(ozoneManager.isAdmin(any())).thenReturn(true);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]