From 86e3c05b0cd1f260d2078fdc6cea6f7c216a3ed6 Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Wed, 11 Jun 2025 11:51:15 -0400 Subject: [PATCH 1/5] Use more verbose failure in get-vcpu-ms test --- integration-tests/js-compute/fixtures/app/src/compute.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-tests/js-compute/fixtures/app/src/compute.js b/integration-tests/js-compute/fixtures/app/src/compute.js index 86f2c34edd..eb6e9f63fe 100644 --- a/integration-tests/js-compute/fixtures/app/src/compute.js +++ b/integration-tests/js-compute/fixtures/app/src/compute.js @@ -5,8 +5,8 @@ import { purgeSurrogateKey, vCpuTime } from 'fastly:compute'; routes.set('/compute/get-vcpu-ms', () => { const cpuTime = vCpuTime(); strictEqual(typeof cpuTime, 'number'); - ok(cpuTime > 0); - ok(cpuTime < 3000); + ok(cpuTime > 0, "cpuTime > 0"); + ok(cpuTime < 3000, "cputime < 3000"); const arr = new Array(100_000).fill(1); for (let j = 1; j < 100; j++) { for (let i = 1; i < 100_000; i++) { @@ -14,8 +14,8 @@ routes.set('/compute/get-vcpu-ms', () => { } } const cpuTime2 = vCpuTime(); - ok(cpuTime2 > cpuTime); - ok(cpuTime2 - cpuTime > 1); + ok(cpuTime2 > cpuTime, "cpuTime2 > cpuTime"); + ok(cpuTime2 - cpuTime > 1, "cpuTime2 - cpuTime > 1"); return pass('ok'); }); From 2027609b9638f85c5c633561769e5a9a15a0b3fc Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Wed, 11 Jun 2025 12:03:42 -0400 Subject: [PATCH 2/5] Formatting fixes --- integration-tests/js-compute/fixtures/app/src/compute.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-tests/js-compute/fixtures/app/src/compute.js b/integration-tests/js-compute/fixtures/app/src/compute.js index eb6e9f63fe..239aa25339 100644 --- a/integration-tests/js-compute/fixtures/app/src/compute.js +++ b/integration-tests/js-compute/fixtures/app/src/compute.js @@ -5,8 +5,8 @@ import { purgeSurrogateKey, vCpuTime } from 'fastly:compute'; routes.set('/compute/get-vcpu-ms', () => { const cpuTime = vCpuTime(); strictEqual(typeof cpuTime, 'number'); - ok(cpuTime > 0, "cpuTime > 0"); - ok(cpuTime < 3000, "cputime < 3000"); + ok(cpuTime > 0, 'cpuTime > 0'); + ok(cpuTime < 3000, 'cputime < 3000'); const arr = new Array(100_000).fill(1); for (let j = 1; j < 100; j++) { for (let i = 1; i < 100_000; i++) { @@ -14,8 +14,8 @@ routes.set('/compute/get-vcpu-ms', () => { } } const cpuTime2 = vCpuTime(); - ok(cpuTime2 > cpuTime, "cpuTime2 > cpuTime"); - ok(cpuTime2 - cpuTime > 1, "cpuTime2 - cpuTime > 1"); + ok(cpuTime2 > cpuTime, 'cpuTime2 > cpuTime'); + ok(cpuTime2 - cpuTime > 1, 'cpuTime2 - cpuTime > 1'); return pass('ok'); }); From 00dcc2c5dd6c46a08eb958b82decc051c910747a Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Wed, 11 Jun 2025 12:37:10 -0400 Subject: [PATCH 3/5] Fix spacing around truthy debug message --- integration-tests/js-compute/fixtures/app/src/assertions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/js-compute/fixtures/app/src/assertions.js b/integration-tests/js-compute/fixtures/app/src/assertions.js index 48b1727172..f747c89bfa 100644 --- a/integration-tests/js-compute/fixtures/app/src/assertions.js +++ b/integration-tests/js-compute/fixtures/app/src/assertions.js @@ -55,7 +55,7 @@ export { assert as strictEqual }; export function ok(truthy, code) { if (!truthy) { throw new Error( - `Expected ${code ? ' ' + code : ''}to be truthy - Found \`${JSON.stringify(prettyPrintSymbol(truthy))}\``, + `Expected ${code ? code + ' ' : ''}to be truthy - Found \`${JSON.stringify(prettyPrintSymbol(truthy))}\``, ); } } From 477a699bc76afe16cbe6696c4b326b1c08fd1e74 Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Wed, 11 Jun 2025 12:40:18 -0400 Subject: [PATCH 4/5] Weaken assertion around vCPU startup time: >=0, not >0 As the comment says, if we're doing _well_ we may have not accumulated a full millisecond of startup time. --- integration-tests/js-compute/fixtures/app/src/compute.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration-tests/js-compute/fixtures/app/src/compute.js b/integration-tests/js-compute/fixtures/app/src/compute.js index 239aa25339..8956bf32ac 100644 --- a/integration-tests/js-compute/fixtures/app/src/compute.js +++ b/integration-tests/js-compute/fixtures/app/src/compute.js @@ -5,7 +5,9 @@ import { purgeSurrogateKey, vCpuTime } from 'fastly:compute'; routes.set('/compute/get-vcpu-ms', () => { const cpuTime = vCpuTime(); strictEqual(typeof cpuTime, 'number'); - ok(cpuTime > 0, 'cpuTime > 0'); + // We can't assert > 0; this only claims millisecond resolution, + // and we hopefully spent less than 500us starting. + ok(cpuTime >= 0, 'cpuTime > 0'); ok(cpuTime < 3000, 'cputime < 3000'); const arr = new Array(100_000).fill(1); for (let j = 1; j < 100; j++) { From f03c193ebcb40f27bf4e0ad0866e48959263ed45 Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Wed, 11 Jun 2025 14:03:55 -0400 Subject: [PATCH 5/5] Fix debug condition in integration-tests/js-compute/fixtures/app/src/compute.js Co-authored-by: Dan Gohman --- integration-tests/js-compute/fixtures/app/src/compute.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/js-compute/fixtures/app/src/compute.js b/integration-tests/js-compute/fixtures/app/src/compute.js index 8956bf32ac..504453e6d1 100644 --- a/integration-tests/js-compute/fixtures/app/src/compute.js +++ b/integration-tests/js-compute/fixtures/app/src/compute.js @@ -7,7 +7,7 @@ routes.set('/compute/get-vcpu-ms', () => { strictEqual(typeof cpuTime, 'number'); // We can't assert > 0; this only claims millisecond resolution, // and we hopefully spent less than 500us starting. - ok(cpuTime >= 0, 'cpuTime > 0'); + ok(cpuTime >= 0, 'cpuTime >= 0'); ok(cpuTime < 3000, 'cputime < 3000'); const arr = new Array(100_000).fill(1); for (let j = 1; j < 100; j++) {