Fix testDedicatedHostPrototypeDedicatedHostByZone and 9 other tests #38
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 Problem
The tests
are flaky as was discovered through the plugin NonDex. Here are the full steps to reproduce this issue:
The build will fail.
The current implementation compares two serializations with each other in each one of these tests. However, it would be safer to directly compare the objects themselves to avoid any issues where serialization strings are different but representing the same object. NonDex shuffles the ordering of fields so that the serialization strings differ, causing the tests to fail without having any real issues.
The Fix
It's a very simple fix, instead of comparing serializations,
JsonParserfrom GSON is used to compare their deserialized forms to make sure that the test will not fail with the plugin because a field in the serialization string is in a different ordering from another that is constructed from the same object.After the fix, running the previous series of commands will no longer make the build fail. It will make sure that no false alarm goes off because of such reasons.
Please do give some feedbacks on whether you think this way of fixing it is feasible. Thanks!