Skip to content

Adding Test coverage to NoOpPinotCrypt class#5726

Closed
rush00121 wants to merge 5 commits intoapache:masterfrom
rush00121:NoOpPinotCryptTest
Closed

Adding Test coverage to NoOpPinotCrypt class#5726
rush00121 wants to merge 5 commits intoapache:masterfrom
rush00121:NoOpPinotCryptTest

Conversation

@rush00121
Copy link
Copy Markdown

Description

This class did not have any code coverage. Adding a simple test to improve test coverage.
Adding test as part of this issue: #5699

Upgrade Notes

Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)

  • No
    Does this PR fix a zero-downtime upgrade introduced earlier?
  • No
    Does this PR otherwise need attention when creating release notes? No

Assert.assertTrue(FileUtils.contentEquals(encryptedFile, decryptedFile));
decryptedFile = new File("fake");
pinotCrypter.encrypt(decryptedFile, encryptedFile);
Assert.assertFalse(encryptedFile.exists());
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.

Seems like this test only asserts that an output file is generated. IMHO, a better test would be one that ensures that we get the same original content back after encryption -> decryption. This might mean that we just have one test method as opposed to two tests.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, makes sense. I have combined the 2 to a single test. Where we are comparing the srcFile to the final decryptedFile.
Also have separated the invalid scenarios to their respective tests


public class NoOpPinotCryptTest {

PinotCrypter pinotCrypter;
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.

As per Pinot Coding Style, member variables should be prefixed with _.

public void testInvalidEncryption() throws IOException {
srcFile = new File("fake");
pinotCrypter.encrypt(srcFile, decryptedFile);
Assert.assertFalse(decryptedFile.exists());
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.

Isn't decryptedFile already created in init()? Which also brings up the point that the files created in init() would only end up being used in one of the tests, so what's the purpose of creating them in init()?

@xiangfu0
Copy link
Copy Markdown
Contributor

not valid

@xiangfu0 xiangfu0 closed this Mar 23, 2026
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.

5 participants