Fix flaky tests in SignalTest.EventRequestTest
and ServerSideTest.CustomDataParametersTest
#360
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.
The flakiness comes from the fact that a hashmap data structure is being serialized into a Json object, but the elements in the original hashmap is not deterministic. Thus, we you compare two serialized Json string with each other, although they might contain the same elements, the order can be different during different test runs.
For checking whether the serialized string does contain all key value pairs, instead it can be done through checking each
{key, value}
pair directly and assert that each individual exists in the serialized string. Since the keys are unique in the hash map, it should be guaranteed that this way it is correctly checking the two compared objects have the same key value pairs.One thing to note is that
Gson.toJson
can also have indeterministic ordering when the object being json serialized is alist
type. Thus currently,Assert.assertTrue(serializedPayload.contains(serializedContents))
and other assertions involving serialized string type objects might be flaky as well. Further examination is needed to address this potential problem.