diff --git a/js/tests/reconnect.test.ts b/js/tests/reconnect.test.ts index c80e3cf8..4699fcf1 100644 --- a/js/tests/reconnect.test.ts +++ b/js/tests/reconnect.test.ts @@ -1,9 +1,9 @@ import { expect } from 'vitest' import { Sandbox } from '../src' -import { sandboxTest } from './setup' +import { isDebug, sandboxTest } from './setup' -sandboxTest('reconnect', async ({ sandbox }) => { +sandboxTest.skipIf(isDebug)('reconnect', async ({ sandbox }) => { sandbox = await Sandbox.connect(sandbox.sandboxId) const result = await sandbox.runCode('x =1; x') diff --git a/js/tests/systemd.test.ts b/js/tests/systemd.test.ts index 76e75563..28f59398 100644 --- a/js/tests/systemd.test.ts +++ b/js/tests/systemd.test.ts @@ -1,5 +1,5 @@ import { expect } from 'vitest' -import { sandboxTest, wait } from './setup' +import { isDebug, sandboxTest, wait } from './setup' async function waitForHealth(sandbox: any, maxRetries = 10, intervalMs = 100) { for (let i = 0; i < maxRetries; i++) { @@ -18,50 +18,56 @@ async function waitForHealth(sandbox: any, maxRetries = 10, intervalMs = 100) { return false } -sandboxTest('restart after jupyter kill', async ({ sandbox }) => { - // Verify health is up initially - const initialHealth = await waitForHealth(sandbox) - expect(initialHealth).toBe(true) +sandboxTest.skipIf(isDebug)( + 'restart after jupyter kill', + async ({ sandbox }) => { + // Verify health is up initially + const initialHealth = await waitForHealth(sandbox) + expect(initialHealth).toBe(true) - // Kill the jupyter process as root - // The command handle may get killed too (since killing jupyter cascades to code-interpreter), - // so we catch the error. - try { - await sandbox.commands.run("kill -9 $(pgrep -f 'jupyter server')", { - user: 'root', - }) - } catch { - // Expected — the kill cascade may terminate the command handle - } + // Kill the jupyter process as root + // The command handle may get killed too (since killing jupyter cascades to code-interpreter), + // so we catch the error. + try { + await sandbox.commands.run("kill -9 $(pgrep -f 'jupyter server')", { + user: 'root', + }) + } catch { + // Expected — the kill cascade may terminate the command handle + } - // Wait for systemd to restart both services - const recovered = await waitForHealth(sandbox, 60, 500) - expect(recovered).toBe(true) + // Wait for systemd to restart both services + const recovered = await waitForHealth(sandbox, 60, 500) + expect(recovered).toBe(true) - // Verify code execution works after recovery - const result = await sandbox.runCode('x = 1; x') - expect(result.text).toEqual('1') -}) + // Verify code execution works after recovery + const result = await sandbox.runCode('x = 1; x') + expect(result.text).toEqual('1') + } +) -sandboxTest('restart after code-interpreter kill', async ({ sandbox }) => { - // Verify health is up initially - const initialHealth = await waitForHealth(sandbox) - expect(initialHealth).toBe(true) +sandboxTest.skipIf(isDebug)( + 'restart after code-interpreter kill', + async ({ sandbox }) => { + // Verify health is up initially + const initialHealth = await waitForHealth(sandbox) + expect(initialHealth).toBe(true) - // Kill the code-interpreter process as root - try { - await sandbox.commands.run("kill -9 $(pgrep -f 'uvicorn main:app')", { - user: 'root', - }) - } catch { - // Expected — killing code-interpreter may terminate the command handle - } + // Kill the code-interpreter process as root + try { + await sandbox.commands.run("kill -9 $(pgrep -f 'uvicorn main:app')", { + user: 'root', + }) + } catch { + // Expected — killing code-interpreter may terminate the command handle + } - // Wait for systemd to restart it and health to come back - const recovered = await waitForHealth(sandbox, 60, 500) - expect(recovered).toBe(true) + // Wait for systemd to restart it and health to come back + const recovered = await waitForHealth(sandbox, 60, 500) + expect(recovered).toBe(true) - // Verify code execution works after recovery - const result = await sandbox.runCode('x = 1; x') - expect(result.text).toEqual('1') -}) + // Verify code execution works after recovery + const result = await sandbox.runCode('x = 1; x') + expect(result.text).toEqual('1') + } +) diff --git a/python/tests/async/test_async_reconnect.py b/python/tests/async/test_async_reconnect.py index 9ed16f4a..6cd36c83 100644 --- a/python/tests/async/test_async_reconnect.py +++ b/python/tests/async/test_async_reconnect.py @@ -1,6 +1,9 @@ +import pytest + from e2b_code_interpreter.code_interpreter_async import AsyncSandbox +@pytest.mark.skip_debug async def test_reconnect(async_sandbox: AsyncSandbox): sandbox_id = async_sandbox.sandbox_id diff --git a/python/tests/async/test_async_systemd.py b/python/tests/async/test_async_systemd.py index 8a9f89ae..5a129abc 100644 --- a/python/tests/async/test_async_systemd.py +++ b/python/tests/async/test_async_systemd.py @@ -1,5 +1,7 @@ import asyncio +import pytest + from e2b_code_interpreter.code_interpreter_async import AsyncSandbox @@ -17,6 +19,7 @@ async def wait_for_health(sandbox: AsyncSandbox, max_retries=10, interval_ms=100 return False +@pytest.mark.skip_debug async def test_restart_after_jupyter_kill(async_sandbox: AsyncSandbox): # Verify health is up initially assert await wait_for_health(async_sandbox) @@ -39,6 +42,7 @@ async def test_restart_after_jupyter_kill(async_sandbox: AsyncSandbox): assert result.text == "1" +@pytest.mark.skip_debug async def test_restart_after_code_interpreter_kill(async_sandbox: AsyncSandbox): # Verify health is up initially assert await wait_for_health(async_sandbox) diff --git a/python/tests/sync/test_reconnect.py b/python/tests/sync/test_reconnect.py index 27800a84..f74b73de 100644 --- a/python/tests/sync/test_reconnect.py +++ b/python/tests/sync/test_reconnect.py @@ -1,6 +1,9 @@ +import pytest + from e2b_code_interpreter.code_interpreter_sync import Sandbox +@pytest.mark.skip_debug def test_reconnect(sandbox: Sandbox): sandbox_id = sandbox.sandbox_id diff --git a/python/tests/sync/test_systemd.py b/python/tests/sync/test_systemd.py index e6ccc256..574ed7d0 100644 --- a/python/tests/sync/test_systemd.py +++ b/python/tests/sync/test_systemd.py @@ -1,5 +1,7 @@ import time +import pytest + from e2b_code_interpreter.code_interpreter_sync import Sandbox @@ -17,6 +19,7 @@ def wait_for_health(sandbox: Sandbox, max_retries=10, interval_ms=100): return False +@pytest.mark.skip_debug def test_restart_after_jupyter_kill(sandbox: Sandbox): # Verify health is up initially assert wait_for_health(sandbox) @@ -37,6 +40,7 @@ def test_restart_after_jupyter_kill(sandbox: Sandbox): assert result.text == "1" +@pytest.mark.skip_debug def test_restart_after_code_interpreter_kill(sandbox: Sandbox): # Verify health is up initially assert wait_for_health(sandbox) diff --git a/template/template.py b/template/template.py index 63ec447a..9101636a 100644 --- a/template/template.py +++ b/template/template.py @@ -144,7 +144,7 @@ def make_template( template = template.set_user("user").set_workdir("/home/user") if is_docker: - start_cmd = "sudo /root/.jupyter/start-up.sh" + start_cmd = "sudo --preserve-env=E2B_LOCAL /root/.jupyter/start-up.sh" else: start_cmd = "sudo systemctl start jupyter"