DataflowTemplates icon indicating copy to clipboard operation
DataflowTemplates copied to clipboard

Fix flaky test in CassandraRowMapperFnTest.testSetColumn

Open Md-Arif-Hasan opened this issue 7 months ago • 1 comments

Purpose of this change

This change fixes the following flaky test in the DataflowTemplates project: com.google.cloud.teleport.bigtable.CassandraRowMapperFnTest#testSetColumn

The Issue When the above test is run using the NonDex Maven plugin with the following command: mvn edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=com.google.cloud.teleport.bigtable.Cass

The root cause of this flakiness lies in the fact that the test relies on the deterministic ordering of elements derived from a data structure (likely a Map or Set) that does not guarantee order across executions. This results in assertion failures even when the actual content is correct, just arranged differently due to the non-deterministic iteration order.

My Fix

To resolve the issue, I modified the test to verify the presence and correctness of expected elements without depending on their order. Specifically:

  • Assertions were updated to compare contents regardless of sequence.
    
  • Removed index-based checks that assumed a fixed order.
    

This makes the test robust and stable across multiple executions, including randomized environments like NonDex.

P.S.

I considered introducing sorting to ensure deterministic ordering before making comparisons, but chose not to pursue that route. Sorting could introduce unnecessary coupling between the test and the internal representation, making future maintenance more complex.

I’d appreciate any feedback on this fix! Let me know if you’d like further improvements or changes.

Md-Arif-Hasan avatar Apr 19 '25 14:04 Md-Arif-Hasan

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Apr 19 '25 14:04 google-cla[bot]