You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here using GSON.toJson(testPerson), testPerson which is an object of type TestPerson is converted to a Json String. GSON internally serializes and this can lead to change in the order of the elements which causes non-determinism in the output string.
Proposed Fix
It is very tricky to compare strings when the order can be changed, hence In my fix, we use JsonParser.parseString() as shown below.
This issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.
Related Template(s)
TextToBigQueryStreamingTest
What happened?
Detected flaky test
wrapBigQueryInsertErrorReturnsValidJSON
incom.google.cloud.teleport.templates.TextToBigQueryStreamingTest
The following command was used to detect flakiness using nondex:
nonDex detects flakiness in the lines
DataflowTemplates/v1/src/test/java/com/google/cloud/teleport/templates/TextToBigQueryStreamingTest.java
Lines 70 to 71 in 62335f6
With the error message
Explanation
The expected string is being calculated in the line
DataflowTemplates/v1/src/test/java/com/google/cloud/teleport/templates/TextToBigQueryStreamingTest.java
Line 62 in 62335f6
Here using
GSON.toJson(testPerson)
,testPerson
which is an object of typeTestPerson
is converted to a Json String. GSON internally serializes and this can lead to change in the order of the elements which causes non-determinism in the output string.Proposed Fix
It is very tricky to compare strings when the order can be changed, hence In my fix, we use
JsonParser.parseString()
as shown below.Here, the JsonParser returns a JsonObject of gson library itself, whose equals implementation is not order-sensitive.
Test Environment:
Beam Version
Newer than 2.46.0
Relevant log output
The text was updated successfully, but these errors were encountered: