Skip to content

test(e2e): align test_sdk_tunnel.py with the rest of the suite's box lifecycle - #1187

Merged
DorianZheng merged 2 commits into
boxlite-ai:mainfrom
G4614:test/sdk-tunnel-explicit-lifecycle
Aug 11, 2026
Merged

test(e2e): align test_sdk_tunnel.py with the rest of the suite's box lifecycle#1187
DorianZheng merged 2 commits into
boxlite-ai:mainfrom
G4614:test/sdk-tunnel-explicit-lifecycle

Conversation

@G4614

@G4614 G4614 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

test_sdk_tunnel.py now manages box lifecycle with rt.create()/rt.remove() like the rest of apps/e2e, instead of SimpleBox.

Test plan:

  • apps/e2e/cases/test_sdk_tunnel.py against the dev cloud API — same pass/xfail pattern before and after this change, dev box count returns to 0 either way

Summary by CodeRabbit

  • Tests

    • Improved end-to-end coverage for tunnel functionality, including stopped-box behavior and multi-box isolation.
    • Enhanced test cleanup to reduce interference between test runs and improve reliability.
    • Updated service lifecycle validation to reflect current execution behavior.
  • Refactor

    • Modernized test setup and teardown flows without changing the user-facing product experience.

…lifecycle

Every other file in apps/e2e/cases uses rt.create() + try/finally: rt.remove()
for box lifecycle. test_sdk_tunnel.py was the sole outlier on SimpleBox's
async-with convenience wrapper - which is how the auto_remove leak fixed in
boxlite-ai#1186 stayed invisible here for so long: the one file with a different
lifecycle pattern was the one nobody thought to check.

network.tunnel() isn't SimpleBox-specific - the raw Box returned by
rt.create() exposes the same handle - so there's no functional reason to
keep the indirection. Switching means this file no longer depends on
SimpleBox's internal cleanup logic at all, and gets the same explicit,
auditable cleanup path as everything else.

test_python_sdk_tunnel_rejects_stopped_box now calls box.stop() directly
instead of relying on `async with` exit - it's testing tunnel access to a
stopped-but-not-deleted box, and after boxlite-ai#1186 exiting a SimpleBox with
auto_remove=True deletes the box outright, which would have silently
changed what this test exercises.

_start_service/_stop_service also move off SimpleBox.exec()'s
convenience signature (single ExecResult return) onto the raw
Box.exec() -> Execution contract (exec + drain + wait), matching
test_lifecycle_comprehensive.py and friends.

Verified against the dev cloud API: same pass/xfail/flake pattern as the
pre-refactor file (test_python_sdk_tunnel_rejects_stopped_box's XPASS(strict)
is a pre-existing, unrelated flake - reproduces identically before and after
this change), and dev cloud box count returns to 0 whether the run passes or
fails.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 601d6e65-83a8-4743-b768-403ecb3e62a4

📥 Commits

Reviewing files that changed from the base of the PR and between e9dd670 and 47fdf15.

📒 Files selected for processing (1)
  • apps/e2e/cases/test_sdk_tunnel.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/e2e/cases/test_sdk_tunnel.py

📝 Walkthrough

Walkthrough

The tunnel E2E tests now create boxes through rt.create, use updated execution result handling, test stopped boxes without immediate removal, and explicitly clean up boxes after each test.

Changes

Tunnel E2E lifecycle updates

Layer / File(s) Summary
Update service execution helpers
apps/e2e/cases/test_sdk_tunnel.py
Service helpers use list-based shell arguments, drain execution streams, await completion, and validate exit_code.
Migrate tunnel test box lifecycle
apps/e2e/cases/test_sdk_tunnel.py
Tunnel tests use runtime-created Box instances, retain stopped boxes for stopped-state coverage, and force removal during cleanup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: dorianzheng

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a summary and test plan but omits the required Call graph and Changes sections. Add the required Before and After call graph, list the notable Changes, and retain the verification steps.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the test file and its primary change to box lifecycle management.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@G4614
G4614 marked this pull request as ready for review August 10, 2026 06:06
@G4614
G4614 requested a review from a team as a code owner August 10, 2026 06:06
@boxlite-agent

boxlite-agent Bot commented Aug 10, 2026

Copy link
Copy Markdown

📦 BoxLite review — couldn't complete

review watchdog timed out after 93 minutes without a /publish callback
repo: boxlite-ai/boxlite
pr: 1187
head: 47fdf153e4e30469ac977e3d80094eb0a68fa972
box: pr-review-boxlite-1187-msmw2b0h
last stage: clone ready
stage updated: 2026-08-10T07:07:18.638Z

powered by BoxLite

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/e2e/cases/test_sdk_tunnel.py`:
- Around line 272-276: Update the box setup around the boxes collection and
cleanup try/finally block: initialize boxes before try, create each box within
the try scope, and append it immediately after successful creation so cleanup
also runs when a later rt.create call fails. Preserve cleanup for every
successfully created box.
- Around line 51-53: Apply the 30-second asyncio.wait_for timeout to both
drain(ex) calls in apps/e2e/cases/test_sdk_tunnel.py at lines 51-53 and 59-61,
ensuring stream draining cannot block indefinitely before waiting for process
completion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d55d823-3d60-42f0-b34a-20e16916e877

📥 Commits

Reviewing files that changed from the base of the PR and between 19e4d8e and e9dd670.

📒 Files selected for processing (1)
  • apps/e2e/cases/test_sdk_tunnel.py

Comment thread apps/e2e/cases/test_sdk_tunnel.py Outdated
Comment thread apps/e2e/cases/test_sdk_tunnel.py Outdated
CodeRabbit on boxlite-ai#1187:
- _start_service/_stop_service: drain(ex) had no timeout of its own, so a
  hung remote exec would block forever before ever reaching ex.wait()'s
  30s timeout. Wrapped both in the same asyncio.wait_for(..., timeout=30).
- test_python_sdk_tunnel_keeps_boxes_isolated: `boxes = [await rt.create()
  for _ in range(2)]` never assigns `boxes` if the second create() raises,
  so a first box that succeeded remotely would have no reference for
  `finally` to clean up. Now appended one at a time inside try.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@DorianZheng
DorianZheng merged commit 2109bdb into boxlite-ai:main Aug 11, 2026
24 checks passed
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