@@ -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 );
0 commit comments