Skip to content

HADOOP-19646. [JDK17] Migrate hadoop-aws module from JUnit4 Assume to JUnit5 Assumptions. #7858

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

Merged
merged 2 commits into from
Aug 12, 2025
Merged
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 @@ -18,7 +18,7 @@

package org.apache.hadoop.fs.s3a;

import org.junit.Assume;
import static org.assertj.core.api.Assumptions.assumeThat;

/**
* Use {@link Constants#FAST_UPLOAD_BUFFER_DISK} for buffering.
Expand All @@ -36,7 +36,9 @@ protected String getBlockOutputBufferName() {
* @return null
*/
protected S3ADataBlocks.BlockFactory createFactory(S3AFileSystem fileSystem) {
Assume.assumeTrue("mark/reset not supported", false);
assumeThat(false)
.as("mark/reset not supported")
.isTrue();
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.hadoop.fs.s3a.impl.ChangeDetectionPolicy.Source;
import org.apache.hadoop.test.LambdaTestUtils;

import org.junit.Assume;
import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;
Expand All @@ -36,6 +35,7 @@
import static org.apache.hadoop.fs.s3a.Constants.RETRY_INTERVAL;
import static org.apache.hadoop.fs.s3a.Constants.RETRY_LIMIT;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.removeBaseAndBucketOverrides;
import static org.assertj.core.api.Assumptions.assumeThat;

/**
* Tests behavior of a FileNotFound error that happens after open(), i.e. on
Expand Down Expand Up @@ -68,9 +68,9 @@ public void testNotFoundFirstRead() throws Exception {
S3AFileSystem fs = getFileSystem();
ChangeDetectionPolicy changeDetectionPolicy =
fs.getChangeDetectionPolicy();
Assume.assumeFalse("FNF not expected when using a bucket with"
+ " object versioning",
changeDetectionPolicy.getSource() == Source.VersionId);
assumeThat(changeDetectionPolicy.getSource())
.as("FNF not expected when using a bucket with object versioning")
.isNotEqualTo(Source.VersionId);

Path p = path("some-file");
ContractTestUtils.createFile(fs, p, false, new byte[] {20, 21, 22});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@

import org.assertj.core.api.Assertions;
import org.assertj.core.api.Assumptions;
import org.junit.Assume;
import org.opentest4j.TestAbortedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -127,6 +126,7 @@
import static org.apache.hadoop.util.functional.FunctionalIO.uncheckIOExceptions;
import static org.apache.hadoop.util.functional.RemoteIterators.mappingRemoteIterator;
import static org.apache.hadoop.util.functional.RemoteIterators.toList;
import static org.assertj.core.api.Assumptions.assumeThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
Expand Down Expand Up @@ -234,8 +234,9 @@ public static S3AFileSystem createTestFileSystem(Configuration conf,
}
// This doesn't work with our JUnit 3 style test cases, so instead we'll
// make this whole class not run by default
Assume.assumeTrue("No test filesystem in " + TEST_FS_S3A_NAME,
liveTest);
assumeThat(liveTest)
.as("No test filesystem in " + TEST_FS_S3A_NAME)
.isTrue();

S3AFileSystem fs1 = new S3AFileSystem();
//enable purging in tests
Expand Down Expand Up @@ -276,8 +277,9 @@ public static FileContext createTestFileContext(Configuration conf)
}
// This doesn't work with our JUnit 3 style test cases, so instead we'll
// make this whole class not run by default
Assume.assumeTrue("No test filesystem in " + TEST_FS_S3A_NAME,
liveTest);
assumeThat(liveTest)
.as("No test filesystem in " + TEST_FS_S3A_NAME)
.isTrue();
FileContext fc = FileContext.getFileContext(testURI, conf);
return fc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.stream.IntStream;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Assume;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -46,6 +45,7 @@
import static org.apache.hadoop.fs.s3a.auth.RolePolicies.*;
import static org.apache.hadoop.fs.s3a.auth.delegation.DelegationConstants.DELEGATION_TOKEN_BINDING;
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
import static org.assertj.core.api.Assumptions.assumeThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -212,8 +212,9 @@ public static <T> AccessDeniedException forbidden(
*/
public static String probeForAssumedRoleARN(Configuration conf) {
String arn = conf.getTrimmed(ASSUMED_ROLE_ARN, "");
Assume.assumeTrue("No ARN defined in " + ASSUMED_ROLE_ARN,
!arn.isEmpty());
assumeThat(arn)
.as("No ARN defined in " + ASSUMED_ROLE_ARN)
.isNotEmpty();
return arn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package org.apache.hadoop.fs.s3a.test;

import org.junit.Assume;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
Expand All @@ -29,6 +27,7 @@

import static org.apache.hadoop.fs.s3a.S3ATestConstants.KEY_BUCKET_WITH_MANY_OBJECTS;
import static org.apache.hadoop.fs.s3a.S3ATestConstants.KEY_REQUESTER_PAYS_FILE;
import static org.assertj.core.api.Assumptions.assumeThat;

/**
* Provides S3A filesystem URIs for public data sets for specific use cases.
Expand Down Expand Up @@ -128,8 +127,9 @@ public static Path requireAnonymousDataPath(Configuration conf) {
*/
public static String requireDefaultExternalDataFile(Configuration conf) {
String filename = getExternalData(conf).toUri().toString();
Assume.assumeTrue("External test file is not the default",
DEFAULT_EXTERNAL_FILE.equals(filename));
assumeThat(filename)
.as("External test file is not the default")
.isEqualTo(DEFAULT_EXTERNAL_FILE);
return filename;
}

Expand Down