You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/12/08 02:49:20 UTC
[GitHub] [camel-spring-boot] bmk15897 opened a new pull request, #681: Fixed Flaky Tests Caused by JSON permutations
bmk15897 opened a new pull request, #681:
URL: https://github.com/apache/camel-spring-boot/pull/681
### Description
Flaky Tests found using [NonDex](https://github.com/TestingResearchIllinois/NonDex) by running the commands -
`
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.apache.camel.component.gson.springboot.GsonFieldNamePolicyTest#testMarshalPojo
`
`
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.apache.camel.component.gson.springboot.GsonMarshalExclusionTest#testMarshalAndUnmarshalPojoWithAnotherExclusion
`
`
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.apache.camel.component.gson.springboot.SpringGsonFieldNamePolicyTest#testMarshalPojo
`
The logged failures were-
```
[WARNING] Flakes:
[WARNING] org.apache.camel.component.gson.springboot.GsonFieldNamePolicyTest.testMarshalPojo
[ERROR] Run 1: GsonFieldNamePolicyTest.testMarshalPojo:76 expected: <{"id":123,"first_name":"Donald","last_name":"Duck"}> but was: <{"id":123,"last_name":"Duck","first_name":"Donald"}>
[INFO] Run 2: PASS
```
```
[ERROR] [WARNING] Flakes:
[WARNING] org.apache.camel.component.gson.springboot.GsonMarshalExclusionTest.testMarshalAndUnmarshalPojoWithAnotherExclusion
[ERROR] Run 1: GsonMarshalExclusionTest.testMarshalAndUnmarshalPojoWithAnotherExclusion:98 expected: <{"height":190,"weight":70}> but was: <{"weight":70,"height":190}>
[INFO] Run 2: PASS
```
```
[WARNING] Flakes:
[WARNING] org.apache.camel.component.gson.springboot.SpringGsonFieldNamePolicyTest.testMarshalPojo
[ERROR] Run 1: SpringGsonFieldNamePolicyTest.testMarshalPojo:87 expected: <{"id":123,"first_name":"Donald","last_name":"Duck"}> but was: <{"last_name":"Duck","id":123,"first_name":"Donald"}>
[INFO] Run 2: PASS
```
### Investigation
The tests fail with a comparison error while comparing an expected JSON String and the result from the value returned by the funtion template.requestBody(...). The function of the that converts given Pojo Object to String does not guarantee the order of the fields in the Pojos. This makes the test outcome non-deterministic, and the test fails whenever the function returns a mismatch in order of the elements in the JSON String. To fix this, the expected and actual keys should be checked in a more deterministic way so that the assertions do not fail.
### Fix
Expected and actual arrays can be compared without making assumptions about the order of the keys in these JSON Strings. Instead of using assertEquals for the complete JSON String, using contains for every subpart of the expected String makes the test more deterministic and ensures that the flakiness from the test is removed.
The PR does not introduce a breaking change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-spring-boot] bmk15897 commented on pull request #681: Fixed Flaky Tests Caused by JSON permutations
Posted by GitBox <gi...@apache.org>.
bmk15897 commented on PR #681:
URL: https://github.com/apache/camel-spring-boot/pull/681#issuecomment-1342119528
Yes @davsclaus I will work on them too! :) Thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-spring-boot] davsclaus commented on pull request #681: Fixed Flaky Tests Caused by JSON permutations
Posted by GitBox <gi...@apache.org>.
davsclaus commented on PR #681:
URL: https://github.com/apache/camel-spring-boot/pull/681#issuecomment-1342083503
You are welcome to check the tests in https://github.com/apache/camel as we have tests for gson/json there too under components
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-spring-boot] davsclaus merged pull request #681: Fixed Flaky Tests Caused by JSON permutations
Posted by GitBox <gi...@apache.org>.
davsclaus merged PR #681:
URL: https://github.com/apache/camel-spring-boot/pull/681
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org