diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-12 17:23:34 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:16 -0300 |
| commit | 9dd6f001c7d5eee987cbd305a79d1b1d011b83f5 (patch) | |
| tree | 2ec5b20565b162b54cdfef9ae5d8fec0e57dfb54 /test | |
| parent | 7a07e24916cd5bc762996d81aa1faf550177cd6f (diff) | |
| download | cloud9-9dd6f001c7d5eee987cbd305a79d1b1d011b83f5.tar.gz cloud9-9dd6f001c7d5eee987cbd305a79d1b1d011b83f5.zip | |
Reserve output space for an async completion plus the already-dispatched synchronous handler. Wait on a condition without the catalogue mutex, preserving cancellation and connection-slot lifetime. Abort HTTP streaming on an upstream error instead of hiding a truncated response.
Reproduced the former failure with concurrent live cafe assets. Add exact-hash load checks with 16 readers, mixed HEAD and 40 interrupted downloads; validate 80 multi-frame responses over 37 live files. All five live sites, mounted 9P browsing, protocol/catalogue/host/HTTP/mux/UI tests and 32 original E2E scenarios pass. Deploy corrected service on sole [::]:8090. See docs/namespace-sites-validation.md.
Diffstat (limited to 'test')
| -rw-r--r-- | test/web/catalog_ui.mjs | 4 | ||||
| -rw-r--r-- | test/web/parallel_reads.mjs | 44 |
2 files changed, 48 insertions, 0 deletions
diff --git a/test/web/catalog_ui.mjs b/test/web/catalog_ui.mjs index 9f4aca5..32fb2ad 100644 --- a/test/web/catalog_ui.mjs +++ b/test/web/catalog_ui.mjs @@ -47,6 +47,7 @@ async function readySites() { await wait(() => evaluate(`document.querySelectorA try { const root = path.join(work, 'public'); await fs.mkdir(root); await fs.writeFile(path.join(root, 'index.html'), '<h1>Fixture</h1>'); + await fs.writeFile(path.join(root, 'large.bin'), Buffer.alloc(512000, 0xa5)); await fs.writeFile(path.join(work, 'large.txt'), 'x'.repeat(180000)); const dashboard = await port(), debugPort = await port(); const runtime = path.join(work, 'runtime'); @@ -58,6 +59,9 @@ try { const web = startWeb(); const url = `http://127.0.0.1:${dashboard}`; await wait(async () => (await fetch(url)).ok, 'server ready'); + const concurrent = start(process.execPath, ['test/web/parallel_reads.mjs', url + '/sites/fixture/', root]); + const [parallelCode] = await once(concurrent, 'exit'); + assert.equal(parallelCode, 0, concurrent.output); assert.equal((await (await fetch(url + '/_cloud9/config.json')).json()).catalog, true); assert.equal((await fetch(url + '/_cloud9/catalog.js')).status, 404, 'standalone JS removed'); start(process.env.CLOUD9_CHROME || 'google-chrome-stable', ['--headless=new', '--no-sandbox', '--disable-dev-shm-usage', '--no-first-run', '--no-default-browser-check', `--user-data-dir=${work}/chrome`, `--remote-debugging-port=${debugPort}`, 'about:blank']); diff --git a/test/web/parallel_reads.mjs b/test/web/parallel_reads.mjs new file mode 100644 index 0000000..a95976b --- /dev/null +++ b/test/web/parallel_reads.mjs @@ -0,0 +1,44 @@ +// Read-only stress check: concurrent multi-frame website reads must be exact. +import assert from 'node:assert/strict'; +import fs from 'node:fs/promises'; +import path from 'node:path'; +import { createHash } from 'node:crypto'; + +const [base, root] = process.argv.slice(2); +if (!base || !root) throw new Error('usage: node parallel_reads.mjs URL DIRECTORY'); +const hash = bytes => createHash('sha256').update(bytes).digest('hex'); +const fileUrl = name => base.replace(/\/$/, '') + '/' + name.split(path.sep).map(encodeURIComponent).join('/'); +const files = []; +async function collect(dir, rel = '') { + for (const entry of await fs.readdir(dir, { withFileTypes: true })) { + const name = path.join(rel, entry.name), full = path.join(dir, entry.name); + if (entry.isDirectory()) await collect(full, name); + else if (entry.isFile()) { + const bytes = await fs.readFile(full); + if (bytes.length >= 65536) files.push({ name, size: bytes.length, hash: hash(bytes) }); + } + } +} +await collect(root); +assert.ok(files.length > 0, 'need at least one multi-frame file'); +for (let round = 0; round < 5; round++) { + const reads = Array.from({ length: 16 }, async (_, i) => { + const file = files[(round * 16 + i) % files.length]; + const response = await fetch(fileUrl(file.name)); + assert.equal(response.status, 200, file.name); + const bytes = Buffer.from(await response.arrayBuffer()); + assert.equal(bytes.length, file.size, `truncated: ${file.name}`); + assert.equal(hash(bytes), file.hash, `corrupt: ${file.name}`); + }); + // Mix synchronous stats with reads, and abandon owned responses midway. + const canceled = Array.from({ length: 8 }, async (_, i) => { + const response = await fetch(fileUrl(files[i % files.length].name)); + assert.equal(response.status, 200); + const reader = response.body.getReader(); + await reader.read(); + await reader.cancel(); + }); + const head = fetch(fileUrl(files[0].name), { method: 'HEAD' }).then(r => assert.equal(r.status, 200)); + await Promise.all([...reads, ...canceled, head]); +} +console.log(`parallel_reads: 80 exact multi-frame responses, 16 concurrent, 40 cancellations and mixed HEAD (${files.length} source files)`); |
