Skip to content

HDDS-15623. Disk check may not completely read test file#10552

Open
adoroszlai wants to merge 3 commits into
apache:masterfrom
adoroszlai:HDDS-15623
Open

HDDS-15623. Disk check may not completely read test file#10552
adoroszlai wants to merge 3 commits into
apache:masterfrom
adoroszlai:HDDS-15623

Conversation

@adoroszlai

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  1. Disk read/write check may not completely read the test file with InputStream.read().
    // Read data back from the test file.
    byte[] readBytes = new byte[numBytesToWrite];
    try (InputStream fis = Files.newInputStream(testFile.toPath())) {
    int numBytesRead = fis.read(readBytes);
    if (numBytesRead != numBytesToWrite) {
    logError(storageDir, String.format("%d bytes written to file %s " +
    "but %d bytes were read back.", numBytesToWrite,
    testFile.getAbsolutePath(), numBytesRead));
    return false;

    Use IOUtils.read to fully read the input.
  2. Delete the test file even if the check fails for any reason.
  3. Convert File.toPath once.

https://issues.apache.org/jira/browse/HDDS-15623

How was this patch tested?

Updated unit test.

CI:
https://github.com/adoroszlai/ozone/actions/runs/27831059411

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.

1 participant