Skip to content

HADOOP-19618. Replace AssumptionViolatedException with TestAbortedException. #7800

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

Open
wants to merge 1 commit into
base: trunk
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 @@ -23,7 +23,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.junit.internal.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;

/**
* Utilities for the CosN tests.
Expand Down Expand Up @@ -52,7 +52,7 @@ public static CosNFileSystem createTestFileSystem(
testUri = URI.create(fsName);
liveTest = testUri.getScheme().equals(CosNFileSystem.SCHEME);
} else {
throw new AssumptionViolatedException("no test file system in " +
throw new TestAbortedException("no test file system in " +
fsName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.junit.internal.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;

import java.io.IOException;
import java.net.URI;
Expand All @@ -45,7 +45,7 @@ public final class OBSTestUtils {
* @param conf configuration
* @return the FS
* @throws IOException IO Problems
* @throws AssumptionViolatedException if the FS is not named
* @throws TestAbortedException if the FS is not named
*/
public static OBSFileSystem createTestFileSystem(Configuration conf)
throws IOException {
Expand All @@ -62,7 +62,7 @@ public static OBSFileSystem createTestFileSystem(Configuration conf)
* @param purge flag to enable Multipart purging
* @return the FS
* @throws IOException IO Problems
* @throws AssumptionViolatedException if the FS is not named
* @throws TestAbortedException if the FS is not named
*/
@SuppressWarnings("deprecation")
public static OBSFileSystem createTestFileSystem(Configuration conf,
Expand All @@ -80,7 +80,7 @@ public static OBSFileSystem createTestFileSystem(Configuration conf,
if (!liveTest) {
// This doesn't work with our JUnit 3 style test cases, so instead we'll
// make this whole class not run by default
throw new AssumptionViolatedException(
throw new TestAbortedException(
"No test filesystem in " + TEST_FS_OBS_NAME);
}
OBSFileSystem fs1 = new OBSFileSystem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.hadoop.fs.StreamCapabilities;

import org.junit.jupiter.api.Test;
import org.junit.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -172,7 +172,7 @@ private void testOverwriteNonEmptyDirectory(boolean useBuilder)
} catch (AssertionError failure) {
if (isSupported(CREATE_OVERWRITES_DIRECTORY)) {
// file/directory hack surfaces here
throw new AssumptionViolatedException(failure.toString(), failure);
throw new TestAbortedException(failure.toString(), failure);
}
// else: rethrow
throw failure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Timeout;
import org.junit.AssumptionViolatedException;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.opentest4j.TestAbortedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -149,7 +149,7 @@ protected boolean isSupported(String feature) throws IOException {
*/
protected void assumeEnabled() {
if (!contract.isEnabled())
throw new AssumptionViolatedException("test cases disabled for " + contract);
throw new TestAbortedException("test cases disabled for " + contract);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.apache.hadoop.util.functional.FutureIO;

import org.junit.jupiter.api.Assertions;
import org.junit.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -565,19 +565,19 @@ public static void noteAction(String action) {
* exception for the Junit test runner to mark as failed.
* @param message text message
* @param failure what failed
* @throws AssumptionViolatedException always
* @throws TestAbortedException always
*/
public static void downgrade(String message, Throwable failure) {
LOG.warn("Downgrading test " + message, failure);
AssumptionViolatedException ave =
new AssumptionViolatedException(failure, null);
TestAbortedException ave =
new TestAbortedException(null, failure);
throw ave;
}

/**
* report an overridden test as unsupported.
* @param message message to use in the text
* @throws AssumptionViolatedException always
* @throws TestAbortedException always
*/
public static void unsupported(String message) {
skip(message);
Expand All @@ -586,11 +586,11 @@ public static void unsupported(String message) {
/**
* report a test has been skipped for some reason.
* @param message message to use in the text
* @throws AssumptionViolatedException always
* @throws TestAbortedException always
*/
public static void skip(String message) {
LOG.info("Skipping: {}", message);
throw new AssumptionViolatedException(message);
throw new TestAbortedException(message);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.apache.hadoop.test;

import org.junit.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;

/**
* JUnit assumptions for the environment (OS).
Expand All @@ -34,13 +34,13 @@ public static void assumeNotWindows() {

public static void assumeNotWindows(String message) {
if (WINDOWS) {
throw new AssumptionViolatedException(message);
throw new TestAbortedException(message);
}
}

public static void assumeWindows() {
if (!WINDOWS) {
throw new AssumptionViolatedException(
throw new TestAbortedException(
"Expected Windows platform but got " + OS_NAME);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.StorageType;
import org.apache.hadoop.util.Shell;
import org.junit.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;
import org.junit.Test;

import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY;
Expand Down Expand Up @@ -104,7 +104,7 @@ public void testDataDirParsing() throws Throwable {
@Test
public void testDataDirFileSystem() throws Exception {
if (Shell.MAC) {
throw new AssumptionViolatedException("Not supported on MAC OS");
throw new TestAbortedException("Not supported on MAC OS");
}
Configuration conf = new Configuration();
String archiveDir = "/home";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
import org.apache.hadoop.security.authentication.client.ConnectionConfigurator;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.AssumptionViolatedException;
import org.junit.jupiter.api.Timeout;
import org.opentest4j.TestAbortedException;

/**
* This test suite checks that WebHdfsFileSystem sets connection timeouts and
Expand Down Expand Up @@ -408,7 +408,7 @@ private void consumeConnectionBacklog() throws IOException {

private void assumeBacklogConsumed() {
if (failedToConsumeBacklog) {
throw new AssumptionViolatedException(
throw new TestAbortedException(
"failed to fill up connection backlog.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileContext;
import org.junit.internal.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;

import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -68,7 +68,7 @@ private static URI getURI(Configuration conf) {
}

if (!liveTest) {
throw new AssumptionViolatedException("No test filesystem in "
throw new TestAbortedException("No test filesystem in "
+ TestAliyunOSSFileSystemContract.TEST_FS_OSS_NAME);
}
return testURI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import org.assertj.core.api.Assertions;
import org.assertj.core.api.Assumptions;
import org.junit.Assume;
import org.junit.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
Expand Down Expand Up @@ -201,7 +201,7 @@ public static String getFsName(Configuration conf) {
* @param conf configuration
* @return the FS
* @throws IOException IO Problems
* @throws AssumptionViolatedException if the FS is not named
* @throws TestAbortedException if the FS is not named
*/
public static S3AFileSystem createTestFileSystem(Configuration conf)
throws IOException {
Expand Down Expand Up @@ -1470,7 +1470,7 @@ public static void assertOptionEquals(Configuration conf,

/**
* Assume that a condition is met. If not: log at WARN and
* then throw an {@link AssumptionViolatedException}.
* then throw an {@link TestAbortedException}.
* @param message
* @param condition
*/
Expand All @@ -1488,7 +1488,7 @@ public static void assume(String message, boolean condition) {
* @param t thrown exception.
*/
public static void raiseAsAssumption(Throwable t) {
throw new AssumptionViolatedException(t.toString(), t);
throw new TestAbortedException(t.toString(), t);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import org.junit.jupiter.api.Assertions;
import org.junit.Assume;
import org.junit.internal.AssumptionViolatedException;
import org.opentest4j.TestAbortedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -75,7 +75,7 @@ public final class AzureTestUtils extends Assertions {
* @param conf configuration
* @return the FS
* @throws IOException IO Problems
* @throws AssumptionViolatedException if the FS is not named
* @throws TestAbortedException if the FS is not named
*/
public static NativeAzureFileSystem createTestFileSystem(Configuration conf)
throws IOException {
Expand All @@ -90,7 +90,7 @@ public static NativeAzureFileSystem createTestFileSystem(Configuration conf)
}
if (!liveTest) {
// Skip the test
throw new AssumptionViolatedException(
throw new TestAbortedException(
"No test filesystem in " + TEST_FS_WASB_NAME);
}
NativeAzureFileSystem fs1 = new NativeAzureFileSystem();
Expand All @@ -108,7 +108,7 @@ public static NativeAzureFileSystem createTestFileSystem(Configuration conf)
* @param conf configuration
* @return the FS
* @throws IOException IO Problems
* @throws AssumptionViolatedException if the FS is not named
* @throws TestAbortedException if the FS is not named
*/
public static FileContext createTestFileContext(Configuration conf)
throws IOException {
Expand All @@ -123,7 +123,7 @@ public static FileContext createTestFileContext(Configuration conf)
if (!liveTest) {
// This doesn't work with our JUnit 3 style test cases, so instead we'll
// make this whole class not run by default
throw new AssumptionViolatedException("No test filesystem in "
throw new TestAbortedException("No test filesystem in "
+ TEST_FS_WASB_NAME);
}
FileContext fc = FileContext.getFileContext(testURI, conf);
Expand Down Expand Up @@ -386,7 +386,7 @@ public static void assertOptionEquals(Configuration conf,

/**
* Assume that a condition is met. If not: log at WARN and
* then throw an {@link AssumptionViolatedException}.
* then throw an {@link TestAbortedException}.
* @param message message in an assumption
* @param condition condition to probe
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.hadoop.fs.FileSystem;
import org.assertj.core.api.Assertions;
import org.junit.Assume;
import org.junit.AssumptionViolatedException;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
Expand All @@ -47,6 +46,7 @@
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.util.Preconditions;
import org.opentest4j.TestAbortedException;

import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.EMPTY_STRING;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_CLIENT_CORRELATIONID;
Expand Down Expand Up @@ -181,7 +181,7 @@ public void runCorrelationTestForAllMethods() throws Exception {
testClasses.get(testClass).invoke(testClass);
testClass.teardown();
} catch (InvocationTargetException e) {
if (!(e.getCause() instanceof AssumptionViolatedException)) {
if (!(e.getCause() instanceof TestAbortedException)) {
throw new IOException(testClasses.get(testClass).getName()
+ " failed tracing context validation test");
}
Expand Down