chore: attempt to fix flapping "organization not found" tests #60418
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.
The sqlstore
Reset()
function is run when the backend database is initialized. One of its tasks is ensuring that a default organization and user are created. IfReset()
finds any records in the user table, it exists early.The functions that create users for tests support auto-assigning users to an existing organization. The flapping
"organization not found"
is from that function. My theory is that - for reasons I have yet to discover - the test database would occasionally have a user record but not the organization.Reset()
finds the user and exits early; then createUser tries to create a new user and fails because the expected org wasn't created byReset()
I could still be wrong about all of this - I haven't been able to reproduce this locally, even after hours on a loop - so I've been re-running the test suite. The tests have run 5 times without that error (so far).