You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by "pem70 (via GitHub)" <gi...@apache.org> on 2025/10/01 19:24:06 UTC

[PR] [#4966] Fixing flaky test `TestSwaggerUtils#testSchemaMethod` [servicecomb-java-chassis]

pem70 opened a new pull request, #4967:
URL: https://github.com/apache/servicecomb-java-chassis/pull/4967

   ### Issue
   The method `testSchemaMethod()` in `TestSwaggerUtils` compares pretty-printed YAML strings to verify correctness. However, since the OpenAPI object is constructed with `Map`/`Set` iteration, the key order in the serialized YAML is non-deterministic. When the iteration order changes, the string comparison fails, resulting in flaky behavior.  
   
   This test was flagged by the [**NonDex**](https://github.com/TestingResearchIllinois/NonDex) tool, which detects unreliable tests caused by hidden assumptions in Java API ordering. To reproduce:
   
   ```bash
   mvn -pl swagger/swagger-generator/generator-core   edu.illinois:nondex-maven-plugin:2.1.7:nondex   -Dtest=org.apache.servicecomb.swagger.generator.core.TestSwaggerUtils#testSchemaMethod
   ```
   
   ### Fix
   Instead of checking raw YAML string equality, I parse both the expected and actual YAML into JSON trees and compare them structurally. This makes the test order-insensitive and removes the non-determinism.  
   
   Rerunning NonDex with this change shows a stable passing result.
   
   ### PR Checklist
   - [ ] **Github Issue:** [[BUG] - Flaky test in `TestSwaggerUtils#testSchemaMethod` (#4966 )  ](https://github.com/apache/servicecomb-java-chassis/issues/4966)
   - [ ] Each commit in the pull request should have a meaningful subject line and body.  
   - [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.  
   - [ ] Format the pull request title like `[SCB-XXX] Fix flaky test in TestSwaggerUtils#testSchemaMethod`, where you replace `SCB-XXX` with the appropriate JIRA issue.  
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.  
   


-- 
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@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#4966] Fixing flaky test `TestSwaggerUtils#testSchemaMethod` [servicecomb-java-chassis]

Posted by "pem70 (via GitHub)" <gi...@apache.org>.
pem70 commented on PR #4967:
URL: https://github.com/apache/servicecomb-java-chassis/pull/4967#issuecomment-3357918639

   This fix applies to all tests calling `testSwagger`, including `TestPojo.testResponseEntity` and `TestPojoExample.testPojoExample1`, which were not mentioned in this PR.


-- 
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@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#4966] Fixing flaky test `UnitTestSwaggerUtils#testSwagger` [servicecomb-java-chassis]

Posted by "liubao68 (via GitHub)" <gi...@apache.org>.
liubao68 commented on PR #4967:
URL: https://github.com/apache/servicecomb-java-chassis/pull/4967#issuecomment-3393028588

   Sorry I will not merge this pull request as I do not want to introduce new dependencies for runtime package. 
   This is a historical problem to add test code in runtime component, and will take a bit effort to fix it. 


-- 
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@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#4966] Fixing flaky test `UnitTestSwaggerUtils#testSwagger` [servicecomb-java-chassis]

Posted by "pem70 (via GitHub)" <gi...@apache.org>.
pem70 commented on PR #4967:
URL: https://github.com/apache/servicecomb-java-chassis/pull/4967#issuecomment-3423763292

   > Sorry I will not merge this pull request as I do not want to introduce new dependencies for runtime package. This is a historical problem to add test code in runtime component, and will take a bit effort to fix it.
   
   Thanks for your feedback! I opened a new [PR](https://github.com/apache/servicecomb-java-chassis/pull/4984), which addressed the same issue without introducing new dependencies. It would be great if you could have a look!


-- 
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@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#4966] Fixing flaky test `UnitTestSwaggerUtils#testSwagger` [servicecomb-java-chassis]

Posted by "liubao68 (via GitHub)" <gi...@apache.org>.
liubao68 closed pull request #4967: [#4966] Fixing flaky test `UnitTestSwaggerUtils#testSwagger`
URL: https://github.com/apache/servicecomb-java-chassis/pull/4967


-- 
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@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org