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

Fix flaky tests in SignalTest.EventRequestTest and ServerSideTest.CustomDataParametersTest #360

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sliu-UIUC
Copy link

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 a list 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.

@sliu-UIUC sliu-UIUC changed the title Fix flaky tests in SignalTest.EventRequestTest and ServerSideTest#CustomDataParametersTest Fix flaky tests in SignalTest.EventRequestTest and ServerSideTest.CustomDataParametersTest Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants