rangareddy opened a new pull request, #19618:
URL: https://github.com/apache/hudi/pull/19618
### Describe the issue this Pull Request addresses
Closes #17413 (HUDI-9465) — make the HFile writer test operate on a
byte-array stream instead of a file.
`TestHFileWriter` wrote every fixture to `test.hfile`, a fixed relative path
in the module working directory,
and read it back with `FileChannel.map`. The file was never needed:
`HFileWriterImpl` already takes any
`OutputStream`, and `HFileReaderImpl` already reads a
`ByteArraySeekableDataInputStream`.
### Summary and Changelog
Test-only; no production code changes.
- Writes go to a `ByteArrayOutputStream`; reads go through a new
`openReader(byte[])`, matching the idiom
already used by `TestHFileMultiBlockScan`, `TestHFileCompatibility` and
`TestHFileReadCompatibility`.
- Removes the fixed relative path shared by four test methods, and the
`@AfterEach` that existed only to
delete it.
- Removes a hidden coupling: `assertSingleBlockBytesMatchGoldenAndHBase`
re-read the file that
`assertSingleBlockBytesMatchHBase` had left behind. The latter now returns
the bytes.
- Fixes three leaked readers — the old code closed the `FileChannel` but not
the `HFileReaderImpl` opened
inside it. Every reader is now in try-with-resources.
- Renames, since no path is involved any more: `writeNativeFile` →
`writeNativeHFile` (returns bytes),
`writeTestFile` → `writeThreeRecordHFile`; the `validate*` helpers take
the bytes instead of reading a file
behind the caller's back.
The HBase writer fixture keeps its temp file — that writer needs a Hadoop
`Path`, and it already uses
`Files.createTempFile` rather than a fixed name.
### Verification
`mvn test checkstyle:check apache-rat:check -pl hudi-io`:
```
Tests run: 125, Failures: 0, Errors: 0, Skipped: 0
You have 0 Checkstyle violations.
Rat check: Unapproved: 0, unknown: 0, generated: 0, approved: 90 licenses.
```
`TestHFileWriter` itself: 6/6. All byte-parity assertions against the HBase
writer, the pinned golden hex
blocks and the 4547-byte size check are unchanged and still pass, so the
refactor preserves what the test
actually checks.
Grepped for other references to `test.hfile`: none — the constant was local
to this class.
### Impact
Test hygiene only. The tests no longer depend on the working directory or on
a shared mutable path, and they
close the readers they open.
### Risk Level
none
### Documentation Update
none
### Contributor's checklist
- [x] Read through [contributor's
guide](https://hudi.apache.org/contribute/how-to-contribute)
- [x] Enough context is provided in the sections above
- [x] Adequate tests were added if applicable — this is a test change; the
existing assertions are preserved
- [x] CI passes on my PR
--
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]