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
Fixed the flaky test
when multiple attributes are specified it should examine all
inside theAttributeSetTest
classDetected flaky test
when setting an expectation as an object it should be serialized to json
inside theDefaultMockServerTest
class.Detected flaky tests
put /1, with missing item, should create item
put /1, with existent item, should replace item
get /1, with existent item, should return item
get /, with one item, should return item
get /, with multiple items, should return array
inside theDefaultMockServerCrudTest
class.Root Cause
All tests mentioned above have been reported as flaky when run with the NonDex tool.
AttributeSetTest
when multiple attributes are specified it should examine all
inside theAttributeSetTest
class utilizeAttribute
andAttributeSet
to perform test operation. However, groovy'sAttributeSet
does not guarantee the elements' order. Therefore, theindexOf()
method will give different results based on the index ofa3
at line 114.kubernetes-client/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/crud/AttributeSetTest.groovy
Lines 109 to 114 in 56a6c2c
DefaultMockServerTest
when setting an expectation as an object it should be serialized to json
inside theDefaultMockServerTest
class invokes the methodclinent.newCall()
which will return a response type result. Then convert this result to a string and compare it with the expected string. However, I guess theResponse
type will not guarantee elements order inside it. Therefore, convertingResponse
to a string will generate a string that has a different order from the expected string.kubernetes-client/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerTest.groovy
Lines 243 to 247 in 56a6c2c
DefaultMockServerCrudTest
Tests in this class have the same problem as the test in the
DefaultMockServerTest
class. Invoking toclient.newCall()
returns aResponse
type result that cannot guarantee a specific order for elements inside. Therefore, converting to a string will not generate the expected string.kubernetes-client/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerCrudTest.groovy
Lines 84 to 89 in 56a6c2c
To reproduce run:
Fix
AttributeSetTest
I fixed this test by creating a new
LinkedHashSet
to storeAttribute
.LinkedHashSet
will guarantee the order ofAttribute
inside it.DefaultMockServerTest & DefaultMockServerCrudTest
For tests in these two classes, a simple way to fix them is to create another
Response
object and assign expected data to the object. However, I cannot find any information about how to create aResponse
object and assign a value to it. Therefore, I can only discuss one possible solution here.Key changed/added classes in this PR
io.fabric8.mockwebserver.crud.AttributeSetTest
Type of change
test, version modification, documentation, etc.)
Checklist