-
Notifications
You must be signed in to change notification settings - Fork 599
HDDS-15172. Add validation tests and logging cleanup for Ozone Iceberg RewriteTablePath action. #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
base: master
Are you sure you want to change the base?
HDDS-15172. Add validation tests and logging cleanup for Ozone Iceberg RewriteTablePath action. #10187
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.hadoop.ozone.iceberg; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import java.io.BufferedReader; | ||
|
|
@@ -188,6 +189,51 @@ void tablePathRewriteForStartAndEndVersionProvided() throws Exception { | |
| assertAllInternalPathsRewritten(csvPairs, targetPrefix); | ||
| } | ||
|
|
||
| @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
+192
to
+200
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. |
||
|
|
||
| @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 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()); | ||
| } | ||
|
|
||
| /** | ||
| * For every staged metadata JSON file in the CSV, parses the file and asserts that: | ||
| * - The table location starts with target | ||
|
|
||
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.
LOG.info will cause noise in the command output with the additional information as follows
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.
Thanks for pointing this out. I will change this to
DEBUGso it does not add noise to the default command output, while still keeping the information available when debug logging is enabled.