bhattmanish98 commented on code in PR #7364:
URL: https://github.com/apache/hadoop/pull/7364#discussion_r1967079356


##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/AbstractAbfsIntegrationTest.java:
##########
@@ -733,4 +737,53 @@ protected void checkFuturesForExceptions(List<Future<?>> 
futures, int exceptionV
     }
     assertEquals(exceptionCaught, exceptionVal);
   }
+
+  /**
+   * Assumes that recovery through client transaction ID is enabled.
+   * Namespace is enabled for the given AzureBlobFileSystem.
+   * Service type is DFS.
+   * Assumes that the client transaction ID is enabled in the configuration.
+   *
+   * @param fs the AzureBlobFileSystem instance to check
+   * @throws AzureBlobFileSystemException in case of an error
+   */
+  protected void assumeRecoveryThroughClientTransactionID(
+      AzureBlobFileSystem fs, boolean isCreate)
+      throws AzureBlobFileSystemException {
+    // Assumes that recovery through client transaction ID is enabled.
+    Assume.assumeTrue(getConfiguration().getIsClientTransactionIdEnabled());
+    // Assumes that service type is DFS.
+    assumeDfsServiceType();
+    // Assumes that namespace is enabled for the given AzureBlobFileSystem.
+    Assume.assumeTrue(
+        fs.getIsNamespaceEnabled(getTestTracingContext(fs, true)));
+    if (isCreate) {
+      // Assume that create client is DFS client.
+      Assume.assumeTrue(
+          AbfsServiceType.DFS.equals(
+              
fs.getAbfsStore().getAbfsConfiguration().getIngressServiceType()));
+      // Assume that append blob is not enabled in DFS client.
+      Assume.assumeFalse(isAppendBlobEnabled());
+    }
+  }
+
+  /**
+   * Mocks the behavior of adding a client transaction ID to the request 
headers
+   * for the given AzureBlobFileSystem. This method generates a random 
transaction ID
+   * and adds it to the headers of the {@link AbfsDfsClient}.
+   *
+   * @param abfsDfsClient The {@link AbfsDfsClient} mocked AbfsDfsClient.
+   * @param clientTransactionId An array to hold the generated transaction ID.
+   */
+  protected void mockAddClientTransactionIdToHeader(AbfsDfsClient 
abfsDfsClient,
+      String[] clientTransactionId) {
+    Mockito.doAnswer(addClientTransactionId -> {
+      clientTransactionId[0] = UUID.randomUUID().toString();
+      List<AbfsHttpHeader> headers = addClientTransactionId.getArgument(0);
+      headers.add(
+          new AbfsHttpHeader(X_MS_CLIENT_TRANSACTION_ID,
+              clientTransactionId[0]));
+      return clientTransactionId[0];
+    }).when(abfsDfsClient).addClientTransactionIdToHeader(Mockito.anyList());
+  }
 }

Review Comment:
   Setting client transaction id header to true will not help, as there can be 
cases where server changes is not deployed and if we set the flag as true, it 
will not return client transaction id in the get path status response. 



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