Skip to content

test(extras): fix the #811 deploy test race - #818

Merged
ParidelPooya merged 5 commits into
mainfrom
fix/microvm-extras-small-followups
Oct 23, 2026
Merged

ParidelPooya merged 5 commits into
mainfrom
fix/microvm-extras-small-followups

Conversation

@ParidelPooya

@ParidelPooya ParidelPooya commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR makes two session deploy tests from #811 deterministic. It also corrects a README sentence and a docstring about JavaScript redirect behavior.

Why

  1. The Codex AI review of fix(extras): record the session resume mode #811 (finding arf_v1_ajwnsebjasbacyyspt6wbmvvj4, P2) found a race in two tests.
    1. The run fixture completes each callback as soon as the job creates it.
    2. A checkpoint response can then carry the first callback's result into the first invocation.
    3. So both jobs can be delivered with the launch's config.
    4. len(invocations) > 1 can then pass without any delivery after the deploy.
    5. If both callbacks complete early, the test fails instead.
  2. The README said that the JavaScript operation follows redirects. fix(extras): stop following redirects in the MicroVM request step aws-durable-execution-sdk-js#1036 changed that. The JavaScript operation now fails every 3xx at once with MicrovmDeliveryError. The send_job docstring in request.py made the same claim.

Changes

  • tests/microvm/session_test.py:
    • test_still_resumes_before_each_job_when_a_deploy_turns_suspending_off and test_makes_no_state_check_when_a_deploy_turns_suspending_on now run a durable wait between the two jobs. In the local runner, a durable wait ends the invocation.
    • The handler that runs the two jobs is named two_jobs_with_a_wait_between. The execution runs 4 invocations, so the earlier name two_jobs_in_two_invocations was inaccurate.
    • Each test records the invocation that sent each request.
    • Each test asserts that the first request is sent in invocation 1 and the second request in a later invocation.
  • README.md: the JavaScript redirect sentence now states the parity.
  • src/.../microvm/request.py: the send_job docstring now states that neither operation follows a redirect. It no longer says that the JavaScript fetch follows one.

Testing

  • Both tests pass 50 of 50 runs: the first request in invocation 1, the second in invocation 3.
  • The tests fail against the session.py and operation.py from before fix(extras): record the session resume mode #811, at the GetMicrovm count: 1 instead of 3, and 1 instead of 0.
  • The race did not occur in 65 runs of the old test body. The new body rules it out by construction.
  • hatch run dev-extras:cov: 279 passed, 100 % coverage. hatch run dev-extras:typecheck and hatch fmt --check pass. The commit lint passes for all four commits.

Two session tests of #811 check the resume mode across a deploy. The
handler counts its invocations. The first invocation uses the launch's
config. Every later invocation uses the deployed config. Each test runs
two jobs and asserts len(invocations) > 1.

1. The run fixture completes each callback as soon as the job creates
   it.
2. A checkpoint response carries every operation that changed since
   the last response.
3. So the first callback's result can reach the first invocation.
4. So both jobs can be delivered in the first invocation, with the
   launch's config.
5. A suspension while the second job waits then satisfies
   len(invocations) > 1. No job is delivered after the deploy.
6. If both callbacks complete early, the execution ends in one
   invocation. The assertion then fails.

The Codex review of #811 reported this race. In 65 local runs of the
old test body, the second job was delivered in invocation 2. The test
body did not ensure that order.

The two tests now run a durable wait between the jobs. A durable wait
always ends the invocation. The local runner skips the wait's time. So
the second job is delivered in a later invocation, after the deploy,
in every run.

Each test also records the invocation that sent each request. It
asserts that the first request was sent in invocation 1, and the
second request in a later invocation.

The tests fail against the session code before #811. The failures are
at the GetMicrovm count: 1 instead of 3, and 1 instead of 0.
The README said that the JavaScript operation follows redirects.
aws/aws-durable-execution-sdk-js#1036 changed that. The JavaScript
request step now passes redirect: "manual". It fails every 3xx at
once. The operation then raises MicrovmDeliveryError. So the README
now states that the JavaScript operation also fails every 3xx at once,
with MicrovmDeliveryError.
The send_job docstring said that the JavaScript operation follows
redirects. aws/aws-durable-execution-sdk-js#1036 changed that. The
JavaScript request step now fails every 3xx at once. So the docstring
contradicted the corrected README sentence.

The docstring now states that neither operation follows a redirect.
It then states why: a followed 301, 302, or 303 would send a GET
without the job, and a followed 307 or 308 to another host would
receive the auth token.
The handler two_jobs_in_two_invocations runs two jobs with a durable
wait between them. The execution runs 4 invocations, not 2. So the
name is now two_jobs_with_a_wait_between.

