test: improve transaction tests to use async/await #7759
Merged
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.
New Pull Request Checklist
Issue Description
Make the transactions tests (
ParseServerRESTController.spec.js
andbatch.spec.js
) use async await.@davimacedo I cleaned up the
ParseServerRESTController.spec.js
and ran into a problem with one of the transactions tests for mongo. I noticed in #5849 (comment) you mentioned mongo needed areplicaset
when using transactions.The problem I ran into is the extra reconfiguration of the server:
parse-server/spec/ParseServerRESTController.spec.js
Lines 348 to 349 in 191d80b
seems to override the one configuration that uses the
replicaSet
:parse-server/spec/ParseServerRESTController.spec.js
Lines 171 to 183 in 191d80b
Related issue: #7180
Approach
When I remove the extra reconfigure and use the
replicaset
one, the following failures occur on Mongo (the Mongo CI that doesn't use replicaSet seems to pass in any case):Note that removing the extra reconfigure on this test seems to work:
parse-server/spec/ParseServerRESTController.spec.js
Lines 189 to 190 in 191d80b
My initial thoughts are the extra reconfigure shouldn't be there and the tests might be catching an actual bug. I don't know enough about Mongo to know if separate sessions are required for transactions.
Also, it looks like the exact set of transaction tests are in
ParseServerRESTController.spec.js
andbatch.spec.js
(the same problem I mentioned above exists in both). The difference I see is one is using theParseServerRESTController
in tests. It seems both tests randomly fail with connection issues (I'm not able to replicate this locally) on Postgres (so I've disabled the RESTController transaction tests on Postgres to reduce the amount of random failures in the CI).parse-server/spec/batch.spec.js
Lines 170 to 590 in 4c29d4d
TODOs before merging