Fix order-dependent flakiness in KubernetesReconcilerCreatorTest.java #2897
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.
Describe the bug
The order dependent flakiness was detected when
KubernetesReconcilerCreatorTest.java
was run before theKubernetesInformerCreatorTest.java
. The error appeared at line 157 inKubernetesInformerCreatorTest.java
. It was suppose to get 1 result the callinggetRequestedFor()
for specificurlPattern
, however, the actual result was 2.Fix log
The reason that the flakiness showed up was due to the object
SharedInformerFactory
. Since in theKubernetesReconcilerCreatorTest.java
, we calledstartAllRegisteredInformers
in the test and registered theV1Pod
, but did not callstopAllRegisteredInformers
to stop the registration, and then when next test class was run, there were already something in the database. Eventually, that lead to the unexpected output 2 when we calledgetRequestedFor()
for specificurlPattern
. To fix this order dependent flakiness, I addedsharedInformerFactory.stopAllRegisteredInformers()
at the end of the testtestSimplePodController()
inKubernetesReconcilerCreatorTest.java
. This can make sure there won't be 2 instance with specific QueryParam came from different test class being stored in the database.Java Version
Java 17
To Reproduce
mvn install -pl spring -am -DskipTests
(must setup iDFlakies on a Maven project - https://github.com/UT-SE-Research/iDFlakies)
mvn -pl spring idflakies:detect -Ddetector.detector_type=random-class-method -Ddt.randomize.rounds=10 -Ddt.detector.original_order.all_must_pass=false
Expected behavior
When calling the getRequestedFor() method in KubernetesInformerCreatorTest, we should get the return value as 1 since we only generated the object with specific QueryParam once in this test file.