From 2c3c82f7bbdcc7021ee01a6a6d8901d27db659e5 Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Thu, 2 Oct 2025 10:17:59 +0200 Subject: [PATCH 1/3] Use ms in sandbox --- tests/periodic-test/time-is-synchronized/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/periodic-test/time-is-synchronized/index.ts b/tests/periodic-test/time-is-synchronized/index.ts index feaf44a0ed..45f7f89c2d 100644 --- a/tests/periodic-test/time-is-synchronized/index.ts +++ b/tests/periodic-test/time-is-synchronized/index.ts @@ -88,11 +88,11 @@ try { console.log("ℹ️ starting command"); const localDate = new Date().getTime() / 1000; - const date = await sandbox.commands.run("date +%s"); + const date = await sandbox.commands.run("date +%s%3N"); console.log("localDate", localDate); console.log("date", date.stdout); - const dateUnix = parseInt(date.stdout); + const dateUnix = parseFloat(date.stdout) / 1000; console.log("ℹ️ comparing dates", dateUnix, localDate); // compare the dates, should be within 1 second From 41f01fccf2157273b4e94f0ae9de94962a54a28d Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Thu, 2 Oct 2025 10:18:06 +0200 Subject: [PATCH 2/3] Increase the times --- .../time-is-synchronized/index.ts | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/tests/periodic-test/time-is-synchronized/index.ts b/tests/periodic-test/time-is-synchronized/index.ts index 45f7f89c2d..815d08029b 100644 --- a/tests/periodic-test/time-is-synchronized/index.ts +++ b/tests/periodic-test/time-is-synchronized/index.ts @@ -70,8 +70,8 @@ if (!templateID) { throw new Error("❌ Template ID not found in e2b.toml"); } -// sleep for 5 seconds to create a time delta -await new Promise((resolve) => setTimeout(resolve, 5000)); +// sleep for 15 seconds to create a time delta +await new Promise((resolve) => setTimeout(resolve, 15000)); try { // remove the file to make script idempotent in local testing @@ -95,8 +95,8 @@ try { const dateUnix = parseFloat(date.stdout) / 1000; console.log("ℹ️ comparing dates", dateUnix, localDate); - // compare the dates, should be within 1 second - if (Math.abs(dateUnix - localDate) > 1) { + // compare the dates, should be within 2 second + if (Math.abs(dateUnix - localDate) > 2) { throw new Error("❌ Date is not synchronized"); } @@ -108,18 +108,4 @@ try { console.error("Error while running sandbox or commands", e); throw e; } finally { - // delete template - const output = await streamCommandOutput("deno", [ - "run", - "--allow-all", - "@e2b/cli", - "template", - "delete", - "-y", - templateID, - ]); - - if (output.status.code !== 0) { - throw new Error(`❌ Delete failed with code ${output.status.code}`); - } } From eac2d7ef0ee4be2c8b8ea7dfc88832530da3e647 Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Thu, 2 Oct 2025 10:21:38 +0200 Subject: [PATCH 3/3] Revert deletion --- tests/periodic-test/time-is-synchronized/index.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/periodic-test/time-is-synchronized/index.ts b/tests/periodic-test/time-is-synchronized/index.ts index 815d08029b..22547f81c5 100644 --- a/tests/periodic-test/time-is-synchronized/index.ts +++ b/tests/periodic-test/time-is-synchronized/index.ts @@ -107,5 +107,18 @@ try { } catch (e) { console.error("Error while running sandbox or commands", e); throw e; -} finally { +} finally { // delete template + const output = await streamCommandOutput("deno", [ + "run", + "--allow-all", + "@e2b/cli", + "template", + "delete", + "-y", + templateID, + ]); + + if (output.status.code !== 0) { + throw new Error(`❌ Delete failed with code ${output.status.code}`); + } }