The SDK's wait returns without a suspension if the START checkpoint
response marks the wait SUCCEEDED. The local runner always answers a
START with STARTED. So the docstring now states that a durable wait
ends the invocation in the local runner.

A request can also time out without an answer. So the comment in
_InvocationLog.append now says that the POST gets an answer or times
out, and that the fake endpoint answers at once.

The sent_in assertions require at least 2 invocations. So the two
deploy tests no longer assert len(invocations) > 1.

@yaythomas yaythomas left a comment

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.

:shipit:

@ParidelPooya
ParidelPooya marked this pull request as ready for review October 23, 2026 20:32
@ParidelPooya
ParidelPooya temporarily deployed to ai-pr-review-runtime October 23, 2026 20:32 — with GitHub Actions Inactive
@ParidelPooya
ParidelPooya temporarily deployed to ai-pr-review-runtime October 23, 2026 20:33 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

No actionable findings in the PR changes. Residual test risk: this was a static, read-only review; tests were not executed.

Reviewed commit 230ad42819ea93f56fedfdb2d90f485ed98b8af7. Workflow run

@ParidelPooya
ParidelPooya merged commit b46e994 into main Oct 23, 2026
25 of 27 checks passed
@ParidelPooya
ParidelPooya deleted the fix/microvm-extras-small-followups branch October 23, 2026 20:36
zhongkechen pushed a commit that referenced this pull request Oct 23, 2026
* test(extras): end the invocation between two jobs

Two session tests of #811 check the resume mode across a deploy. The
handler counts its invocations. The first invocation uses the launch's
config. Every later invocation uses the deployed config. Each test runs
two jobs and asserts len(invocations) > 1.

1. The run fixture completes each callback as soon as the job creates
   it.
2. A checkpoint response carries every operation that changed since
   the last response.
3. So the first callback's result can reach the first invocation.
4. So both jobs can be delivered in the first invocation, with the
   launch's config.
5. A suspension while the second job waits then satisfies
   len(invocations) > 1. No job is delivered after the deploy.
6. If both callbacks complete early, the execution ends in one
   invocation. The assertion then fails.

The Codex review of #811 reported this race. In 65 local runs of the
old test body, the second job was delivered in invocation 2. The test
body did not ensure that order.

The two tests now run a durable wait between the jobs. A durable wait
always ends the invocation. The local runner skips the wait's time. So
the second job is delivered in a later invocation, after the deploy,
in every run.

Each test also records the invocation that sent each request. It
asserts that the first request was sent in invocation 1, and the
second request in a later invocation.

The tests fail against the session code before #811. The failures are
at the GetMicrovm count: 1 instead of 3, and 1 instead of 0.

* docs(extras): state the JS redirect behavior

The README said that the JavaScript operation follows redirects.
aws/aws-durable-execution-sdk-js#1036 changed that. The JavaScript
request step now passes redirect: "manual". It fails every 3xx at
once. The operation then raises MicrovmDeliveryError. So the README
now states that the JavaScript operation also fails every 3xx at once,
with MicrovmDeliveryError.

* docs(extras): fix the send_job redirect docstring

The send_job docstring said that the JavaScript operation follows
redirects. aws/aws-durable-execution-sdk-js#1036 changed that. The
JavaScript request step now fails every 3xx at once. So the docstring
contradicted the corrected README sentence.

The docstring now states that neither operation follows a redirect.
It then states why: a followed 301, 302, or 303 would send a GET
without the job, and a followed 307 or 308 to another host would
receive the auth token.

* test(extras): name the wait between the two jobs

The handler two_jobs_in_two_invocations runs two jobs with a durable
wait between them. The execution runs 4 invocations, not 2. So the
name is now two_jobs_with_a_wait_between.

The SDK's wait returns without a suspension if the START checkpoint
response marks the wait SUCCEEDED. The local runner always answers a
START with STARTED. So the docstring now states that a durable wait
ends the invocation in the local runner.

A request can also time out without an answer. So the comment in
_InvocationLog.append now says that the POST gets an answer or times
out, and that the fake endpoint answers at once.

The sent_in assertions require at least 2 invocations. So the two
deploy tests no longer assert len(invocations) > 1.

This branch was previously deployed

1 inactive deployment
ai-pr-review-runtime — 230ad428 Deployed Oct 23, 2026 by ParidelPooya via ai-pr-review / Codex review / Generate Codex review #2200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants