HADOOP-17054. ABFS: Fix test AbfsClient authentication instance

Contributed by Sneha Vijayarajan
This commit is contained in:
Sneha Vijayarajan 2020-05-26 15:26:28 -07:00 committed by GitHub
parent 6c9f75cf16
commit 37b1b4799d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -246,21 +246,29 @@ public static AbfsClient createTestClientFromCurrentContext(
AbfsClient baseAbfsClientInstance, AbfsClient baseAbfsClientInstance,
AbfsConfiguration abfsConfig) AbfsConfiguration abfsConfig)
throws AzureBlobFileSystemException { throws AzureBlobFileSystemException {
AbfsPerfTracker tracker = new AbfsPerfTracker("test", AuthType currentAuthType = abfsConfig.getAuthType(
abfsConfig.getAccountName(), abfsConfig.getAccountName());
abfsConfig);
// Create test AbfsClient AbfsPerfTracker tracker = new AbfsPerfTracker("test",
AbfsClient testClient = new AbfsClient( abfsConfig.getAccountName(),
baseAbfsClientInstance.getBaseUrl(), abfsConfig);
new SharedKeyCredentials(abfsConfig.getAccountName().substring(0,
abfsConfig.getAccountName().indexOf(DOT)),
abfsConfig.getStorageAccountKey()),
abfsConfig,
new ExponentialRetryPolicy(abfsConfig.getMaxIoRetries()),
abfsConfig.getTokenProvider(),
tracker);
return testClient; // Create test AbfsClient
} AbfsClient testClient = new AbfsClient(
baseAbfsClientInstance.getBaseUrl(),
(currentAuthType == AuthType.SharedKey
? new SharedKeyCredentials(
abfsConfig.getAccountName().substring(0,
abfsConfig.getAccountName().indexOf(DOT)),
abfsConfig.getStorageAccountKey())
: null),
abfsConfig,
new ExponentialRetryPolicy(abfsConfig.getMaxIoRetries()),
(currentAuthType == AuthType.OAuth
? abfsConfig.getTokenProvider()
: null),
tracker);
return testClient;
}
} }