Repository navigation
test: add httpx-based Code Interpreter test suite ported from the SDK - #345
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Devin.
|
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
f8e2abe to
f60a587
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
…r protocol Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
…R tests Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
…R tests Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
8932b92 to
042d1e8
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8932b92a1d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@claude review |
…dev/code-interpreter (#1956) ## Summary Follow-up to e2b-dev/code-interpreter#345, which ports the Code Interpreter behavior suite into the template repo as a direct-HTTP (httpx) suite. The SDK suites in `packages/code-interpreter-python` and `packages/code-interpreter-js` now only test SDK surface; everything that asserted on server/template behavior is removed here (~-2900 LOC, no `src/` changes). Removed (py sync + async, js): `charts/*` live chart-shape tests (the Python `charts/test_json.py` `to_json` test stays), `test_default_kernels`/`defaultKernels` (js/ts/r/java/bash hello-worlds), `test_cwd`, `test_bash`, `env_vars/*` (per-language × sandbox-level/per-execution/overwrite), `test_statefulness`, `test_execution_count`, `test_display_data`, `test_data`, `test_custom_repr_object`, `images/*`, `test_systemd`, and `test_kernels` (its one SDK check, `test_pass_context_and_language` → `InvalidArgumentException` / `InvalidArgumentError`, moved into `test_contexts` / `contexts.test.ts`). With the java/r kernel tests gone, the `_wait_for_kernel*` / `waitForKernel` readiness-retry helpers and their unit tests (`test_java_kernel_readiness.py`, `javaKernelReadiness.test.ts`) have no callers and are removed from `conftest.py` / `setup.ts` too. Replaced with SDK-focused coverage (from review): - `tests/{sync,async}/test_env_vars.py`, `tests/envVars.test.ts` — one per-execution `envs` → `env_vars` pass-through test per implementation (the HTTP suite can't see the SDK's request mapping). - `tests/charts/test_deserialize.py` — fixture-based unit tests for `_deserialize_chart` / `Result(chart=…)` / `to_json` covering line, scatter, bar, pie, box-and-whisker, nested superchart, unknown type and unknown scale. No JS counterpart: `Result` in JS stores the raw `chart` payload, there is no deserialization step to test. Kept: basic (incl. secure-traffic), callbacks, contexts, interrupt, killed, reconnect, streaming, messaging/utils/sandbox-url/timeout/exception-format unit tests, `performance.py`. CI: `code_interpreter_{python,js}_tests.yml` `run_recovery_tests=false` paths no longer ignore the deleted systemd files (interrupt is the only remaining recovery suite). Verified locally against `code-interpreter-v1`: Python 62 → now 77 incl. the new unit tests, JS 38 passed. Linear: [SDK-386](https://linear.app/e2b/issue/SDK-386/port-code-interpreter-test-suite-from-the-sdk-to-e2b-devcode) Link to Devin session: https://app.devin.ai/sessions/6fd302f062cc459796016eba4e06d9e1 Open in Devin Desktop: https://app.devin.ai/desktop/session/6fd302f062cc459796016eba4e06d9e1?variant=devin Requested by: @mishushakov --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: mish@e2b.dev <mish@e2b.dev>
…rver_tests.yml Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
|
check the findings above |
…local server; fail fast if the kill in test_killed errors Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
Summary
Ports the Code Interpreter test suite from
e2b-dev/E2B(packages/code-interpreter-python/-js) into this repo as a standalonetests/uv project. Thee2bSDK is used only for sandbox lifecycle (Sandbox.create/kill/connect,get_host(49999), access tokens,commands.runfor in-sandbox shell checks); everything that talks to the Code Interpreter server goes over its HTTP API on port49999withhttpx, so the server protocol is what's under test and template/server changes can be validated here without an SDK release. Noe2b_code_interpreterimport anywhere.Harness (
tests/harness/):CodeInterpreter/AsyncCodeInterpreter— wire-protocol client forhttps://{sandbox.get_host(49999)}:/health,/contexts*, and/executeas an NDJSON stream aggregated intoExecution(stdout,stderr,results,error,execution_count,completed, rawevents). SendsX-Access-Token/E2B-Traffic-Access-Tokenfrom the sandbox; non-2xx raisesCodeInterpreterError(status_code, body).wait_for_kernel(language)keeps the 4-attempt-on-500 readiness retry for the lazily started Java/R contexts (called inline by the tests that need it).conftest.py):sandbox/sandbox_factory(timeout=, envs=, allow_public_traffic=)wrape2b.Sandbox;client/client_factory/async_clientbuild the httpx client for a fresh sandbox (killed on teardown).E2B_DEBUG=truetargetshttp://localhost:49999(make start-template-server) and skipsskip_debugtests.Coverage ported: basic/statefulness/stdout/stderr/error,
!bashmagic, execution count, secure-traffic sandboxes, reconnect (Sandbox.connect), contexts (create/list/restart/remove, cwd, alias normalization), kernels (js/ts/r/java/bash, ESM imports, top-level await), cwd per language, env vars (sandbox-level, per-execution, overwrite × python/js/bash/r/java), streaming event order, display data / pandasdata/ custom repr / HTML / images, all chart types (asserting on the rawchartJSON), client-timeout → kernel interrupt, sandbox killed mid-execution, systemd recovery (commands.run("kill -9 …", user="root"), then poll/health), plus an async smoke subset. New HTTP-level checks the SDK suites couldn't express:/execute→ 400 oncontext_id+language, 404 on unknown context (also for restart/remove).Jupyter Unix-socket isolation (#343) is tested in a real sandbox instead of in-process on the runner:
test_jupyter_socket.pyasserts/run/e2b-jupyteris0700 rootandserver.sock0600 root,/api/statusanswers over the socket as root,usercannot connect (curl exit 7), and nothing listens on tcp8888(ss -ltn+connect_exfrom the kernel). Execution/interrupt over the socket is covered by the basic/interrupt tests, soserver_tests.yml,template/tests/,template/pytest.iniandtemplate/requirements-test.txtare removed.Deliberately not ported (SDK-internal behavior): sandbox URL resolution, timeout construction, exception formatting, NDJSON line-splitting utils,
Execution.to_json(), chart model deserialization. The suite is written once (sync) rather than duplicated sync/async, since the server is the unit under test. The matching upstream trim is e2b-dev/E2B#1956.CI: new
code_interpreter_tests.yml(reusable,run_recovery_testsswitch like the SDK workflow) wired intopull_request.ymlbetweenbuild-templateandcleanup-build-template;lint.ymlsyncstests/sopnpm run lint/formatcovers it (added topnpm-workspace.yaml).Verified locally: 86 tests pass against
code-interpreter-v1(uv run pytest -n 4, ~40s).Link to Devin session: https://app.devin.ai/sessions/6fd302f062cc459796016eba4e06d9e1
Open in Devin Desktop: https://app.devin.ai/desktop/session/6fd302f062cc459796016eba4e06d9e1?variant=devin
Requested by: @mishushakov