Skip to content

Make generated test archive deterministic - #3420

Open
cragkhit wants to merge 1 commit into
yahoo:masterfrom
cragkhit:matcha-deterministic-tar-output
Open

Make generated test archive deterministic#3420
cragkhit wants to merge 1 commit into
yahoo:masterfrom
cragkhit:matcha-deterministic-tar-output

Conversation

@cragkhit

Copy link
Copy Markdown

Hi. We are researchers from Mahidol University, Thailand, and the State University of Ceará, Brazil, working on a research project for improving open-source projects by using the latest accepted answer from Stack Overflow that matched your code snippet. We found this recommendation for improving your code from https://stackoverflow.com/a/34174309.

Note: Our study is approved by the Institutional Review Board of Mahidol University. You can find the participant information sheet explaining this study https://drive.google.com/file/d/1ml5AqrtWQ9pnifTQyTFTcWQmwp6RuPA7/view?usp=sharing.


Proposed change

Made the generated test archive deterministic by sorting files and normalizing file-entry modification times.

Testing

mvn -pl elide-model-config -Dtest=DynamicConfigVerifierTest test

Result: Could not start from the sparse checkout because the parent Maven build requires all sibling modules to be present.

Copilot AI left a comment

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.

Pull request overview

This PR aims to make the tar.gz archive generated by DynamicConfigVerifierTest deterministic so the resulting readTarContents and RSA signature verification are stable across runs.

Changes:

  • Sorts files before adding them to the tar archive.
  • Normalizes tar-entry modification times to a constant value.
Suppressed comments (1)

elide-model-config/src/test/java/com/yahoo/elide/modelconfig/verify/DynamicConfigVerifierTest.java:145

  • createTarGZ can throw a NullPointerException (and mask the root cause) because tarOutputStream is closed in finally even if it was never created (e.g., when configs/ is missing or listFiles() returns null). Using try-with-resources and validating listFiles() avoids this and makes failures clearer.
        } finally {
            tarOutputStream.finish();
            tarOutputStream.close();
        }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +155 to 157
tOut.putArchiveEntry(tarEntry);
IOUtils.copy(new FileInputStream(f), tOut);
tOut.closeArchiveEntry();
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