HADOOP-17398. Skipping network I/O in S3A getFileStatus(/) breaks some tests (#2493)

Follow-on to HADOOP-17323.

Contributed by Mukund Thakur.
This commit is contained in:
Mukund Thakur 2020-11-27 01:55:32 +05:30 committed by Steve Loughran
parent 1e59bf7394
commit 3ef0e3d615
2 changed files with 22 additions and 12 deletions

View File

@ -282,16 +282,24 @@ public final class MarkerTool extends S3GuardTool {
} }
FileSystem fs = path.getFileSystem(getConf()); FileSystem fs = path.getFileSystem(getConf());
boolean nonAuth = command.getOpt(OPT_NONAUTH); boolean nonAuth = command.getOpt(OPT_NONAUTH);
ScanResult result = execute( ScanResult result;
new ScanArgsBuilder() try {
.withSourceFS(fs) result = execute(
.withPath(path) new ScanArgsBuilder()
.withDoPurge(clean) .withSourceFS(fs)
.withMinMarkerCount(expectedMin) .withPath(path)
.withMaxMarkerCount(expectedMax) .withDoPurge(clean)
.withLimit(limit) .withMinMarkerCount(expectedMin)
.withNonAuth(nonAuth) .withMaxMarkerCount(expectedMax)
.build()); .withLimit(limit)
.withNonAuth(nonAuth)
.build());
} catch (UnknownStoreException ex) {
// bucket doesn't exist.
// replace the stack trace with an error code.
throw new ExitUtil.ExitException(EXIT_NOT_FOUND,
ex.toString(), ex);
}
if (verbose) { if (verbose) {
dumpFileSystemStatistics(out); dumpFileSystemStatistics(out);
} }

View File

@ -62,8 +62,10 @@ public class ITestS3ABucketExistence extends AbstractS3ATestBase {
Path root = new Path(uri); Path root = new Path(uri);
expectUnknownStore( //See HADOOP-17323.
() -> fs.getFileStatus(root)); assertTrue("root path should always exist", fs.exists(root));
assertTrue("getFileStatus on root should always return a directory",
fs.getFileStatus(root).isDirectory());
expectUnknownStore( expectUnknownStore(
() -> fs.listStatus(root)); () -> fs.listStatus(root));