-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow to run tests with read-only credentials for DB #711
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #711 +/- ##
==========================================
- Coverage 82.18% 82.10% -0.09%
==========================================
Files 42 42
Lines 6196 6224 +28
==========================================
+ Hits 5092 5110 +18
- Misses 1104 1114 +10 ☔ View full report in Codecov by Sentry. |
Obviously (!) tested only with read-only credentials. But tests in test_db_handler are skipped also for write credentials... |
This issue is fixed now. Tests are running correctly now depending on the DB configuration. |
I am not sure about the status of this PR. Did you already set in the CI and everywhere the read-only user? I would make one annoying suggestion, change the name of "admin" to "write" cause it's not really admin rights and we might even need that in the future. Regarding the integration test. I suggest we mark that as |
Not ready for review (as it is draft :-) ). Waited for your answer in issue #604. So I do this tomorrow (or feel free to do it). |
@orelgueta - I think I need your help here. units tests are almost all working individually (except test_db_handler.py::test_insert_files_db), but not when executed after each other. I don't see where I overwrite the db configuration from write to read. |
… function can accidentally open 1000 simultaneous connections, but the probability is small, so it is probably acceptable
… with hazargeous search and replace
Your solution in terms of pytest was fine, but you didn't take into account that the Essentially, it was written such that once a connection is open, any other init of the For the sake of this PR I removed that protection to allow two connections, one with read permissions and one with write permissions. Now we have to decide wether we think it is a good idea to remove the protection from I tend to think it would be better to simply use the the |
This is definitely good - I was seriously in doubt about my understanding of pytest fixtures. I didn't know that there should be one DB instance only. I agree with you that we should remove this protection. What about the simple solution of running in the matrix of the unit tests one of the elements with write permissions? This would mix testing different python versions / pip vs mamba setup with db read / write setup, but would give us enough confidence that the code is good and tested. Don't you think that some of the tools will also write to the database? Or did we agree (I would be fine with it) that tools produces output (in most cases files) and it is a separate step (as part of a workflow) to submit it to the database. |
I assume you meant to write "shouldn't", right?
Here as well, I assume you mean one of the elements with read permissions, right? However, since we are essentially limiting the scope of the read-only test to just checking that the user itself works (and not the code/tests), I don't see the benefit of running multiple tests with it instead of just one application/test. That is why I made the suggestion to run the 1-2 applications you plan to run in the prod container with the read-only account and that's it.
I don't know yet if it will be part of a workflow or one single tool that also writes to the "production DB". Either way, when we get there, we can make sure that that application runs with the write permissions. For now, we can choose any application and run it with the read-only user. |
shouldn't
I actually meant read permission. Most of the unit tests don't write to the DB (except
OK, all good - I think we agree. |
Sorry, but did we agree to do?
|
After discussion on zoom we decided to close this PR without merging. |
closes #604
This PR changes the tests so that they can run with the read-only credentials for the DB:
@pytest.mark.requires_db_admin
Note that the integration test
tests/integration_tests/test_applications.py::test_applications[simulate_prod::gamma_20_deg_pack_for_grid]
requires write access. We leave for the the write access for the integration tests.