From 6ea10cf41b78bcc54a2b205b2a9f6231f6f574b7 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Mon, 17 Apr 2023 10:18:33 +0100 Subject: [PATCH] HADOOP-18696. ITestS3ABucketExistence arn test failures. (#5557) Explicitly sets the fs.s3a.endpoint.region to eu-west-1 so the ARN-referenced fs creation fails with unknown store rather than IllegalArgumentException. Steve Loughran --- .../hadoop/fs/s3a/ITestS3ABucketExistence.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ABucketExistence.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ABucketExistence.java index fb295f3f09..9485202f64 100644 --- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ABucketExistence.java +++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ABucketExistence.java @@ -34,6 +34,7 @@ import static org.apache.hadoop.fs.contract.ContractTestUtils.dataset; import static org.apache.hadoop.fs.contract.ContractTestUtils.writeDataset; +import static org.apache.hadoop.fs.s3a.Constants.AWS_REGION; import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_ACCESSPOINT_REQUIRED; import static org.apache.hadoop.fs.s3a.Constants.FS_S3A; import static org.apache.hadoop.fs.s3a.Constants.S3A_BUCKET_PROBE; @@ -47,7 +48,7 @@ public class ITestS3ABucketExistence extends AbstractS3ATestBase { private FileSystem fs; private final String randomBucket = - "random-bucket-" + UUID.randomUUID().toString(); + "random-bucket-" + UUID.randomUUID(); private final URI uri = URI.create(FS_S3A + "://" + randomBucket + "/"); @@ -163,7 +164,7 @@ public void testBucketProbingParameterValidation() throws Exception { @Test public void testAccessPointProbingV2() throws Exception { describe("Test V2 bucket probing using an AccessPoint ARN"); - Configuration configuration = createConfigurationWithProbe(2); + Configuration configuration = createArnConfiguration(); String accessPointArn = "arn:aws:s3:eu-west-1:123456789012:accesspoint/" + randomBucket; configuration.set(String.format(InternalConstants.ARN_BUCKET_OPTION, randomBucket), accessPointArn); @@ -175,7 +176,7 @@ public void testAccessPointProbingV2() throws Exception { @Test public void testAccessPointRequired() throws Exception { describe("Test V2 bucket probing with 'fs.s3a.accesspoint.required' property."); - Configuration configuration = createConfigurationWithProbe(2); + Configuration configuration = createArnConfiguration(); configuration.set(AWS_S3_ACCESSPOINT_REQUIRED, "true"); intercept(PathIOException.class, InternalConstants.AP_REQUIRED_EXCEPTION, @@ -189,6 +190,17 @@ public void testAccessPointRequired() throws Exception { () -> FileSystem.get(uri, configuration)); } + /** + * Create a configuration which has bucket probe 2 and the endpoint.region + * option set to "eu-west-1" to match that of the ARNs generated. + * @return a configuration for tests which are expected to fail in specific ways. + */ + private Configuration createArnConfiguration() { + Configuration configuration = createConfigurationWithProbe(2); + configuration.set(AWS_REGION, "eu-west-1"); + return configuration; + } + @Override protected Configuration getConfiguration() { Configuration configuration = super.getConfiguration();