Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HADOOP-17873. ABFS: Fix transient failures in ITestAbfsStreamStatistics and ITestAbfsRestOperationException #3341

Merged
merged 7 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hadoop-tools/hadoop-azure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@
<include>**/azurebfs/Test*.java</include>
<include>**/azurebfs/**/Test*.java</include>
</includes>
<excludes>
steveloughran marked this conversation as resolved.
Show resolved Hide resolved
<exclude>**/azurebfs/ITestAbfsStreamStatistics*.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -555,6 +558,7 @@
<exclude>**/azurebfs/ITestAzureBlobFileSystemListStatus.java</exclude>
<exclude>**/azurebfs/extensions/ITestAbfsDelegationTokens.java</exclude>
<exclude>**/azurebfs/ITestSmallWriteOptimization.java</exclude>
<exclude>**/azurebfs/ITestAbfsStreamStatistics*.java</exclude>
</excludes>

</configuration>
Expand Down Expand Up @@ -595,6 +599,9 @@
<include>**/azurebfs/ITestAzureBlobFileSystemListStatus.java</include>
<include>**/azurebfs/extensions/ITestAbfsDelegationTokens.java</include>
<include>**/azurebfs/ITestSmallWriteOptimization.java</include>
<excludes>
<exclude>**/azurebfs/ITestAbfsStreamStatistics*.java</exclude>
</excludes>
</includes>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.IOException;
import java.net.URI;

import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -138,4 +139,9 @@ public String getUserAgentSuffix() {
String suffix = ExtensionHelper.getUserAgentSuffix(adaptee, "");
return suffix != null ? suffix : "";
}

@VisibleForTesting
protected CustomTokenProviderAdaptee getCustomTokenProviderAdaptee() {
return adaptee;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1204,4 +1204,9 @@ public ListenableFuture<?> submit(Runnable runnable) {
public <V> void addCallback(ListenableFuture<V> future, FutureCallback<V> callback) {
Futures.addCallback(future, callback, executorService);
}

@VisibleForTesting
protected AccessTokenProvider getTokenProvider() {
return tokenProvider;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.azurebfs.constants.FSOperationType;
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AzureBlobFileSystemException;
import org.apache.hadoop.fs.azurebfs.oauth2.AccessTokenProvider;
import org.apache.hadoop.fs.azurebfs.security.AbfsDelegationTokenManager;
import org.apache.hadoop.fs.azurebfs.services.AbfsClient;
import org.apache.hadoop.fs.azurebfs.services.AbfsOutputStream;
import org.apache.hadoop.fs.azurebfs.services.AuthType;
import org.apache.hadoop.fs.azurebfs.services.TestAbfsClient;
import org.apache.hadoop.fs.azure.AzureNativeFileSystemStore;
import org.apache.hadoop.fs.azure.NativeAzureFileSystem;
import org.apache.hadoop.fs.azure.metrics.AzureFileSystemInstrumentation;
Expand Down Expand Up @@ -241,6 +243,9 @@ public Hashtable<String, String> call() throws Exception {
}
}

public AccessTokenProvider getAccessTokenProvider(final AzureBlobFileSystem fs) {
return TestAbfsClient.getAccessTokenProvider(fs.getAbfsStore().getClient());
}

public void loadConfiguredFileSystem() throws Exception {
// disable auto-creation of filesystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,21 @@ public void testWithDifferentCustomTokenFetchRetry(int numOfRetries) throws Exce
final AzureBlobFileSystem fs1 =
(AzureBlobFileSystem) FileSystem.newInstance(fs.getUri(),
config);
RetryTestTokenProvider.ResetStatusToFirstTokenFetch();
RetryTestTokenProvider retryTestTokenProvider
= RetryTestTokenProvider.getCurrentRetryTestProviderInstance(
getAccessTokenProvider(fs1));
retryTestTokenProvider.resetStatusToFirstTokenFetch();

intercept(Exception.class,
()-> {
fs1.getFileStatus(new Path("/"));
});

// Number of retries done should be as configured
Assert.assertTrue(
"Number of token fetch retries (" + RetryTestTokenProvider.reTryCount
+ ") done, does not match with fs.azure.custom.token.fetch.retry.count configured (" + numOfRetries
+ ")", RetryTestTokenProvider.reTryCount == numOfRetries);
Assert.assertEquals(
"Number of token fetch retries done does not match with fs.azure"
+ ".custom.token.fetch.retry.count configured", numOfRetries,
retryTestTokenProvider.getRetryCount());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,34 @@
*/
public class RetryTestTokenProvider implements CustomTokenProviderAdaptee {

// Need to track first token fetch otherwise will get counted as a retry too.
private static boolean isThisFirstTokenFetch = true;
public static int reTryCount = 0;
private static final Logger LOG = LoggerFactory.getLogger(
RetryTestTokenProvider.class);

private static final Logger LOG = LoggerFactory
.getLogger(RetryTestTokenProvider.class);
// Need to track first token fetch otherwise will get counted as a retry too.
private boolean isThisFirstTokenFetch = true;
private int retryCount = 0;

@Override
public void initialize(Configuration configuration, String accountName)
throws IOException {

}

public static void ResetStatusToFirstTokenFetch() {
/**
* Clear earlier retry details and reset RetryTestTokenProvider instance to
* state of first access token fetch call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

When parallel is set to "classes" (instead of "both"), the StreamStats test passes even with the failure scenario induced by dummy test, as the two tests are run sequentially in the process. However, I guess there might be occasional failures if a different class reads/writes simultaneously in a different process; could not reproduce failure though.

Have made a minor correction to the pom file; the test will be excluded from the parallel run (currently classesandMethods/both) and executed separately along with a bunch of other integration tests that need to be run sequentially

*/
public void resetStatusToFirstTokenFetch() {
steveloughran marked this conversation as resolved.
Show resolved Hide resolved
isThisFirstTokenFetch = true;
reTryCount = 0;
retryCount = 0;
}

@Override
public String getAccessToken() throws IOException {
if (isThisFirstTokenFetch) {
isThisFirstTokenFetch = false;
} else {
reTryCount++;
retryCount++;
}

LOG.debug("RetryTestTokenProvider: Throw an exception in fetching tokens");
Expand All @@ -64,4 +68,13 @@ public String getAccessToken() throws IOException {
public Date getExpiryTime() {
return new Date();
}

public static RetryTestTokenProvider getCurrentRetryTestProviderInstance(
AccessTokenProvider customTokenProvider) {
return (RetryTestTokenProvider) ((CustomTokenProviderAdapter) customTokenProvider).getCustomTokenProviderAdaptee();
}

public int getRetryCount() {
return retryCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,8 @@ public static AbfsRestOperation getRestOp(AbfsRestOperationType type,
url,
requestHeaders);
}

public static AccessTokenProvider getAccessTokenProvider(AbfsClient client) {
return client.getTokenProvider();
}
}