steveloughran commented on a change in pull request #2150:
URL: https://github.com/apache/hadoop/pull/2150#discussion_r457668405
##########
File path:
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemDelete.java
##########
@@ -181,6 +186,64 @@ public void testDeleteIdempotency() throws Exception {
.describedAs(
"Delete is considered idempotent by default and should return
success.")
.isEqualTo(HTTP_OK);
+
+ // Case 2: Mock instance of Http Operation response. This will return
+ // HTTP:Bad Request
+ AbfsHttpOperation http400Op = mock(AbfsHttpOperation.class);
+ when(http400Op.getStatusCode()).thenReturn(HTTP_BAD_REQUEST);
+
+ // Mock delete response to 400
+ when(op.getResult()).thenReturn(http400Op);
+
+ Assertions.assertThat(testClient.deleteIdempotencyCheckOp(op)
+ .getResult()
+ .getStatusCode())
+ .describedAs(
+ "Idempotency check to happen only for HTTP 404 response.")
+ .isEqualTo(HTTP_BAD_REQUEST);
+
+ }
+
+ @Test
+ public void testDeleteIdempotencyTriggerHttp404() throws Exception {
+
+ final AzureBlobFileSystem fs = getFileSystem();
+ AbfsClient client = TestAbfsClient.createTestClientFromCurrentContext(
+ fs.getAbfsStore().getClient(),
+ this.getConfiguration());
+
+ // Case 1: Not a retried case should throw error back
+ intercept(AbfsRestOperationException.class,
+ () -> client.deletePath(
+ "/NonExistingPath",
+ false,
+ null));
+
+ // mock idempotency check to mimick retried case
Review comment:
check spelling of mimic
##########
File path:
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsRestOperation.java
##########
@@ -170,7 +170,7 @@ String getSasToken() {
* Executes the REST operation with retry, by issuing one or more
* HTTP operations.
*/
- void execute() throws AzureBlobFileSystemException {
+ public void execute() throws AzureBlobFileSystemException {
Review comment:
tag this as @VisibleForTesting too
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]