-
Notifications
You must be signed in to change notification settings - Fork 621
HDDS-15172. Cleanup logging in Iceberg RewriteTablePath action and add validation tests #10187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f2c5111
bb6d12e
cb99c0d
a30d297
e49b758
8f8b287
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,6 +222,89 @@ void tablePathRewriteForStartAndEndVersionProvided() throws Exception { | |
| } | ||
|
|
||
| @Test | ||
| void executeRejectsMissingLocationPrefix() { | ||
| NullPointerException exception = assertThrows(NullPointerException.class, | ||
| () -> new RewriteTablePathOzoneAction(table) | ||
| .stagingLocation(stagingDir.toString() + "/") | ||
| .execute()); | ||
|
|
||
| assertEquals("Source prefix is null", exception.getMessage()); | ||
| } | ||
|
Comment on lines
+224
to
+232
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not need to be checked because when we add the CLI HDDS-14946 the source and target prefix would be required fields so they can not be missing.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updating my earlier comment: while the CLI will enforce that source and target prefixes are set, I think it would be fine to keep this null check and the test as a defensive safeguard. It protects against misuse outside the CLI path and makes the contract of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sreejasahithi That makes sense. I kept this as a defensive check for possible non-CLI callers, and to make the execute() contract a bit clearer.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add case to cover the target prefix null case too.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a test case to cover the null target prefix case. |
||
|
|
||
| @Test | ||
| void executeRejectsMissingTargetPrefix() { | ||
| NullPointerException exception = assertThrows(NullPointerException.class, | ||
| () -> new RewriteTablePathOzoneAction(table) | ||
| .rewriteLocationPrefix(sourcePrefix, null)); | ||
|
|
||
| assertEquals("Target prefix is null", exception.getMessage()); | ||
| } | ||
|
|
||
| @Test | ||
| void rewriteLocationPrefixRejectsSameSourceAndTarget() { | ||
| IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, | ||
| () -> new RewriteTablePathOzoneAction(table) | ||
| .rewriteLocationPrefix(sourcePrefix, sourcePrefix) | ||
| .execute()); | ||
|
|
||
| assertEquals("Source prefix cannot be the same as target prefix (" + | ||
| sourcePrefix + ")", exception.getMessage()); | ||
| } | ||
|
|
||
| @Test | ||
| void startVersionRejectsUnknownVersion() { | ||
| IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, | ||
| () -> new RewriteTablePathOzoneAction(table) | ||
| .rewriteLocationPrefix(sourcePrefix, targetPrefix) | ||
| .startVersion("missing.metadata.json") | ||
| .execute()); | ||
|
|
||
| assertEquals("Cannot find provided version file missing.metadata.json " + | ||
| "in metadata log.", exception.getMessage()); | ||
| } | ||
|
|
||
| @Test | ||
| void startVersionRejectsDeletedVersionFile() { | ||
| List<String> metadataPaths = metadataLogEntryPaths(table); | ||
|
Comment on lines
+267
to
+268
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry my previous comment was not clear enough, could you please also do for end version.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sreejasahithi Added the corresponding end version test case where the version exists in the metadata log but the physical metadata file is missing. |
||
| String existingName = RewriteTablePathUtil.fileName(metadataPaths.get(0)); | ||
| table.io().deleteFile(metadataPaths.get(0)); | ||
|
|
||
| IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, | ||
| () -> new RewriteTablePathOzoneAction(table) | ||
| .rewriteLocationPrefix(sourcePrefix, targetPrefix) | ||
| .startVersion(existingName) | ||
| .execute()); | ||
|
|
||
| assertThat(exception).hasMessageContaining("does not exist"); | ||
| } | ||
|
|
||
| @Test | ||
| void endVersionRejectsUnknownVersion() { | ||
| IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, | ||
| () -> new RewriteTablePathOzoneAction(table) | ||
| .rewriteLocationPrefix(sourcePrefix, targetPrefix) | ||
| .endVersion("missing.metadata.json") | ||
| .execute()); | ||
|
|
||
| assertEquals("Cannot find provided version file missing.metadata.json " + | ||
| "in metadata log.", exception.getMessage()); | ||
| } | ||
|
|
||
| @Test | ||
| void endVersionRejectsDeletedVersionFile() { | ||
| List<String> metadataPaths = metadataLogEntryPaths(table); | ||
| String existingName = RewriteTablePathUtil.fileName(metadataPaths.get(0)); | ||
| table.io().deleteFile(metadataPaths.get(0)); | ||
|
|
||
| IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, | ||
| () -> new RewriteTablePathOzoneAction(table) | ||
| .rewriteLocationPrefix(sourcePrefix, targetPrefix) | ||
| .endVersion(existingName) | ||
| .execute()); | ||
|
|
||
| assertThat(exception).hasMessageContaining("does not exist"); | ||
| } | ||
|
|
||
| void defaultStagingDirIsUnderTableMetadataLocation() { | ||
| String metadataLocation = RewriteTablePathOzoneUtils.getMetadataLocation(table); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also add a case like follows where the version file is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use
assertThat(exception).hasMessageContaininginstead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sreejasahithi @adoroszlai Added a test case for the scenario where the requested start version exists in the metadata log but the physical metadata file has been deleted. The test verifies that the action fails with an IllegalArgumentException indicating that the version file does not exist.