ferenc-csaky commented on code in PR #23211:
URL: https://github.com/apache/flink/pull/23211#discussion_r1306606274
##########
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:
No, you are correct, thanks for the suggestion, fixed!
--
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]