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 sporadic flowauth fails #845

Merged
merged 6 commits into from
May 28, 2019
Merged

Fix sporadic flowauth fails #845

merged 6 commits into from
May 28, 2019

Conversation

greenape
Copy link
Member

@greenape greenape commented May 23, 2019

Closes #844

I have:

  • Formatted any Python files with black
  • Brought the branch up to date with master
  • Added any relevant Github labels
  • Added tests for any new additions
  • Added or updated any relevant documentation
  • Added an Architectural Decision Record (ADR), if appropriate
  • Added an MPLv2 License Header if appropriate
  • Updated the Changelog

Description

Added two multiprocessing Events, which prevent more than one forked flowauth process from trying to initialise the database, or create demo data, and will cause others to wait until this is done.

@greenape greenape added bug Something isn't working FlowAuth Issues related to FlowAuth labels May 23, 2019
@codecov
Copy link

codecov bot commented May 23, 2019

Codecov Report

Merging #845 into master will decrease coverage by 0.06%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #845      +/-   ##
==========================================
- Coverage   93.13%   93.07%   -0.07%     
==========================================
  Files         130      130              
  Lines        6631     6657      +26     
  Branches      696      696              
==========================================
+ Hits         6176     6196      +20     
- Misses        331      337       +6     
  Partials      124      124
Flag Coverage Δ
#flowapi_unit_tests 77.9% <ø> (ø) ⬆️
#flowauth_unit_tests 94.03% <77.77%> (-0.65%) ⬇️
#flowclient_unit_tests 82.6% <ø> (ø) ⬆️
#flowkit_jwt_generator_unit_tests 100% <ø> (ø) ⬆️
#flowmachine_unit_tests 91.13% <ø> (ø) ⬆️
#integration_tests 59.87% <ø> (ø) ⬆️
Impacted Files Coverage Δ
flowauth/backend/flowauth/models.py 93.17% <77.77%> (-1.9%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b01bb87...f69c63d. Read the comment docs.

@codecov
Copy link

codecov bot commented May 23, 2019

Codecov Report

Merging #845 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #845      +/-   ##
==========================================
+ Coverage   93.13%   93.16%   +0.02%     
==========================================
  Files         130      130              
  Lines        6631     6657      +26     
  Branches      696      696              
==========================================
+ Hits         6176     6202      +26     
  Misses        331      331              
  Partials      124      124
Flag Coverage Δ
#flowapi_unit_tests 77.9% <ø> (ø) ⬆️
#flowauth_unit_tests 94.86% <100%> (+0.19%) ⬆️
#flowclient_unit_tests 82.6% <ø> (ø) ⬆️
#flowkit_jwt_generator_unit_tests 100% <ø> (ø) ⬆️
#flowmachine_unit_tests 91.13% <ø> (ø) ⬆️
#integration_tests 59.87% <ø> (-0.04%) ⬇️
Impacted Files Coverage Δ
flowauth/backend/flowauth/models.py 95.58% <100%> (+0.51%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b21b90...75a8ffa. Read the comment docs.

@greenape greenape self-assigned this May 23, 2019
@greenape greenape added the ready-to-merge Label indicating a PR is OK to automerge label May 23, 2019
@greenape greenape removed their assignment May 23, 2019
with app.app_context():
runner = app.test_cli_runner()
app.config["DB_IS_SET_UP"].clear()
result = runner.invoke(demodata)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double-check: these two instances of runner.invoke(demodata) will run in serial, i.e. the first one will definitely finish before the second one is run? Just want to make sure this test can't accidentally fail if they run concurrently.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely serial.

with app.app_context():
runner = app.test_cli_runner()
app.config["DB_IS_SET_UP"].clear()
app.config["DB_IS_SETTING_UP"].set()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically the use of DB_IS_SETTING_UP as a flag is an internal implementation detail, but I can't think of an easy way to reliably trigger the test condition in a different way so I guess it's fine to use it in the test too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually that's a good point - these should probably be on g instead really. I'll change it.

Copy link
Contributor

@maxalbert maxalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍 Well done for identifying the cause of this issue.

@mergify mergify bot merged commit 5a2ed85 into master May 28, 2019
@mergify mergify bot deleted the fix-sporadic-flowauth-fails branch May 28, 2019 10:37
@greenape greenape removed the ready-to-merge Label indicating a PR is OK to automerge label May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working FlowAuth Issues related to FlowAuth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sporadic flowauth test fails
2 participants