cloudhopper-commons icon indicating copy to clipboard operation
cloudhopper-commons copied to clipboard

Fixed Flaky Test in WindowTest.java

Open Sitara-a opened this issue 1 year ago • 1 comments

Description

The test simulatedMultithreadedProcessing in the test class com.cloudhopper.commons.util.windowing.WindowTest could fail if the same key is generated by two different threads.

Steps to reproduce

Run the test multiple times. The current logic to generate a key is: Integer.valueOf(""+id+""+x); Here id is a number between 0 and requestThreadCount-1 x is a number between 0 and requestsPerThread-1 However, this can generate duplicate keys in some scenarios. Eg- For id = 0, x = 26 -> Key is 26 and for id = 2, x = 6 -> Key is 26. This leads to a DuplicateKeyException being thrown.

This was identified by running NonDex. The flaky tests can be found when running the following command: mvn edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest={test}

Expected Behaviour

All tests should pass

Actual Behaviour

The test can fail if duplicate keys are generated.

Solution

The logic of defining a key is updated to - Integer.valueOf(""+id*requestsPerThread+""+x); This way there are no duplicate keys generated.

Sitara-a avatar Oct 04 '24 19:10 Sitara-a

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 04 '24 19:10 CLAassistant