You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/02/06 21:56:50 UTC

[GitHub] zentol commented on a change in pull request #7657: [FLINK-11495][runtime] Remove legacy job archiving paths

zentol commented on a change in pull request #7657:  [FLINK-11495][runtime] Remove legacy job archiving paths 
URL: https://github.com/apache/flink/pull/7657#discussion_r254468335
 
 

 ##########
 File path: flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/history/FsJobArchivistTest.java
 ##########
 @@ -30,56 +29,32 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.regex.Pattern;
+
+import static org.hamcrest.core.IsCollectionContaining.hasItem;
 
 /**
  * Tests for the {@link FsJobArchivist}.
  */
 public class FsJobArchivistTest {
 
 	@Rule
-	public TemporaryFolder tmpFolder = new TemporaryFolder();
+	public final TemporaryFolder tmpFolder = new TemporaryFolder();
 
 	@Test
 	public void testArchiveJob() throws Exception {
-		Path tmpPath = new Path(tmpFolder.getRoot().getAbsolutePath());
-
-		AccessExecutionGraph graph = ArchivedJobGenerationUtils.getTestJob();
-
-		Collection<ArchivedJson> expected = new ArrayList<>();
-		for (JsonArchivist archivist : Collections.<JsonArchivist>emptyList()) {
-			for (ArchivedJson archive : archivist.archiveJsonWithPath(graph)) {
-				expected.add(archive);
-			}
-		}
-
-		Path archivePath = FsJobArchivist.archiveJob(tmpPath, graph);
-		Collection<ArchivedJson> actual = FsJobArchivist.getArchivedJsons(archivePath);
+		final Path tmpPath = new Path(tmpFolder.getRoot().getAbsolutePath());
+		final JobID jobId = new JobID();
 
-		Assert.assertEquals(expected.size(), actual.size());
+		final Collection<ArchivedJson> toArchive = new ArrayList<>(2);
+		toArchive.add(new ArchivedJson("dir1", "hello"));
+		toArchive.add(new ArchivedJson("dir1/dir11", "world"));
 
-		Iterator<ArchivedJson> eI = expected.iterator();
-		Iterator<ArchivedJson> aI = actual.iterator();
+		final Path archive = FsJobArchivist.archiveJob(tmpPath, jobId, toArchive);
+		final Collection<ArchivedJson> restored = FsJobArchivist.getArchivedJsons(archive);
 
-		// several jsons contain a dynamic "now" field that depends on the time of creation, so we can't easily compare
-		// the json and only check the path
-		// /jobs/:jobid
-		// /jobs/:jobid/vertices
-		// /jobs/:jobid/vertices/:vertexid
-		// /jobs/:jobid/vertices/:vertexid/subtasktimes
-		// /jobs/:jobid/vertices/:vertexid/taskmanagers
-		Pattern jobDetailsPattern = Pattern.compile("/jobs/[a-fA-F0-9]{32}(/vertices(/[a-fA-F0-9]{32}(/(subtasktimes|taskmanagers))?)?)?");
-		while (eI.hasNext() && aI.hasNext()) {
-			// technically there isn't guarantee that the order is identical, but as it stands this is the case
-			ArchivedJson exp = eI.next();
-			ArchivedJson act = aI.next();
-			if (jobDetailsPattern.matcher(exp.getPath()).matches()) {
-				Assert.assertEquals(exp.getPath(), act.getPath());
-			} else {
-				Assert.assertEquals(exp, act);
-			}
+		Assert.assertEquals(toArchive.size(), restored.size());
+		for (final ArchivedJson json : toArchive) {
 
 Review comment:
   one could probably do that. I kind of do not wanna do this collection to array conversion because it is just.so.stupid; internally it is again converted into a collection -.-

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services