Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-3863: [Java] Delete temporary test data after tests finish #2506

Merged
merged 3 commits into from
Sep 25, 2023

Conversation

sarutak
Copy link
Member

@sarutak sarutak commented Sep 20, 2023

AVRO-3863

What is the purpose of the change

This PR proposes to delete temporary test data generated by tests for Java SDK.
Tests for Java SDK creates some test data, which are left even after tests finish.

ls -1 /tmp/*.avro
/tmp/junit1533190586260098046testMappedByteBuffer.avro
/tmp/junit3099644739767498712testMappedByteBuffer.avro
/tmp/junit4466003251314064556testMappedByteBuffer.avro
/tmp/junit4974226498248565286testMappedByteBuffer.avro
/tmp/junit6473921034404349045testMappedByteBuffer.avro
/tmp/junit8662732084083941415testMappedByteBuffer.avro
/tmp/random.avro
/tmp/testIgnoreSchemaValidationOnRead275054571669736256.avro
/tmp/testIgnoreSchemaValidationOnRead4615547521362396523.avro
/tmp/testIgnoreSchemaValidationOnRead4955268403025511495.avro
/tmp/testIgnoreSchemaValidationOnRead5426593551205571746.avro
/tmp/testIgnoreSchemaValidationOnRead7554021276748093417.avro
/tmp/testIgnoreSchemaValidationOnRead8241302423385070851.avro
/tmp/testInputStreamEOF3549506421974960237.avro
/tmp/testInputStreamEOF4423343183305481378.avro
/tmp/testInputStreamEOF7397178073669402143.avro
/tmp/testInputStreamEOF8065492409408481522.avro
/tmp/testInputStreamEOF8087280538995909098.avro
/tmp/testInputStreamEOF8719004614093216771.avro
/tmp/testInvalidMagicBytes1940432228654910095.avro
/tmp/testInvalidMagicBytes2703760186774533143.avro
/tmp/testInvalidMagicBytes5088097518917799234.avro
/tmp/testInvalidMagicBytes863787801374013591.avro
/tmp/testInvalidMagicBytes887543761182735490.avro
/tmp/testInvalidMagicBytes980334707534164945.avro
/tmp/testInvalidMagicLength1346115615984572207.avro
/tmp/testInvalidMagicLength1511998921770126285.avro
/tmp/testInvalidMagicLength1824057536245960603.avro
/tmp/testInvalidMagicLength2005669502062311523.avro
/tmp/testInvalidMagicLength7068591900276715585.avro
/tmp/testInvalidMagicLength8356756206873381473.avro
/tmp/testThrottledInputStream2962195154373996754.avro
/tmp/testThrottledInputStream3610702487927451328.avro
/tmp/testThrottledInputStream4661398720877824185.avro
/tmp/testThrottledInputStream5592809458916764863.avro
/tmp/testThrottledInputStream6489638888793454476.avro
/tmp/testThrottledInputStream8013323018361761899.avro

Verifying this change

The tests still pass even after this change.
Also, test data are deleted.

ls /tmp/*.avro
ls: cannot access '/tmp/*.avro': No such file or directory

Documentation

  • Does this pull request introduce a new feature? (no)

@github-actions github-actions bot added the Java Pull Requests for Java binding label Sep 20, 2023
Copy link
Contributor

@RyanSkraba RyanSkraba left a comment

Choose a reason for hiding this comment

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

Hey thanks for your contribution -- this is a really good catch!

It looks like all of these tests have been migrated to JUnit5. Would it be possible to use the @TempDir annotation to manage these resources? I think it's a much more common approach!

Comment on lines 264 to 265
Path file = Paths.get(DIR.getPath() + "testMappedByteBuffer.avro");
file.toFile().deleteOnExit();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Path file = Paths.get(DIR.getPath() + "testMappedByteBuffer.avro");
file.toFile().deleteOnExit();
Path file = DIR.toPath().resolve( "testMappedByteBuffer.avro");

For example: here we have a @TempDir already present, and cleaned up automatically in the test case -- we just accidentally forgot the path separator so the file was outside!

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, O.K. I'll try it.


@SuppressWarnings("restriction")
public class TestDataFileReader {
@TempDir
public Path DATA_DIR;
Copy link
Contributor

@paliwalashish paliwalashish Sep 24, 2023

Choose a reason for hiding this comment

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

Can we relook at the variable name once please? This format used is for constants, giving an impression that it is static final. Same for similar name in other classes

Copy link
Contributor

@RyanSkraba RyanSkraba left a comment

Choose a reason for hiding this comment

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

Great! Thanks so much for this clean up and thanks @mystic-lama for the review :D

@RyanSkraba RyanSkraba merged commit 9ed7379 into apache:master Sep 25, 2023
13 checks passed
RanbirK pushed a commit to RanbirK/avro that referenced this pull request May 13, 2024
…he#2506)

* AVRO-3863: [Java] Delete temporary test data after tests finish

* Use @tempdir

* Align Java naming convention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java Pull Requests for Java binding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants