pvary commented on a change in pull request #1465:
URL: https://github.com/apache/iceberg/pull/1465#discussion_r490129106
##########
File path: core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCatalog.java
##########
@@ -494,23 +495,42 @@ public void testVersionHintFile() throws Exception {
stream.write("3".getBytes(StandardCharsets.UTF_8));
}
- // Check the result of the readVersionHint(), and load the table and check
the current snapshotId
- Assert.assertEquals(3, tableOperations.readVersionHint());
+ // Check the result of the versionHint(), and load the table and check the
current snapshotId
+ Assert.assertEquals(3, tableOperations.versionHint());
Assert.assertEquals(secondSnapshotId,
catalog.loadTable(tableId).currentSnapshot().snapshotId());
// Write an empty version hint file
io.deleteFile(versionHintLocation);
io.newOutputFile(versionHintLocation).create().close();
- // Check the result of the readVersionHint(), and load the table and check
the current snapshotId
- Assert.assertEquals(1, tableOperations.readVersionHint());
+ // Check the result of the versionHint(), and load the table and check the
current snapshotId
+ Assert.assertEquals(3, tableOperations.versionHint());
Assert.assertEquals(secondSnapshotId,
catalog.loadTable(tableId).currentSnapshot().snapshotId());
// Just delete the file - double check that we have manipulated the
correct file
io.deleteFile(versionHintLocation);
- // Check the result of the readVersionHint(), and load the table and check
the current snapshotId
- Assert.assertEquals(1, tableOperations.readVersionHint());
+ // Check the result of the versionHint(), and load the table and check the
current snapshotId
+ Assert.assertEquals(3, tableOperations.versionHint());
Assert.assertEquals(secondSnapshotId,
catalog.loadTable(tableId).currentSnapshot().snapshotId());
+
+ // Remove the first version file, and see if we can recover
+ io.deleteFile(tableOperations.getMetadataFile(1).toString());
+
+ // Check the result of the versionHint(), and load the table and check the
current snapshotId
+ Assert.assertEquals(3, tableOperations.versionHint());
+ Assert.assertEquals(secondSnapshotId,
catalog.loadTable(tableId).currentSnapshot().snapshotId());
+
+ // Remove all the version files, and see if we can recover. Hint... not :)
+ io.deleteFile(tableOperations.getMetadataFile(2).toString());
+ io.deleteFile(tableOperations.getMetadataFile(3).toString());
+
+ // Check that we got 0 versionHint, and a NoSuchTableException is thrown
when trying to load the table
+ Assert.assertEquals(0, tableOperations.versionHint());
+ AssertHelpers.assertThrows(
+ "Should not be able to find the table",
+ NoSuchTableException.class,
+ "Table does not exist: tbl",
+ () -> catalog.loadTable(tableId));
Review comment:
Done.
Create a new method for this.
Might refactor a little bit later to have a nicer code, but first I would
like to be sure that the failing tests are solved
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]