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

Fixing flaky test case in BulkDecompressor.java #1986

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mihirgune
Copy link

Description

This Pull Request is meant to fix flakiness in the test BulkDecompressorTest.testDecompressUnknownCompressionFile()

The provided test is intermittently failing because it is doing a direct String comparison, in which the elements of a set are being printed in an error message. Since the order of the elements in a set is non-deterministic, the expected String is not matching the actual String. The following code is inducing the flakiness, where the BulkDecomopressor.SUPPORTED_COMPRESSIONS is a Set of supported compression types.

assertThat(
                  kv.getValue(),
                  containsString(
                      String.format(
                          BulkDecompressor.UNCOMPRESSED_ERROR_MSG,
                          unknownCompressionFile.toString(),
                          BulkDecompressor.SUPPORTED_COMPRESSIONS)));

The described issue can be reproduced by running the test using the nondex plugin, with the following command -

mvn -pl v1 edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest="com.google.cloud.teleport.templates.BulkDecompressorTest"

which occasionally throws the error -

[ERROR] Failures: 
[ERROR]   BulkDecompressorTest.testDecompressUnknownCompressionFile:237 Decompress.out1: 
Expected: a string containing "Skipping file <sample_filename> because it did not match any compression mode ([SNAPPY, ZSTD, ZIP, BZIP2, LZO, DEFLATE, LZOP, GZIP])"
     but: was "Skipping file <sample_filename> because it did not match any compression mode ([GZIP, DEFLATE, LZO, ZIP, ZSTD, SNAPPY, LZOP, BZIP2])"

Fix

The provided fix changes the type of the SUPPORTED_COMPRESSIONS from java.util.Set to java.util.List. Since the set has been converted into a list, the ordering of the elements is deterministic, and hence the flakiness has been removed.

I'd love to get feedback on this pull request. Please let me know if you'd like to see any changes!

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.09%. Comparing base (e71280a) to head (528504d).
Report is 7 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1986      +/-   ##
============================================
- Coverage     45.10%   45.09%   -0.02%     
+ Complexity     3614     3611       -3     
============================================
  Files           835      835              
  Lines         49739    49739              
  Branches       5240     5240              
============================================
- Hits          22437    22432       -5     
- Misses        25634    25638       +4     
- Partials       1668     1669       +1     
Components Coverage Δ
spanner-templates 66.24% <ø> (-0.02%) ⬇️
spanner-import-export 64.16% <ø> (-0.05%) ⬇️
spanner-live-forward-migration 76.11% <ø> (ø)
spanner-live-reverse-replication 76.48% <ø> (ø)
spanner-bulk-migration 85.50% <ø> (ø)
Files with missing lines Coverage Δ
...gle/cloud/teleport/templates/BulkDecompressor.java 56.96% <100.00%> (ø)

... and 3 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant