lokeshj1703 opened a new pull request, #19349:
URL: https://github.com/apache/hudi/pull/19349
## What is the purpose of this PR?
Add two tests that verify the `catch (SparkException)` behaviour introduced
in #18371
(`ExceptionUtil.validateErrorMsg` guard in `doMetadataTableValidation`):
1.
**`testDoMetadataTableValidationThrowsHoodieExceptionOnSparkContextShutdown`**
— a `SparkException` containing `"cancelled because SparkContext was shut
down"` must be wrapped in `HoodieException`, not `HoodieValidationException`.
2.
**`testDoMetadataTableValidationThrowsHoodieValidationExceptionOnUnexpectedSparkFailure`**
— any other `SparkException` must still produce
`HoodieValidationException("Unexpected spark failure")`, covering the
false-branch of the `ExceptionUtil.validateErrorMsg` condition for Sonar branch
coverage.
## Key implementation details
* **Static nested classes instead of anonymous classes**: an anonymous
subclass of `HoodieMetadataTableValidator` would implicitly capture
`TestHoodieMetadataTableValidator.this`, which is not `Serializable`. That
causes Spark's `parallelize().map()` to throw `"Task not serializable"`, which
the outer `catch` converts to `HoodieValidationException` rather than the
intended `HoodieException`.
* **`validateLatestFileSlices` / `validateAllFileGroups` left `false`**:
enabling them invokes `validateFilesInPartition` inside the Spark map job,
which can throw `HoodieValidationException` before `validateRecordIndex` is
ever reached, masking the exception the test intends to assert.
## Does this PR introduce any user-facing changes?
No — test-only change.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]