Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
53ec99f
test(js-sdk): remove duplicate core unit and list tests
devin-ai-integration[bot] Oct 28, 2026
afcd76d
test(js-sdk): remove duplicate pty sendInput test
devin-ai-integration[bot] Oct 28, 2026
b3f8d3b
test(js-sdk): remove duplicate sandbox files tests
devin-ai-integration[bot] Oct 28, 2026
2af7e53
test(js-sdk): remove redundant sandbox signing, iam and config tests
devin-ai-integration[bot] Oct 28, 2026
3fd3f37
test(js-sdk): remove redundant template utils tests
devin-ai-integration[bot] Oct 28, 2026
ced8870
test(python-sdk): remove redundant unit tests
devin-ai-integration[bot] Oct 28, 2026
4d8bebd
test(python-sdk): remove redundant sandbox tests
devin-ai-integration[bot] Oct 28, 2026
05b53c7
test(python-sdk): drop empty network config dns test covered by creat…
devin-ai-integration[bot] Oct 28, 2026
fde611a
test(python-sdk): share from_dockerfile/to_dockerfile tests between s…
devin-ai-integration[bot] Oct 28, 2026
2ebfe16
test(python-sdk): share Secret.fill tests between sync and async
devin-ai-integration[bot] Oct 28, 2026
16beede
test(python-sdk): remove redundant transport and retry unit tests
devin-ai-integration[bot] Oct 28, 2026
c3e15d1
test(js-sdk): remove redundant volume tests
devin-ai-integration[bot] Oct 28, 2026
8cc3613
test(python-sdk): remove redundant volume tests
devin-ai-integration[bot] Oct 28, 2026
f3db97d
test(js-sdk): use Sandbox.pause instead of deprecated betaPause in ne…
devin-ai-integration[bot] Oct 30, 2026
96a4761
test: restore runtime-probed iam token validation tests
devin-ai-integration[bot] Oct 30, 2026
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
220 changes: 1 addition & 219 deletions packages/js-sdk/tests/api/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ sandboxTest.skipIf(isDebug)(
async ({ sandboxTestId }) => {
// Create and pause a sandbox
const extraSbx = await Sandbox.create({ metadata: { sandboxTestId } })
await extraSbx.betaPause()
await Sandbox.pause(extraSbx.sandboxId)

try {
const paginator = Sandbox.list({
Expand Down Expand Up @@ -298,221 +298,3 @@ sandboxTest.skipIf(isDebug)(
assert.equal(unknownSandboxes.length, 0)
}
)

sandboxTest.skipIf(isDebug)(
'list sandboxes',
async ({ sandbox, sandboxTestId }) => {
const paginator = Sandbox.list({
query: { metadata: { sandboxTestId } },
})
const sandboxes = await paginator.nextItems()

assert.isAtLeast(sandboxes.length, 1)

const found = sandboxes.some((s) => s.sandboxId === sandbox.sandboxId)
assert.isTrue(found)
}
)

sandboxTest.skipIf(isDebug)('list sandboxes with filter', async () => {
const uniqueId = crypto.randomUUID()
const extraSbx = await Sandbox.create({ metadata: { uniqueId } })

try {
const paginator = Sandbox.list({
query: { metadata: { uniqueId } },
})
const sandboxes = await paginator.nextItems()

assert.equal(sandboxes.length, 1)
assert.equal(sandboxes[0].sandboxId, extraSbx.sandboxId)
} finally {
await extraSbx.kill()
}
})

sandboxTest.skipIf(isDebug)(
'list running sandboxes',
async ({ sandboxTestId }) => {
const extraSbx = await Sandbox.create({ metadata: { sandboxTestId } })

try {
const paginator = Sandbox.list({
query: { metadata: { sandboxTestId }, state: ['running'] },
})
const sandboxes = await paginator.nextItems()

assert.isAtLeast(sandboxes.length, 1)

// Verify our running sandbox is in the list
const found = sandboxes.some(
(s) => s.sandboxId === extraSbx.sandboxId && s.state === 'running'
)
assert.isTrue(found)
} finally {
await extraSbx.kill()
}
}
)

sandboxTest.skipIf(isDebug)(
'list paused sandboxes',
async ({ sandboxTestId }) => {
// Create and pause a sandbox
const extraSbx = await Sandbox.create({ metadata: { sandboxTestId } })
await Sandbox.betaPause(extraSbx.sandboxId)

try {
const paginator = Sandbox.list({
query: { metadata: { sandboxTestId }, state: ['paused'] },
})
const sandboxes = await paginator.nextItems()

assert.isAtLeast(sandboxes.length, 1)

// Verify our paused sandbox is in the list
const found = sandboxes.some(
(s) => s.sandboxId === extraSbx.sandboxId && s.state === 'paused'
)
assert.isTrue(found)
} finally {
await extraSbx.kill()
}
}
)

sandboxTest.skipIf(isDebug)(
'paginate running sandboxes',
async ({ sandbox, sandboxTestId }) => {
// Create extra sandboxes
const extraSbx = await Sandbox.create({ metadata: { sandboxTestId } })

try {
// Test pagination with limit
const paginator = Sandbox.list({
limit: 1,
query: { metadata: { sandboxTestId }, state: ['running'] },
})
const sandboxes = await paginator.nextItems()

// Check first page
assert.equal(sandboxes.length, 1)
assert.equal(sandboxes[0].state, 'running')
assert.isTrue(paginator.hasNext)
assert.notEqual(paginator.nextToken, undefined)
assert.equal(sandboxes[0].sandboxId, extraSbx.sandboxId)

// Get second page
const sandboxes2 = await paginator.nextItems()

// Check second page
assert.equal(sandboxes2.length, 1)
assert.equal(sandboxes2[0].state, 'running')
assert.isFalse(paginator.hasNext)
assert.equal(paginator.nextToken, undefined)
assert.equal(sandboxes2[0].sandboxId, sandbox.sandboxId)
} finally {
await extraSbx.kill()
}
}
)

sandboxTest.skipIf(isDebug)(
'paginate paused sandboxes',
async ({ sandbox, sandboxTestId }) => {
await Sandbox.betaPause(sandbox.sandboxId)

// Create extra paused sandbox
const extraSbx = await Sandbox.create({ metadata: { sandboxTestId } })
await Sandbox.betaPause(extraSbx.sandboxId)

try {
// Test pagination with limit
const paginator = Sandbox.list({
limit: 1,
query: { metadata: { sandboxTestId }, state: ['paused'] },
})
const sandboxes = await paginator.nextItems()

// Check first page
assert.equal(sandboxes.length, 1)
assert.equal(sandboxes[0].state, 'paused')
assert.isTrue(paginator.hasNext)
assert.notEqual(paginator.nextToken, undefined)
assert.equal(sandboxes[0].sandboxId, extraSbx.sandboxId)

// Get second page
const sandboxes2 = await paginator.nextItems()

// Check second page
assert.equal(sandboxes2.length, 1)
assert.equal(sandboxes2[0].state, 'paused')
assert.isFalse(paginator.hasNext)
assert.equal(paginator.nextToken, undefined)
assert.equal(sandboxes2[0].sandboxId, sandbox.sandboxId)
} finally {
await extraSbx.kill()
}
}
)

sandboxTest.skipIf(isDebug)(
'paginate running and paused sandboxes',
async ({ sandbox, sandboxTestId }) => {
// Create extra sandbox
const extraSbx = await Sandbox.create({ metadata: { sandboxTestId } })

// Pause the extra sandbox
await Sandbox.betaPause(sandbox.sandboxId)

try {
// Test pagination with limit
const paginator = Sandbox.list({
limit: 1,
query: {
metadata: { sandboxTestId },
state: ['running', 'paused'],
},
})
const sandboxes = await paginator.nextItems()

// Check first page
assert.equal(sandboxes.length, 1)
assert.equal(sandboxes[0].state, 'running')

assert.isTrue(paginator.hasNext)
assert.notEqual(paginator.nextToken, undefined)
assert.equal(sandboxes[0].sandboxId, extraSbx.sandboxId)

// Get second page
const sandboxes2 = await paginator.nextItems()

// Check second page
assert.equal(sandboxes2.length, 1)
assert.equal(sandboxes2[0].state, 'paused')
assert.isFalse(paginator.hasNext)
assert.equal(paginator.nextToken, undefined)
assert.equal(sandboxes2[0].sandboxId, sandbox.sandboxId)
} finally {
await extraSbx.kill()
}
}
)

sandboxTest.skipIf(isDebug)(
'paginate iterator',
async ({ sandbox, sandboxTestId }) => {
const paginator = Sandbox.list({
query: { metadata: { sandboxTestId } },
})
const sandboxes: SandboxInfo[] = []

while (paginator.hasNext) {
const sbxs = await paginator.nextItems()
sandboxes.push(...sbxs)
}

assert.isAtLeast(sandboxes.length, 1)
assert.isTrue(sandboxes.some((s) => s.sandboxId === sandbox.sandboxId))
}
)
6 changes: 0 additions & 6 deletions packages/js-sdk/tests/connectionConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,6 @@ test('setupRequestController clearStartTimeout stops the handshake timer', async
assert.equal(controller.signal.aborted, false)
})

test('setupRequestController handshake timer aborts when not cleared', async () => {
const { controller } = setupRequestController(20, undefined)
await new Promise((resolve) => setTimeout(resolve, 40))
assert.equal(controller.signal.aborted, true)
})

test('setupRequestController handshake timeout aborts with TimeoutError reason', async () => {
const { controller } = setupRequestController(20, undefined)
await new Promise((resolve) => setTimeout(resolve, 40))
Expand Down
31 changes: 2 additions & 29 deletions packages/js-sdk/tests/envd/handleRpcError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ function neverProbe(): Promise<boolean | undefined> {
throw new Error('health check should not run')
}

describe('Unavailable with the sandbox not found', () => {
test('returns SandboxNotRunningError, not SandboxNotFoundError, from every call', () => {
const err = handleRpcError(
new ConnectError('The sandbox was not found', Code.Unavailable)
)
assert.instanceOf(err, SandboxNotRunningError)
assert.notInstanceOf(err, SandboxNotFoundError)
})
})

describe('ambiguous Unavailable', () => {
test('is an Unavailable that says neither not found nor port not open', () => {
assert.isTrue(
Expand Down Expand Up @@ -148,6 +138,7 @@ describe('handleRpcError', () => {
test('returns SandboxUnreachableError for Unavailable with the sandbox running but its port closed', () => {
const err = handleRpcError(new ConnectError(PORT_CLOSED, Code.Unavailable))
assert.instanceOf(err, SandboxUnreachableError)
assert.notInstanceOf(err, SandboxNotRunningError)
assert.include(err.message, 'could not be reached')
})

Expand All @@ -157,16 +148,11 @@ describe('handleRpcError', () => {
)
assert.instanceOf(err, SandboxNotRunningError)
assert.instanceOf(err, TimeoutError)
assert.notInstanceOf(err, SandboxNotFoundError)
assert.notInstanceOf(err, SandboxUnreachableError)
assert.include(err.message, 'The sandbox was not found')
})

test('returns SandboxUnreachableError, not SandboxNotRunningError, for Unavailable with the port closed', () => {
const err = handleRpcError(new ConnectError(PORT_CLOSED, Code.Unavailable))
assert.instanceOf(err, SandboxUnreachableError)
assert.notInstanceOf(err, SandboxNotRunningError)
})

test('returns TimeoutError for Unavailable', () => {
const err = handleRpcError(new ConnectError('gone', Code.Unavailable))
assert.instanceOf(err, TimeoutError)
Expand Down Expand Up @@ -203,19 +189,6 @@ describe('handleRpcErrorWithHealthCheck', () => {
Browser: 'network error',
}

test('does not probe health on an Unavailable for the sandbox not found', async () => {
let probed = false
const err = await handleRpcErrorWithHealthCheck(
new ConnectError('The sandbox was not found', Code.Unavailable),
async () => {
probed = true
return true
}
)
assert.isFalse(probed)
assert.instanceOf(err, SandboxNotRunningError)
})

test('returns a SandboxNotRunningError when the health check says the sandbox is not running', async () => {
const original = terminated()
const err = await handleRpcErrorWithHealthCheck(original, async () => false)
Expand Down
22 changes: 0 additions & 22 deletions packages/js-sdk/tests/envd/http2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,28 +193,6 @@ test('passes Request objects to undici as URL plus init', async () => {
expect(requests[0].init?.body).toBeInstanceOf(ReadableStream)
})

test('can create a bounded dispatcher for RPC streams', async () => {
const agents: Array<{ allowH2?: boolean; connections?: number }> = []

class Agent {
constructor(options: { allowH2?: boolean; connections?: number }) {
agents.push(options)
}
}

const undiciFetch = vi.fn(() => Promise.resolve(new Response('ok')))

const { createEnvdFetchForRuntime } = await import('../../src/envd/http2')

const fetcher = createEnvdFetchForRuntime('node', {
connectionLimit: 100,
loadUndici: () => Promise.resolve({ Agent, fetch: undiciFetch }),
})
await fetcher('https://example.com/rpc')

expect(agents).toEqual([{ allowH2: true, connections: 100 }])
})

test('reads RPC stream dispatcher connection limit from env', async () => {
process.env.E2B_ENVD_RPC_CONNECTIONS = '200'

Expand Down
41 changes: 0 additions & 41 deletions packages/js-sdk/tests/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,47 +339,6 @@ test.each([
}
)

test('retries a POST when the server marks a 503', async () => {
const statuses = [503, 200]
const fetchImpl = vi.fn(async () => {
const responseStatus = statuses.shift()!
return new Response(null, {
status: responseStatus,
headers: responseStatus === 200 ? {} : { 'Should-Retry': 'true' },
})
}) as typeof fetch
const fetchWithRetry = withRetry(fetchImpl, 3, 60_000, {
monotonic: () => 0,
sleep: async () => {},
})

const response = await fetchWithRetry('https://api.e2b.test/sandboxes', {
method: 'POST',
})

expect(response.status).toBe(200)
expect(fetchImpl).toHaveBeenCalledTimes(2)
})

test('retries a POST 502 without Should-Retry', async () => {
const responses = [
new Response(null, { status: 502, headers: { 'Retry-After': '0' } }),
new Response('ok'),
]
const fetchImpl = vi.fn(async () => responses.shift()!) as typeof fetch
const fetchWithRetry = withRetry(fetchImpl, 1, 10_000, {
monotonic: () => 0,
sleep: async () => {},
})

const response = await fetchWithRetry('https://api.e2b.test/v2/sandboxes', {
method: 'POST',
})

expect(response.status).toBe(200)
expect(fetchImpl).toHaveBeenCalledTimes(2)
})

test('caps the backoff for long retry sequences', async () => {
const fetchImpl = vi.fn(
async () =>
Expand Down
8 changes: 0 additions & 8 deletions packages/js-sdk/tests/sandbox/configPropagation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ describe('Sandbox API config propagation', () => {
assert.equal(opts?.headers?.['X-Test'], baseConfig.apiHeaders['X-Test'])
})

test('accepts apiHeaders in static Sandbox API options', () => {
const opts = { apiHeaders: baseConfig.apiHeaders } satisfies Parameters<
typeof Sandbox.kill
>[1]

assert.equal(opts.apiHeaders['X-Test'], baseConfig.apiHeaders['X-Test'])
})

test('lets public method call overrides win over connectionConfig', async () => {
const pauseSpy = vi.spyOn(SandboxApi, 'pause').mockResolvedValue(true)
const sandbox = createSandbox()
Expand Down
Loading
Loading