Skip to content

Commit df6285a

Browse files
committed
update option and tests for root delete
1 parent bb78dff commit df6285a

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractRootDirectoryTest.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@ public void testRmEmptyRootDirRecursive() throws Throwable {
8080
skipIfUnsupported(TEST_ROOT_TESTS_ENABLED);
8181
Path root = new Path("/");
8282
assertIsDirectory(root);
83-
if (isSupported(SUPPORTS_ROOT_DELETE)) {
84-
boolean deleted = getFileSystem().delete(root, true);
85-
LOG.info("rm -r / of empty dir result is {}", deleted);
86-
assertIsDirectory(root);
87-
} else {
88-
// An exception is expected from unsupported file system
83+
if (isSupported(ROOT_DELETE_INCOMPATIBLE_FS)) {
84+
// Root delete incompatible file systems should throw an exception on calling
8985
try {
9086
boolean deleted = getFileSystem().delete(root, true);
91-
fail("unsupported file system should have raised an exception," +
87+
fail("incompatible file system should have raised an exception," +
9288
" but completed with exit code " + deleted);
9389
} catch (IOException e) {
9490
handleExpectedException(e);
9591
}
92+
} else {
93+
boolean deleted = getFileSystem().delete(root, true);
94+
LOG.info("rm -r / of empty dir result is {}", deleted);
95+
assertIsDirectory(root);
9696
}
9797
}
9898

@@ -130,19 +130,19 @@ public Void call() throws Exception {
130130
},
131131
new LambdaTestUtils.ProportionalRetryInterval(50, 1000));
132132
// then try to delete the empty one
133-
if (isSupported(SUPPORTS_ROOT_DELETE)) {
134-
boolean deleted = fs.delete(root, false);
135-
LOG.info("rm / of empty dir result is {}", deleted);
136-
assertIsDirectory(root);
137-
} else {
138-
// An exception is expected from unsupported file system
133+
if (isSupported(ROOT_DELETE_INCOMPATIBLE_FS)) {
134+
// Root delete incompatible file systems should throw an exception on calling
139135
try {
140136
boolean deleted = getFileSystem().delete(root, true);
141-
fail("unsupported file system should have raised an exception," +
137+
fail("incompatible file system should have raised an exception," +
142138
" but completed with exit code " + deleted);
143139
} catch (IOException e) {
144140
handleExpectedException(e);
145141
}
142+
} else {
143+
boolean deleted = fs.delete(root, false);
144+
LOG.info("rm / of empty dir result is {}", deleted);
145+
assertIsDirectory(root);
146146
}
147147
}
148148

@@ -179,7 +179,16 @@ public void testRmRootRecursive() throws Throwable {
179179
Path file = new Path("/testRmRootRecursive");
180180
try {
181181
ContractTestUtils.touch(getFileSystem(), file);
182-
if (isSupported(SUPPORTS_ROOT_DELETE)) {
182+
if (isSupported(ROOT_DELETE_INCOMPATIBLE_FS)) {
183+
// Root delete incompatible file systems should throw an exception on calling
184+
try {
185+
boolean deleted = getFileSystem().delete(root, true);
186+
fail("incompatible file system should have raised an exception," +
187+
" but completed with exit code " + deleted);
188+
} catch (IOException e) {
189+
handleExpectedException(e);
190+
}
191+
} else {
183192
boolean deleted = getFileSystem().delete(root, true);
184193
assertIsDirectory(root);
185194
LOG.info("rm -rf / result is {}", deleted);
@@ -188,15 +197,6 @@ public void testRmRootRecursive() throws Throwable {
188197
} else {
189198
assertPathExists("expected file to be preserved", file);
190199
}
191-
} else {
192-
// An exception is expected from unsupported file system
193-
try {
194-
boolean deleted = getFileSystem().delete(root, true);
195-
fail("unsupported file system should have raised an exception," +
196-
" but completed with exit code " + deleted);
197-
} catch (IOException e) {
198-
handleExpectedException(e);
199-
}
200200
}
201201
} finally{
202202
getFileSystem().delete(file, false);

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/ContractOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ public interface ContractOptions {
235235
String TEST_ROOT_TESTS_ENABLED = "test.root-tests-enabled";
236236

237237
/**
238-
* Does the FS support root directory delete?
238+
* Indicates that FS is incompatible with root delete.
239239
* {@value}
240240
*/
241-
String SUPPORTS_ROOT_DELETE = "supports-root-delete";
241+
String ROOT_DELETE_INCOMPATIBLE_FS = "root-delete-incompatible-fs";
242242

243243
/**
244244
* Limit for #of random seeks to perform.

hadoop-tools/hadoop-aws/src/test/resources/contract/s3a.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
</property>
149149

150150
<property>
151-
<name>fs.contract.supports-root-delete</name>
152-
<value>false</value>
151+
<name>fs.contract.root-delete-incompatible-fs</name>
152+
<value>true</value>
153153
</property>
154154
</configuration>

0 commit comments

Comments
 (0)