kuenishi commented on a change in pull request #2433:
URL: https://github.com/apache/ozone/pull/2433#discussion_r734118620



##########
File path: 
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyCommitRequest.java
##########
@@ -275,6 +276,76 @@ public void testValidateAndUpdateCacheWithKeyNotFound() 
throws Exception {
     Assert.assertNull(omKeyInfo);
   }
 
+  @Test
+  public void testValidateAndUpdateCacheOnOverwrite() throws Exception {
+    testValidateAndUpdateCache();
+
+    // Become a new client and set next version number
+    clientID = Time.now();
+    version += 1;
+
+    OMRequest modifiedOmRequest = doPreExecute(createCommitKeyRequest());
+
+    OMKeyCommitRequest omKeyCommitRequest =
+            getOmKeyCommitRequest(modifiedOmRequest);
+
+    KeyArgs keyArgs = modifiedOmRequest.getCommitKeyRequest().getKeyArgs();
+
+    // Key should be there in key table, as validateAndUpdateCache is called.
+    OmKeyInfo omKeyInfo =
+        omMetadataManager.getKeyTable().get(getOzonePathKey());
+
+    Assert.assertNotNull(omKeyInfo);
+    // Previously committed version
+    Assert.assertEquals(0L,
+            omKeyInfo.getLatestVersionLocations().getVersion());
+
+    // Append new blocks
+    List<OmKeyLocationInfo> allocatedLocationList =
+            keyArgs.getKeyLocationsList().stream()
+                    .map(OmKeyLocationInfo::getFromProtobuf)
+                    .collect(Collectors.toList());
+    addKeyToOpenKeyTable(allocatedLocationList);
+
+    OMClientResponse omClientResponse =
+            omKeyCommitRequest.validateAndUpdateCache(ozoneManager,
+                    102L, ozoneManagerDoubleBufferHelper);
+
+    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK,
+            omClientResponse.getOMResponse().getStatus());
+
+    String ozoneKey = getOzonePathKey();
+    // Entry should be deleted from openKey Table.

Review comment:
       This line was actually copy & pasted from ` 
testValidateAndUpdateCache()` (line 152-153), but as this is not the test for 
overwriting, I'm removing it.




-- 
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