Migrate Snapshot files in Core to JUnit5#9892
Conversation
|
@nastra Update the snapshot files. Could you review this PR? |
| name -> { | ||
| try { | ||
| return temp.newFile(name).getAbsolutePath(); | ||
| return java.nio.file.Files.createTempDirectory(temp, "junit") |
There was a problem hiding this comment.
shouldn't this create a temp file with the given name rather than a temp directory?
There was a problem hiding this comment.
thanks. yes, that should create a temp file. Will fix.
|
|
||
| public class TestSnapshotJson { | ||
| @Rule public TemporaryFolder temp = new TemporaryFolder(); | ||
| @TempDir private static Path temp; |
There was a problem hiding this comment.
| @TempDir private static Path temp; | |
| @TempDir private Path temp; |
|
|
||
| public TableOperations ops = new LocalTableOperations(temp); | ||
| public TableOperations ops = | ||
| new LocalTableOperations(java.nio.file.Files.createTempDirectory(temp, "junit")); |
There was a problem hiding this comment.
why does this create a new temp directory? I think it should just pass temp
| public TableOperations ops = | ||
| new LocalTableOperations(java.nio.file.Files.createTempDirectory(temp, "junit")); | ||
|
|
||
| public TestSnapshotJson() throws IOException {} |
There was a problem hiding this comment.
why is the constructor here?
There was a problem hiding this comment.
It doesn't need. As the above comment, I previously set createTempDirectory for LocalTableOperations, then the createTempDirectory needs the IOException handling. But as your feedback, temp should be set for LocalTableOperations and this IOException is not needed. Remove it in the next commit.
| private String createManifestListWithManifestFiles(long snapshotId, Long parentSnapshotId) | ||
| throws IOException { | ||
| File manifestList = temp.newFile("manifests" + UUID.randomUUID()); | ||
| File manifestList = java.nio.file.Files.createTempDirectory(temp, "junit").toFile(); |
There was a problem hiding this comment.
this should create a new temp file instead of a temp directory
| assertThat(snapshot.snapshotId()).isEqualTo(expected.snapshotId()); | ||
| assertThat(snapshot.allManifests(ops.io())).hasSize(2); | ||
|
|
||
| for (int i = 0; i < snapshot.allManifests(ops.io()).size(); i++) { |
There was a problem hiding this comment.
are these new checks? can you elaborate why those are being added?
There was a problem hiding this comment.
@nastra I tried to check each element in the manifest list, but it's a bit redundant. I believe it's enough to check with isEqualTo between two lists. Let me revert this part and other part like this.
| .build(); | ||
|
|
||
| @Rule public TemporaryFolder temp = new TemporaryFolder(); | ||
| @TempDir protected static Path temp; |
There was a problem hiding this comment.
| @TempDir protected static Path temp; | |
| @TempDir private Path temp; |
| private String createManifestListWithManifestFile( | ||
| long snapshotId, Long parentSnapshotId, String manifestFile) throws IOException { | ||
| File manifestList = temp.newFile("manifests" + UUID.randomUUID()); | ||
| File manifestList = java.nio.file.Files.createTempDirectory(temp, "junit").toFile(); |
There was a problem hiding this comment.
same as above, shouldn't this create a temp file with the given name rather than a temp folder?
There was a problem hiding this comment.
yes it should be a temp file. Will fix this part.
| expectedBranch != null | ||
| && expectedBranch.equals(SnapshotRef.branchBuilder(snapshotId).build())); | ||
| assertThat(expectedBranch).isNotNull(); | ||
| assertThat(expectedBranch).isEqualTo(SnapshotRef.branchBuilder(snapshotId).build()); |
There was a problem hiding this comment.
| assertThat(expectedBranch).isEqualTo(SnapshotRef.branchBuilder(snapshotId).build()); | |
| assertThat(expectedBranch).isNotNull().isEqualTo(SnapshotRef.branchBuilder(snapshotId).build()); |
| Assert.assertTrue( | ||
| expectedBranch != null | ||
| && expectedBranch.equals(SnapshotRef.branchBuilder(snapshotId).build())); | ||
| assertThat(expectedBranch).isNotNull(); |
There was a problem hiding this comment.
| assertThat(expectedBranch).isNotNull(); |
| Assertions.assertThat(actualBranch).isNotNull(); | ||
| Assertions.assertThat(actualBranch).isEqualTo(SnapshotRef.branchBuilder(snapshotId).build()); | ||
| assertThat(actualBranch).isNotNull(); | ||
| assertThat(actualBranch).isEqualTo(SnapshotRef.branchBuilder(snapshotId).build()); |
| Assert.assertTrue( | ||
| expectedTag != null && expectedTag.equals(SnapshotRef.tagBuilder(snapshotId).build())); | ||
| assertThat(expectedTag).isNotNull(); | ||
| assertThat(expectedTag).isEqualTo(SnapshotRef.tagBuilder(snapshotId).build()); |
| "Table should be on version 2 after creating manageSnapshots", 2, (int) version()); | ||
| assertThat(readMetadata()) | ||
| .as("Base metadata should not change when manageSnapshots is created") | ||
| .isEqualTo(base); |
There was a problem hiding this comment.
this should be isSameAs() as this check actually verifies that both objects are referentially equal. Same for the other places that previously used assertSame()
There was a problem hiding this comment.
Okay sure. Thanks for the advice.
cc0a63e to
eaaf0f8
Compare
|
@nastra Thanks for the review. Reflected your comments. Could you review the new one? |
| private String createManifestListWithManifestFiles(long snapshotId, Long parentSnapshotId) | ||
| throws IOException { | ||
| File manifestList = temp.newFile("manifests" + UUID.randomUUID()); | ||
| File manifestList = File.createTempFile("junit", null, temp.toFile()); |
There was a problem hiding this comment.
| File manifestList = File.createTempFile("junit", null, temp.toFile()); | |
| File manifestList = File.createTempFile("manifests", null, temp.toFile()); |
| private String createManifestListWithManifestFile( | ||
| long snapshotId, Long parentSnapshotId, String manifestFile) throws IOException { | ||
| File manifestList = temp.newFile("manifests" + UUID.randomUUID()); | ||
| File manifestList = File.createTempFile("junit", null, temp.toFile()); |
There was a problem hiding this comment.
| File manifestList = File.createTempFile("junit", null, temp.toFile()); | |
| File manifestList = File.createTempFile("manifests", null, temp.toFile()); |
| "Table should be on version 2 after creating transaction", 2, (int) version()); | ||
| assertThat(readMetadata()) | ||
| .as("Base metadata should not change when transaction is created") | ||
| .isEqualTo(base); |
| txn.commitTransaction(); | ||
|
|
||
| Assert.assertEquals(snapshotAfterFirstAppend, readMetadata().currentSnapshot()); | ||
| assertThat(readMetadata().currentSnapshot()).isSameAs(snapshotAfterFirstAppend); |
There was a problem hiding this comment.
| assertThat(readMetadata().currentSnapshot()).isSameAs(snapshotAfterFirstAppend); | |
| assertThat(readMetadata().currentSnapshot()).isEqualTo(snapshotAfterFirstAppend); |
| Assert.assertEquals(snapshotAfterFirstAppend, readMetadata().currentSnapshot()); | ||
| Assert.assertEquals( | ||
| "Table should be on version 3 after invoking rollbackTo", 3, (int) version()); | ||
| assertThat(readMetadata().currentSnapshot()).isSameAs(snapshotAfterFirstAppend); |
There was a problem hiding this comment.
| assertThat(readMetadata().currentSnapshot()).isSameAs(snapshotAfterFirstAppend); | |
| assertThat(readMetadata().currentSnapshot()).isEqualTo(snapshotAfterFirstAppend); |
|
Thanks for the review @nastra |
Migrate the following "Read" in iceberg-core to JUnit 5 for #9085.
Current Progress
Snapshots:
The following classes are for Iceberg procedures: