HDDS-15172. Cleanup logging in Iceberg RewriteTablePath action and add validation tests#10187
Conversation
sreejasahithi
left a comment
There was a problem hiding this comment.
Thanks @slfan1989 for adding the additional tests
| @Test | ||
| void executeRejectsMissingLocationPrefix() { | ||
| NullPointerException exception = assertThrows(NullPointerException.class, | ||
| () -> new RewriteTablePathOzoneAction(table) | ||
| .stagingLocation(stagingDir.toString() + "/") | ||
| .execute()); | ||
|
|
||
| assertEquals("Source prefix is null", exception.getMessage()); | ||
| } |
There was a problem hiding this comment.
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.
And once the CLI is added , the source and target prefix will be set before calling the action.
rewriteLocationPrefix is always called by the CLI before execute(), then sourcePrefix will never be null in practice, and the test adds no real value to it.
There was a problem hiding this comment.
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 execute() clearer.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
Can you add case to cover the target prefix null case too.
There was a problem hiding this comment.
Added a test case to cover the null target prefix case.
| String stagingPath = RewriteTablePathUtil.stagingPath(versionFilePath, sourcePrefix, stagingDir); | ||
|
|
||
| System.out.println("Processing version file " + versionFilePath); | ||
| LOG.info("Processing version file {}", versionFilePath); |
There was a problem hiding this comment.
LOG.info will cause noise in the command output with the additional information as follows
2026-05-05 12:00:01,000 [main] INFO RewriteTablePathOzoneAction: Processing version file v4.metadata.json
2026-05-05 12:00:01,050 [main] INFO RewriteTablePathOzoneAction: Processing version file v3.metadata.json
There was a problem hiding this comment.
Thanks for pointing this out. I will change this to DEBUG so it does not add noise to the default command output, while still keeping the information available when debug logging is enabled.
|
@adoroszlai @ashishkumar50 Could you please help review this PR? Thank you very much! |
|
@sreejasahithi Do you have any other suggestions? |
sreejasahithi
left a comment
There was a problem hiding this comment.
Thanks @slfan1989 for updating the patch
There was a problem hiding this comment.
You could also add a case like follows where the version file is missing.
void startVersionRejectsDeletedVersionFile() {
List<String> metadataPaths = metadataLogEntryPaths(table);
String existingName = RewriteTablePathUtil.fileName(metadataPaths.get(0));
// delete the physical file so it's in the log but missing on disk
table.io().deleteFile(metadataPaths.get(0));
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> new RewriteTablePathOzoneAction(table)
.rewriteLocationPrefix(sourcePrefix, targetPrefix)
.startVersion(existingName)
.execute());
assertTrue(exception.getMessage().contains("does not exist"));
}
There was a problem hiding this comment.
assertTrue(exception.getMessage().contains
Please use assertThat(exception).hasMessageContaining instead.
There was a problem hiding this comment.
@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.
| void startVersionRejectsDeletedVersionFile() { | ||
| List<String> metadataPaths = metadataLogEntryPaths(table); |
There was a problem hiding this comment.
Sorry my previous comment was not clear enough, could you please also do for end version.
There was a problem hiding this comment.
@sreejasahithi Added the corresponding end version test case where the version exists in the metadata log but the physical metadata file is missing.
…g RewriteTablePath action.
…g RewriteTablePath action.
…g RewriteTablePath action.
…g RewriteTablePath action.
sreejasahithi
left a comment
There was a problem hiding this comment.
Thanks @slfan1989
LGTM
@sreejasahithi Thanks for the review! @adoroszlai @ashishkumar50 Could you please take another look when you get a chance? Thank you! |
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @slfan1989 for updating the patch, LGTM
|
Thanks @slfan1989 for the patch, @ashishkumar50, @sreejasahithi for the review. |
@adoroszlai Thanks a lot for your review and for merging this PR! @ashishkumar50 @sreejasahithi Thanks a lot for your review! |
What changes were proposed in this pull request?
This PR improves validation coverage for the Ozone Iceberg
RewriteTablePathaction and replaces direct console output with SLF4J logging.The Ozone Iceberg
RewriteTablePathOzoneActionalready validates several user-provided inputs, such as source/target prefixes and metadata version names. However, some validation paths were not covered by unit tests. In particular, executing the action without configuring the source and target prefixes previously resulted in a raw JVMNullPointerExceptionmessage instead of the existing validation helper's clearer error message.This PR proposes the following changes:
RewriteTablePathOzoneActioninputs:execute().System.out.printlncall inRewriteTablePathOzoneActionwith SLF4J logging.These changes make the Iceberg rewrite path action easier to validate and keep logging consistent with the rest of the Ozone codebase.
What is the link to the Apache JIRA
HDDS-15172. Add validation tests and logging cleanup for Ozone Iceberg RewriteTablePath action.
How was this patch tested?