Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem Statement:
Shared Static Variables: The use of static variables like ws (the WebSocketServer instance), port, and countServerDownLatch meant that these resources were shared across multiple test instances.
This shared state caused interference between tests, especially when they were run multiple times or in parallel, leading to unpredictable failures.
Parameterized Tests with Shared State: Parameterizing the tests without proper isolation led to tests depending on or interfering with each other.
The combination of shared static variables and parameterization exacerbated the flakiness.
Solution Implemented:
Eliminated Static Variables: Removed the static variables ws, port, and countServerDownLatch.
By using local variables within the test method runTestScenarioReconnect, we prevent shared state between test runs.
Removed Parameterization: Eliminated the RunWith(Parameterized.class) annotation and related parameterization code. Instead, used a simple loop within each test method to run the test scenario multiple times (10 iterations), providing the same effect without the complexity and flakiness introduced by parameterization.
Related Issue
Fixes #1443
Motivation and Context
The change eliminates flakiness in the Issue256Test class caused by shared static state, improper resource management, and reliance on parameterization. These issues led to Non-Order-Deterministic (NOD) failures where tests interfered with each other due to shared resources like the WebSocketServer instance and static ports. This change ensures the tests are robust.
How Has This Been Tested?
iDFlakies
Types of changes
Checklist: