SaketaChalamchala commented on code in PR #8157:
URL: https://github.com/apache/ozone/pull/8157#discussion_r2014569797
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java:
##########
@@ -264,6 +264,39 @@ public void testEntryExists() throws Exception {
assertEquals(2, getOmMetrics().getNumSnapshotCreates());
}
+ @Test
+ public void testSnapshotLimit() throws Exception {
+ when(getOzoneManager().isAdmin(any())).thenReturn(true);
+
+ when(getOzoneManager().getFsSnapshotMaxLimit()).thenReturn(1);
+
+ String key1 = getTableKey(getVolumeName(), getBucketName(), snapshotName1);
+
+ OMRequest omRequest =
+ createSnapshotRequest(getVolumeName(), getBucketName(), snapshotName1);
+ OMSnapshotCreateRequest omSnapshotCreateRequest = doPreExecute(omRequest);
+
+ assertNull(getOmMetadataManager().getSnapshotInfoTable().get(key1));
+ omSnapshotCreateRequest.validateAndUpdateCache(getOzoneManager(), 1);
+
+ assertNotNull(getOmMetadataManager().getSnapshotInfoTable().get(key1));
+
+ // Should fail as snapshot limit is 1
+ omRequest = createSnapshotRequest(getVolumeName(), getBucketName(),
snapshotName2);
+ omSnapshotCreateRequest = doPreExecute(omRequest);
+ OMClientResponse omClientResponse =
+ omSnapshotCreateRequest.validateAndUpdateCache(getOzoneManager(), 2);
+
+ OMResponse omResponse = omClientResponse.getOMResponse();
+ assertNotNull(omResponse.getCreateSnapshotResponse());
+ assertEquals(OzoneManagerProtocolProtos.Status.INVALID_SNAPSHOT_ERROR,
+ omResponse.getStatus());
+
+ assertEquals(1, getOmMetrics().getNumSnapshotCreateFails());
+ assertEquals(1, getOmMetrics().getNumSnapshotActive());
+ assertEquals(2, getOmMetrics().getNumSnapshotCreates());
Review Comment:
Could you also expand the test to delete a snapshot and create one again?
--
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]