Fix flaky test testAssembleQueryConfigUrl.#4083
Fix flaky test testAssembleQueryConfigUrl.#4083nobodyiam merged 2 commits intoapolloconfig:masterfrom
Conversation
|
Thanks for the report. In this case, though the converted string of queryConfigUrl is non-deterministic due to hash map characteristic, I think this test will always pass as the actual logic to handle assembleQueryConfigUrl: if (remoteMessages != null) {
queryParams.put("messages", queryParamEscaper.escape(GSON.toJson(remoteMessages)));
}testAssembleQueryConfigUrl: assertTrue(queryConfigUrl
.contains("messages=" + UrlEscapers.urlFormParameterEscaper()
.escape(gson.toJson(notificationMessages)))); |
|
Thanks for your response! Yes, both |
Codecov Report
@@ Coverage Diff @@
## master #4083 +/- ##
=========================================
Coverage 52.45% 52.45%
Complexity 2612 2612
=========================================
Files 484 484
Lines 15203 15203
Branches 1572 1572
=========================================
Hits 7974 7974
- Misses 6674 6675 +1
+ Partials 555 554 -1
Continue to review full report at Codecov.
|
Fix flaky test testAssembleQueryConfigUrl due to the non-deterministic iteration order of HashMap.
This flaky test is found by using Nondex, a tool used to find flaky tests in Java projects. The assertion on Line#361 in
RemoteConfigRepositoryTest.javamay fail because the order of two entries,someKeyandanotherKey, is non-deterministic, so the converted string ofqueryConfigUrlis non-deterministic, resulting in the flaky test. To fix this test, the data structure of thedetailsfield ofApolloNotificationMessagesis changed fromHashMaptoTreeMapso that the entries of the map is sorted. As a result, the iteration order is deterministic and the test will always pass.