You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2020/05/16 15:25:11 UTC

[flink] 07/14: [hotfix][tests] Add some clarifying comment in MetadataV3SerializerTest

This is an automated email from the ASF dual-hosted git repository.

sewen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 4ee41bebc504880c7224ec29ffdd4cf28f5fc218
Author: Stephan Ewen <se...@apache.org>
AuthorDate: Sat May 16 01:57:46 2020 +0200

    [hotfix][tests] Add some clarifying comment in MetadataV3SerializerTest
---
 .../metadata/MetadataV3SerializerTest.java         | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV3SerializerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV3SerializerTest.java
index e5e9dbd..4a78321 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV3SerializerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV3SerializerTest.java
@@ -49,7 +49,7 @@ import static org.junit.Assert.assertEquals;
 public class MetadataV3SerializerTest {
 
 	@Rule
-	public TemporaryFolder temporaryFolder = new TemporaryFolder();
+	public final TemporaryFolder temporaryFolder = new TemporaryFolder();
 
 	@Test
 	public void testCheckpointWithNoState() throws Exception {
@@ -163,13 +163,20 @@ public class MetadataV3SerializerTest {
 
 		CheckpointMetadata metadata = new CheckpointMetadata(checkpointId, operatorStates, masterStates);
 		MetadataV3Serializer.serialize(metadata, out);
-		Path metaPath = null;
-		// add this because we need to resolve the checkpoint pointer in MetadataV2V3SerializerBase.
+		out.close();
+
+		// The relative pointer resolution in MetadataV2V3SerializerBase currently runs the same
+		// code as the file system checkpoint location resolution. Because of that, it needs the
+		// a "_metadata" file present. we could change the code to resolve the pointer without doing
+		// file I/O, but it is somewhat delicate to reproduce that logic without I/O and the same guarantees
+		// to differentiate between the supported options of directory addressing and metadata file addressing.
+		// So, better safe than sorry, we do actually do the file system operations in the serializer for now,
+		// even if it makes the tests a a tad bit more clumsy
 		if (basePath != null) {
-			metaPath = new Path(basePath, "_metadata");
-			metaPath.getFileSystem().create(metaPath, FileSystem.WriteMode.OVERWRITE);
+			final Path metaPath = new Path(basePath, "_metadata");
+			// this is in the temp folder, so it will get automatically deleted
+			FileSystem.getLocalFileSystem().create(metaPath, FileSystem.WriteMode.OVERWRITE).close();
 		}
-		out.close();
 
 		byte[] bytes = baos.toByteArray();
 
@@ -183,8 +190,5 @@ public class MetadataV3SerializerTest {
 				a.hasNext();) {
 			CheckpointTestUtils.assertMasterStateEquality(a.next(), b.next());
 		}
-		if (metaPath != null) {
-			metaPath.getFileSystem().delete(metaPath, true);
-		}
 	}
 }