Skip to content

HDDS-15172. Add validation tests and logging cleanup for Ozone Iceberg RewriteTablePath action.#10187

Open
slfan1989 wants to merge 2 commits intoapache:masterfrom
slfan1989:HDDS-15172
Open

HDDS-15172. Add validation tests and logging cleanup for Ozone Iceberg RewriteTablePath action.#10187
slfan1989 wants to merge 2 commits intoapache:masterfrom
slfan1989:HDDS-15172

Conversation

@slfan1989
Copy link
Copy Markdown
Contributor

@slfan1989 slfan1989 commented May 5, 2026

What changes were proposed in this pull request?

This PR improves validation coverage for the Ozone Iceberg RewriteTablePath action and replaces direct console output with SLF4J logging.

The Ozone Iceberg RewriteTablePathOzoneAction already 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 JVM NullPointerException message instead of the existing validation helper's clearer error message.

This PR proposes the following changes:

  • Add unit tests for invalid RewriteTablePathOzoneAction inputs:
    • missing source/target location prefix
    • identical source and target prefixes
    • unknown start metadata version
    • unknown end metadata version
  • Add explicit validation for missing source and target prefixes in execute().
  • Replace a direct System.out.println call in RewriteTablePathOzoneAction with 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?

  • Tested with:
mvn -pl hadoop-ozone/iceberg test
  • Result:
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.hadoop.ozone.iceberg.TestRewriteTablePathOzoneAction
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.152 s -- in org.apache.hadoop.ozone.iceberg.TestRewriteTablePathOzoneAction
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Copy link
Copy Markdown
Contributor

@sreejasahithi sreejasahithi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @slfan1989 for adding the additional tests

Comment on lines +192 to +200
@Test
void executeRejectsMissingLocationPrefix() {
NullPointerException exception = assertThrows(NullPointerException.class,
() -> new RewriteTablePathOzoneAction(table)
.stagingLocation(stagingDir.toString() + "/")
.execute());

assertEquals("Source prefix is null", exception.getMessage());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.
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.

Copy link
Copy Markdown
Contributor

@sreejasahithi sreejasahithi May 5, 2026

Choose a reason for hiding this comment

The 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 execute() clearer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

String stagingPath = RewriteTablePathUtil.stagingPath(versionFilePath, sourcePrefix, stagingDir);

System.out.println("Processing version file " + versionFilePath);
LOG.info("Processing version file {}", versionFilePath);
Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
Contributor Author

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 DEBUG so it does not add noise to the default command output, while still keeping the information available when debug logging is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants