Fix flaky hosted API tests: unify SQLite timeout, increase httpx timeout, fix missing await#21105
Draft
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
…out, fix missing await Three root causes addressed for flaky test failures on main: 1. SQLite busy_timeout was 30s in test mode vs 60s in production. Under heavy parallel test execution (pytest-xdist), the hosted API server subprocess and test process compete for the same SQLite file, causing lock contention that can exceed 30s. Unified to 60s for all modes. 2. hosted_api_client used the default httpx timeout of 5s. When the hosted server is slow to respond under CI load (e.g., waiting on SQLite locks), 5s is insufficient. Increased to 30s. 3. test_delete_task_run_deletes_logs had a missing 'await' on asyncio.sleep(1), creating a tight polling loop that hammered the DB instead of yielding between retries. Failing tests: - test_get_runs_in_queue_concurrency_limit_and_limit[1] (httpx.ReadError) - test_delete_task_run_deletes_logs (httpx.ConnectTimeout) Co-authored-by: bot_apk <apk@cognition.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes two flaky test failures observed on main (workflow run, commit 11576ed):
test_get_runs_in_queue_concurrency_limit_and_limit[1]—httpx.ReadErrorcaused bysqlite3.OperationalError: database is lockedtest_delete_task_run_deletes_logs—httpx.ConnectTimeoutChanges
1. Unify SQLite
busy_timeoutto 60s for all modes (configurations.py)The test-mode SQLite
busy_timeoutwas 30s while production used 60s. Under heavy parallel test execution (pytest-xdist), the hosted API server subprocess and test process share the same SQLite file, and lock contention can exceed 30s. Theconnect_argstimeout is also bumped from 30s to 60s to match.2. Increase
hosted_api_clienthttpx timeout to 30s (tests/fixtures/api.py)The default httpx timeout of 5s is too aggressive when the hosted server is slow to respond under CI load. This is a broad fix that helps all tests using
hosted_api_client.3. Fix missing
awaitonasyncio.sleep(1)(test_task_runs.py)test_delete_task_run_deletes_logshadasyncio.sleep(1)withoutawait, which creates a coroutine object that's immediately discarded. This turned the polling loop into a tight busy-loop hammering the database instead of yielding between retries.Review checklist for humans
hosted_api_clientis appropriate — not so generous that it masks real server issues, but note it's still well under the 90s pytest-timeoutbusy_timeoutis now unconditionally 60s (no test/prod branch), whileconnect_argstimeout still has a test-mode branch — confirm this asymmetry is acceptableawait asyncio.sleep(1)fix is clearly correct but verify the surrounding polling logic still has the right semanticsChecklist
<link to issue>"mint.json.Link to Devin Session | Requested by: bot_apk (apk@cognition.ai)