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

Fixed Flaky Test in WindowTest.java #44

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

Conversation

Sitara-a
Copy link

@Sitara-a Sitara-a commented Oct 4, 2024

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.

@CLAassistant
Copy link

CLAassistant commented Oct 4, 2024

CLA assistant check
All committers have signed the CLA.

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.

2 participants