Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/integration/core/jobs/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,34 @@ async def test_run_job_with_env_overrides(self):
assert execution is not None
assert execution.status is not None

async def test_run_job_with_allow_queue_false(self):
"""Test running a job with allow_queue=False.

With allow_queue=False the execution is either created immediately
(capacity available) or rejected with a 429 (capacity unavailable),
never queued for background retry.
"""
job = bl_job(TEST_JOB_NAME)

try:
execution_id = await job.arun(tasks=[{"name": "AllowQueueTest"}], allow_queue=False)
except KeyError as e:
pytest.skip(f"Job API response missing expected field: {e}")
except Exception as e:
if "not found" in str(e).lower() or "404" in str(e):
pytest.skip(f"Job '{TEST_JOB_NAME}' not found in workspace")
if "429" in str(e):
pytest.skip("No capacity available right now; immediate 429 rejection is expected")
raise

assert execution_id is not None
assert isinstance(execution_id, str)

# Verify execution was created
execution = await job.aget_execution(execution_id)
assert execution is not None
assert execution.status is not None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

False pass on queued executions

Medium Severity

The success path only checks that an execution exists and has some status. Per the allow_queue=False contract, a capacity miss must 429 rather than queue, but a queued execution still passes here while a correct 429 is only skipped—so ignoring allow_queue under capacity pressure is not caught.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aa50418. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, but this can't be asserted deterministically from an integration test: the "capacity unavailable" branch only exists under real capacity pressure, which the test can't force in the shared workspace. When capacity is available, the outcome is identical with or without allow_queue=False (an execution is created), and immediately after create the stored status is legitimately queued/pending before admission, so asserting status != queued on the success path would flake rather than catch an ignored flag. The contract itself (synchronous check, immediate 429, no record) is covered by unit tests on the controlplane side (blaxel-ai/controlplane#5229, register_test.go / router tests). This test's purpose is the AGENTS.md requirement to exercise the new SDK parameter end to end against the real API — verifying the field serializes and the API accepts it.


async def test_run_job_with_both_memory_and_env_overrides(self):
"""Test running a job with both memory and env overrides."""
job = bl_job(TEST_JOB_NAME)
Expand Down
Loading