Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

test(js-sdk): remove unused integration test suite (#1591)

Mish Ushakovaa3c2593b996
diff --git a/packages/js-sdk/package.json b/packages/js-sdk/package.json
index 459061d06..e5e3db6e3 100644
--- a/packages/js-sdk/package.json
+++ b/packages/js-sdk/package.json
@@ -41,7 +41,6 @@
"test:cf": "vitest run --config tests/runtimes/cloudflare/vitest.config.mts",
"test:cf:deploy": "vitest run --config tests/runtimes/cloudflare-deploy/vitest.config.mts",
"test:deno": "deno run -A npm:vitest run --project unit --project connectionConfig",
- "test:integration": "E2B_INTEGRATION_TEST=1 vitest run tests/integration/**",
"typecheck": "tsc --noEmit",
"lint": "oxlint --config ../../.oxlintrc.json src tests",
"format": "prettier --write src/ tests/ example.mts"
diff --git a/packages/js-sdk/tests/integration/randomness.test.ts b/packages/js-sdk/tests/integration/randomness.test.ts
deleted file mode 100644
index a982eb31f..000000000
--- a/packages/js-sdk/tests/integration/randomness.test.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import { test, assert } from 'vitest'
-
-import Sandbox from '../../src/index.js'
-import { isIntegrationTest } from '../setup.js'
-
-const integrationTestTemplate = 'en716jw99aj63v1k8ugh'
-
-test.skipIf(!isIntegrationTest)(
- 'test python random number generation in same sandbox',
- async () => {
- const sbx = await Sandbox.create(integrationTestTemplate, {
- timeoutMs: 120,
- })
- console.log('sandboxId', sbx.sandboxId)
- const cmd1 = await sbx.commands.run(
- 'python -c "import numpy as np; print([np.random.normal(),np.random.normal(),np.random.normal()])"'
- )
- console.log('cmd1 stdout', cmd1.stdout)
-
- const cmd2 = await sbx.commands.run(
- 'python -c "import numpy as np; print([np.random.normal(),np.random.normal(),np.random.normal()])"'
- )
- console.log('cmd2 stdout', cmd2.stdout)
-
- assert.notEqual(cmd1.stdout, cmd2.stdout)
- }
-)
-
-test.skipIf(!isIntegrationTest)(
- 'test python random number generation with same template',
- async () => {
- const sbx = await Sandbox.create(integrationTestTemplate, {
- timeoutMs: 120,
- })
- console.log('sandboxId 1', sbx.sandboxId)
- const cmd1 = await sbx.commands.run(
- 'python -c "import numpy as np; print([np.random.normal(),np.random.normal(),np.random.normal()])"'
- )
- console.log('cmd1 stdout', cmd1.stdout)
- await sbx.kill()
-
- const sbx2 = await Sandbox.create(integrationTestTemplate, {
- timeoutMs: 120,
- })
- console.log('sandboxId 2', sbx2.sandboxId)
- const cmd2 = await sbx2.commands.run(
- 'python -c "import numpy as np; print([np.random.normal(),np.random.normal(),np.random.normal()])"'
- )
- console.log('cmd2 stdout', cmd2.stdout)
-
- assert.notEqual(cmd1.stdout, cmd2.stdout)
- }
-)
diff --git a/packages/js-sdk/tests/integration/stress.test.ts b/packages/js-sdk/tests/integration/stress.test.ts
deleted file mode 100644
index 83e4b0ddc..000000000
--- a/packages/js-sdk/tests/integration/stress.test.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import { test } from 'vitest'
-
-import Sandbox from '../../src/index.js'
-import { isIntegrationTest, wait } from '../setup.js'
-
-const heavyArray = new ArrayBuffer(256 * 1024 * 1024) // 256 MiB = 256 * 1024 * 1024 bytes
-const view = new Uint8Array(heavyArray)
-for (let i = 0; i < view.length; i++) {
- view[i] = Math.floor(Math.random() * 256)
-}
-
-const integrationTestTemplate = 'integration-test-v1'
-const sandboxCount = 10
-
-test.skipIf(!isIntegrationTest)(
- 'stress test heavy file writes and reads',
- async () => {
- const promises: Array<Promise<string | void>> = []
- for (let i = 0; i < sandboxCount; i++) {
- promises.push(
- Sandbox.create(integrationTestTemplate, { timeoutMs: 60 })
- .then((sbx) => {
- console.log(sbx.sandboxId)
- return sbx.files
- .write('heavy-file', heavyArray)
- .then(() => sbx.files.read('heavy-file'))
- })
- .catch(console.error)
- )
- }
- await wait(10_000)
- await Promise.all(promises)
- }
-)
-
-test.skipIf(!isIntegrationTest)('stress requests to nextjs app', async () => {
- const hostPromises: Array<Promise<string | void>> = []
-
- for (let i = 0; i < sandboxCount; i++) {
- hostPromises.push(
- Sandbox.create(integrationTestTemplate, { timeoutMs: 60_000 }).then(
- (sbx) => {
- console.log('created sandbox', sbx.sandboxId)
- return new Promise((resolve, reject) => {
- try {
- resolve(sbx.getHost(3000))
- } catch (e) {
- console.error('error getting sbx host', e)
- reject(e)
- }
- })
- }
- )
- )
- }
-
- await wait(10_000)
- const hosts = await Promise.all(hostPromises)
-
- const fetchPromises: Array<Promise<string | void>> = []
-
- for (let i = 0; i < 100; i++) {
- for (const host of hosts) {
- fetchPromises.push(
- new Promise((resolve) => {
- fetch('https://' + host)
- .then((res) => {
- console.log(`response for ${host}: ${res.status}`)
- })
- .then(resolve)
- })
- )
- }
- }
-
- await Promise.all(fetchPromises)
-})
diff --git a/packages/js-sdk/tests/integration/template/README.md b/packages/js-sdk/tests/integration/template/README.md
deleted file mode 100644
index 7da9296a3..000000000
--- a/packages/js-sdk/tests/integration/template/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Integration test template
-
-# Build the template
-
-`$ e2b template build -c "cd /basic-nextjs-app/ && sudo npm run dev"`
diff --git a/packages/js-sdk/tests/integration/template/e2b.Dockerfile b/packages/js-sdk/tests/integration/template/e2b.Dockerfile
deleted file mode 100644
index 1eb06dab6..000000000
--- a/packages/js-sdk/tests/integration/template/e2b.Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM e2bdev/code-interpreter:latest
-
-# Install stress-ng, a tool to load and stress computer systems
-RUN apt update
-RUN apt install -y stress-ng
-
-# Create a basic Next.js app
-RUN npx -y create-next-app@latest basic-nextjs-app --yes --ts --use-npm
-
-# Install dependencies
-RUN cd basic-nextjs-app && npm install
diff --git a/packages/js-sdk/tests/integration/template/e2b.toml b/packages/js-sdk/tests/integration/template/e2b.toml
deleted file mode 100644
index 3f3fd1c4b..000000000
--- a/packages/js-sdk/tests/integration/template/e2b.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-# This is a config for E2B sandbox template.
-# You can use template ID (2e2z80zhv34yumbrybvn) or template name (integration-test-v1) to create a sandbox:
-
-# Python SDK
-# from e2b import Sandbox, AsyncSandbox
-# sandbox = Sandbox("integration-test-v1") # Sync sandbox
-# sandbox = await AsyncSandbox.create("integration-test-v1") # Async sandbox
-
-# JS SDK
-# import { Sandbox } from 'e2b'
-# const sandbox = await Sandbox.create('integration-test-v1')
-
-team_id = "460355b3-4f64-48f9-9a16-4442817f79f5"
-memory_mb = 512
-start_cmd = "npm run dev"
-dockerfile = "e2b.Dockerfile"
-template_name = "integration-test-v1"
-template_id = "2e2z80zhv34yumbrybvn"
diff --git a/packages/js-sdk/tests/setup.ts b/packages/js-sdk/tests/setup.ts
index 45e15735c..e29c20eba 100644
--- a/packages/js-sdk/tests/setup.ts
+++ b/packages/js-sdk/tests/setup.ts
@@ -140,7 +140,6 @@ export const volumeTest = base
.skipIf(process.env.ENABLE_VOLUME_TESTS === undefined)
export const isDebug = process.env.E2B_DEBUG !== undefined
-export const isIntegrationTest = process.env.E2B_INTEGRATION_TEST !== undefined
/** Placeholder API key with a valid format for tests that don't hit the API. */
export const TEST_API_KEY = `e2b_${'0'.repeat(40)}`
diff --git a/packages/js-sdk/vitest.config.mts b/packages/js-sdk/vitest.config.mts
index ee1c73487..d770c91b0 100644
--- a/packages/js-sdk/vitest.config.mts
+++ b/packages/js-sdk/vitest.config.mts
@@ -12,7 +12,6 @@ export default defineConfig({
include: ['tests/**/*.test.ts'],
exclude: [
'tests/runtimes/**',
- 'tests/integration/**',
'tests/template/**',
'tests/connectionConfig.test.ts',
],
@@ -53,15 +52,6 @@ export default defineConfig({
},
},
},
- {
- test: {
- name: 'integration',
- include: ['tests/integration/**/*.test.ts'],
- globals: false,
- testTimeout: 60_000,
- environment: 'node',
- },
- },
{
test: {
name: 'template',