-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
HADOOP-18869: [ABFS] Fixing Behavior of a File System APIs on root path #6003
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
import java.util.EnumSet; | ||
import java.util.UUID; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.Test; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
|
@@ -33,6 +34,7 @@ | |
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.FSDataOutputStream; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants; | ||
import org.apache.hadoop.fs.permission.FsAction; | ||
import org.apache.hadoop.fs.permission.FsPermission; | ||
import org.apache.hadoop.test.GenericTestUtils; | ||
|
@@ -146,6 +148,30 @@ public void testCreateNonRecursive2() throws Exception { | |
assertIsFile(fs, testFile); | ||
} | ||
|
||
@Test | ||
public void testCreateOnRoot() throws Exception { | ||
final AzureBlobFileSystem fs = getFileSystem(); | ||
Path testFile = path(AbfsHttpConstants.ROOT_PATH); | ||
try { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you shouldn't need the double catch. intercept() will return the caught exception, type case to the class of arg 1, so can be asserted on. and if an exception is not the one expected, the stack trace is too important to lose. so rethrow it or use as the cause of an assertion error AbfsRestOperationException e = intercept(...)
if (e.getStatusCode()!=HTTP_CONFLICT) {
// rethrow if its not the expected one.
throw e;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken |
||
intercept(AbfsRestOperationException.class, () -> | ||
fs.create(testFile, true)); | ||
} catch (AbfsRestOperationException e) { | ||
Assertions.assertThat(e.getStatusCode()) | ||
.describedAs("Request should fail with 409 Conflict") | ||
.isEqualTo(HTTP_CONFLICT); | ||
} | ||
try { | ||
intercept(AbfsRestOperationException.class, () -> | ||
fs.createNonRecursive(testFile, FsPermission.getDefault(), | ||
false, 1024, (short) 1, 1024, null)); | ||
|
||
} catch (AbfsRestOperationException e) { | ||
Assertions.assertThat(e.getStatusCode()) | ||
.describedAs("Request should fail with 409 Conflict") | ||
.isEqualTo(HTTP_CONFLICT); | ||
} | ||
} | ||
|
||
/** | ||
* Attempts to use to the ABFS stream after it is closed. | ||
*/ | ||
|
@@ -190,7 +216,8 @@ public void testTryWithResources() throws Throwable { | |
// the exception raised in close() must be in the caught exception's | ||
// suppressed list | ||
Throwable[] suppressed = fnfe.getSuppressed(); | ||
assertEquals("suppressed count", 1, suppressed.length); | ||
Assertions.assertThat(suppressed.length) | ||
.describedAs("suppressed count should be 1").isEqualTo(1); | ||
Throwable inner = suppressed[0]; | ||
if (!(inner instanceof IOException)) { | ||
throw inner; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractContractRootDirectoryTest.testCreateFileOverRoot() shoud be doing some of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and for some reason these tests are getting skipped even after adding the required configuration. Will debug more on this and get back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I checked further and found the tests were blocked because of the setting here: https://github.com/apache/hadoop/blob/trunk/hadoop-tools/hadoop-azure/src/test/resources/abfs.xml#L20
We have to set the required config fs.contract.test.root-tests-enabled as true here for these tests to run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aah. well, do that then. it's off by default to stop people accidentally deleting their local disk and then complaining. (this has never happened, but...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense..
Set the config to true.
Also, I was trying to add createNonRecursive in AbstractContractRootDirectoryTest.
Looks like ContractTestUtils does not have support for this HDFS API.
Directly getting File System instance and calling createNonRecursive could cause failure when this test wil run with file systems other than ABFS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. but at the same time, adding it will see what breaks...if you touch a file in the hdfs source tree (say its contract xml file...it can be left out the final commit) then we see what it does, and for s3a we will find out later and fix.