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-18325: [ABFS] Fix metric related test failures due to missing … #7306

Open
wants to merge 1 commit into
base: branch-3.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.classification.VisibleForTesting;
import org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants;
import org.apache.hadoop.fs.azurebfs.constants.HttpOperationType;
Expand Down Expand Up @@ -246,21 +247,24 @@ private AbfsClient(final URL baseUrl,
this.isMetricCollectionStopped = new AtomicBoolean(false);
this.metricAnalysisPeriod = abfsConfiguration.getMetricAnalysisTimeout();
this.metricIdlePeriod = abfsConfiguration.getMetricIdleTimeout();
if (!metricFormat.toString().equals("")) {
isMetricCollectionEnabled = true;
abfsCounters.initializeMetrics(metricFormat);
if (StringUtils.isNotEmpty(metricFormat.toString())) {
String metricAccountName = abfsConfiguration.getMetricAccount();
int dotIndex = metricAccountName.indexOf(AbfsHttpConstants.DOT);
if (dotIndex <= 0) {
throw new InvalidUriException(
metricAccountName + " - account name is not fully qualified.");
}
String metricAccountKey = abfsConfiguration.getMetricAccountKey();
try {
metricSharedkeyCredentials = new SharedKeyCredentials(metricAccountName.substring(0, dotIndex),
metricAccountKey);
} catch (IllegalArgumentException e) {
throw new IOException("Exception while initializing metric credentials " + e);
if (StringUtils.isNotEmpty(metricAccountName) && StringUtils.isNotEmpty(metricAccountKey)) {
isMetricCollectionEnabled = true;
abfsCounters.initializeMetrics(metricFormat);
int dotIndex = metricAccountName.indexOf(AbfsHttpConstants.DOT);
if (dotIndex <= 0) {
throw new InvalidUriException(
metricAccountName + " - account name is not fully qualified.");
}
try {
metricSharedkeyCredentials = new SharedKeyCredentials(
metricAccountName.substring(0, dotIndex),
metricAccountKey);
} catch (IllegalArgumentException e) {
throw new IOException("Exception while initializing metric credentials ", e);
}
}
}
this.timer = new Timer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import static org.apache.hadoop.fs.CommonConfigurationKeys.IOSTATISTICS_LOGGING_LEVEL_INFO;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_READ_BUFFER_SIZE;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_WRITE_BUFFER_SIZE;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_KEY;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_NAME;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_FORMAT;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_URI;
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.MIN_BUFFER_SIZE;
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.ONE_KB;
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.ONE_MB;
Expand All @@ -30,6 +33,8 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.azurebfs.utils.MetricFormat;

import org.junit.Assume;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -47,6 +52,20 @@
public class ITestAbfsReadFooterMetrics extends AbstractAbfsScaleTest {

public ITestAbfsReadFooterMetrics() throws Exception {
checkPrerequisites();
}

private void checkPrerequisites(){
checkIfConfigIsSet(FS_AZURE_METRIC_ACCOUNT_NAME);
checkIfConfigIsSet(FS_AZURE_METRIC_ACCOUNT_KEY);
checkIfConfigIsSet(FS_AZURE_METRIC_URI);
}

private void checkIfConfigIsSet(String configKey){
AbfsConfiguration conf = getConfiguration();
String value = conf.get(configKey);
Assume.assumeTrue(configKey + " config is mandatory for the test to run",
value != null && value.trim().length() > 1);
}

private static final String TEST_PATH = "/testfile";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import org.apache.hadoop.fs.azurebfs.utils.MetricFormat;
import org.junit.Test;
import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.HTTP_METHOD_DELETE;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_KEY;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_NAME;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_FORMAT;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_URI;
import static org.apache.hadoop.fs.azurebfs.services.AbfsRestOperationType.DeletePath;
import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem;
import org.apache.hadoop.fs.azurebfs.AbstractAbfsIntegrationTest;
Expand All @@ -39,6 +42,12 @@ public class TestAbfsRestOperation extends
public TestAbfsRestOperation() throws Exception {
}

private void checkPrerequisites() {
assumeValidTestConfigPresent(getRawConfiguration(), FS_AZURE_METRIC_ACCOUNT_NAME);
assumeValidTestConfigPresent(getRawConfiguration(), FS_AZURE_METRIC_ACCOUNT_KEY);
assumeValidTestConfigPresent(getRawConfiguration(), FS_AZURE_METRIC_URI);
}

/**
* Test for backoff retry metrics.
*
Expand All @@ -49,6 +58,7 @@ public TestAbfsRestOperation() throws Exception {
*/
@Test
public void testBackoffRetryMetrics() throws Exception {
checkPrerequisites();
// Create an AzureBlobFileSystem instance.
final Configuration configuration = getRawConfiguration();
configuration.set(FS_AZURE_METRIC_FORMAT, String.valueOf(MetricFormat.INTERNAL_BACKOFF_METRIC_FORMAT));
Expand Down