ferenc-csaky commented on code in PR #23211:
URL: https://github.com/apache/flink/pull/23211#discussion_r1303094188


##########
flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCachePutTest.java:
##########
@@ -582,57 +545,47 @@ public void testPutBufferFailsForJobHa() throws 
IOException {
      */
     private void testPutBufferFails(@Nullable final JobID jobId, 
BlobKey.BlobType blobType)
             throws IOException {
-        assumeTrue(!OperatingSystem.isWindows()); // setWritable doesn't work 
on Windows.
+        // setWritable doesn't work on Windows.
+        assumeThat(OperatingSystem.isWindows()).as("setWritable doesn't work 
on Windows").isFalse();
 
-        final Configuration config = new Configuration();
-        File tempFileDir = null;
-        try (BlobServer server =
-                        new BlobServer(config, temporaryFolder.newFolder(), 
new VoidBlobStore());
-                BlobCacheService cache =
-                        new BlobCacheService(
-                                config,
-                                temporaryFolder.newFolder(),
-                                new VoidBlobStore(),
-                                new InetSocketAddress("localhost", 
server.getPort()))) {
+        Tuple2<BlobServer, BlobCacheService> serverAndCache =
+                TestingBlobUtils.createServerAndCache(tempDir);
 
+        try (BlobServer server = serverAndCache.f0;
+                BlobCacheService cache = serverAndCache.f1) {
             server.start();
 
             // make sure the blob server cannot create any files in its 
storage dir
-            tempFileDir = 
server.createTemporaryFilename().getParentFile().getParentFile();
-            assertTrue(tempFileDir.setExecutable(true, false));
-            assertTrue(tempFileDir.setReadable(true, false));
-            assertTrue(tempFileDir.setWritable(false, false));
+            File tempFileDir = 
server.createTemporaryFilename().getParentFile().getParentFile();
+            assertThat(tempFileDir.setExecutable(true, false)).isTrue();
+            assertThat(tempFileDir.setReadable(true, false)).isTrue();
+            assertThat(tempFileDir.setWritable(false, false)).isTrue();
 
             byte[] data = new byte[2000000];
             rnd.nextBytes(data);
 
-            // upload the file to the server via the cache
-            exception.expect(IOException.class);
-            exception.expectMessage("PUT operation failed: ");
-
-            put(cache, jobId, data, blobType);
-
-        } finally {
-            // set writable again to make sure we can remove the directory
-            if (tempFileDir != null) {
-                //noinspection ResultOfMethodCallIgnored
-                tempFileDir.setWritable(true, false);
+            try {
+                assertThatThrownBy(() -> put(cache, jobId, data, blobType))
+                        .isInstanceOf(IOException.class)
+                        .hasMessageStartingWith("PUT operation failed: ");
+            } finally {
+                assertThat(tempFileDir.setWritable(true, false)).isTrue();
             }
         }

Review Comment:
   This is a difference between JUnit4 and JUnit5. The blob server storage 
folder (where `tempFileDir` points) has no write permissions at the time of 
`close()` is called on master as well, but JUnit4 ignores that and removes the 
folder anyways. JUnit5 does not. 
   
   JUnit4 list dir for the server storage dir at the point of delete:
   ```
   /var/folders/wp/ccy48gw1255bswh9bx9svxjc0000gn/T/junit5602027938676775669
   % ll
   total 0
   dr-xr-xr-x  3 fcsaky  staff    96B Aug 23 15:58 junit4915192828668545622
   ```
   
   JUnit5 list dir for the server storage dir at the point of delete:
   ```
   /var/folders/wp/ccy48gw1255bswh9bx9svxjc0000gn/T/junit2862686155928225667
   % ll
   total 0
   dr-xr-xr-x  3 fcsaky  staff    96B Aug 23 16:08 server
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to