steveloughran commented on a change in pull request #1838: HADOOP-16711 Add way to skip verifyBuckets check in S3A fs init() URL: https://github.com/apache/hadoop/pull/1838#discussion_r377172646
########## File path: hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ABucketExistence.java ########## @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.fs.s3a; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URI; +import java.util.UUID; + +import org.junit.Test; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; + +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.FS_S3A; +import static org.apache.hadoop.fs.s3a.Constants.S3A_BUCKET_PROBE; +import static org.apache.hadoop.test.LambdaTestUtils.intercept; + +/** + * Class to test bucket existence api. + * See {@link S3AFileSystem#doBucketProbing()}. + */ +public class ITestS3ABucketExistence extends AbstractS3ATestBase { + + private FileSystem fs; + + private final String randomBucket = + "random-bucket-" + UUID.randomUUID().toString(); + + private final URI uri = URI.create(FS_S3A + "://" + randomBucket); + + @Test + public void testNoBucketProbing() throws Exception { + Configuration configuration = this.getConfiguration(); + configuration.setInt(S3A_BUCKET_PROBE, 0); Review comment: You get a problem in this code because FileSystem.cache() will cache on the URI only; if there's an FS in the cache, your settings aren't picked up -you will always get the previous instance. That often causes intermittent problems with test runs. 1. Use S3ATestUtils.disableFilesystemCaching to turn off caching of the filesystems you get via FileSystem.get 2. and close() them at the end of each test case. You can do with with try/finally or a try-with-resources clause ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
