Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix intermittent test failures #214

Merged
merged 1 commit into from
Nov 10, 2020
Merged

Conversation

rcowsill
Copy link
Contributor

@rcowsill rcowsill commented Sep 27, 2020

Sometimes the cypress tests fail in CI when they should have passed. Rerunning the tests eventually gets them to go green, but that makes unnecessary work for the maintainers. The change in this PR fixes the main issue causing this problem in the master branch.

This issues affects all branches, but it's intermittent. The nodegoat service fails with:

TypeError: Cannot read property 'seq' of null
    at /home/travis/build/OWASP/NodeGoat/app/data/user-dao.js:119:83

All cypress tests fail after that point. For example: https://travis-ci.com/github/OWASP/NodeGoat/jobs/298947707

That happens because the db-reset script doesn't wait for the collection drop commands to complete before inserting new data. The command to insert the userId counter can run against the old collection, just before it gets deleted. The test then fails when nodegoat tries to add a user and can't get the userId counter.

21d5740 prevents that by waiting for all the collection drops to complete (or fail) before starting to insert new data. Sorry if the diff looks complex, the last ~50 lines is mainly just an extra level of indentation. It's much clearer with "hide whitespace changes" enabled.

Collection drop commands were sent without waiting for their completion. The
userId counter insert could complete before the counter collection drop.
In that case the new counter would be deleted
@rcowsill rcowsill marked this pull request as ready for review September 27, 2020 22:48
@rcowsill rcowsill mentioned this pull request Sep 27, 2020
6 tasks
@ckarande ckarande merged commit 21d5740 into OWASP:master Nov 10, 2020
@rcowsill rcowsill deleted the fix/db-reset branch November 10, 2020 09:45
@rcowsill rcowsill mentioned this pull request Jun 7, 2021
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants