fix(runtime): bound build memory and parallelism
This commit is contained in:
@@ -4,7 +4,11 @@ import assert from 'node:assert/strict';
|
||||
import { validateComposeModel } from '../runtime/validate-compose-model.mjs';
|
||||
|
||||
const safeRuntime = {
|
||||
environment: { CORE_SOURCE_MODE: 'clone' },
|
||||
environment: {
|
||||
CORE_SOURCE_MODE: 'clone',
|
||||
NODE_OPTIONS: '--max-old-space-size=1536',
|
||||
RAYON_NUM_THREADS: '2',
|
||||
},
|
||||
restart: 'unless-stopped',
|
||||
mem_limit: String(4 * 1024 * 1024 * 1024),
|
||||
memswap_limit: String(4 * 1024 * 1024 * 1024),
|
||||
@@ -21,7 +25,12 @@ test('accepts a literal, non-restarting development model', () => {
|
||||
services.runtime = {
|
||||
...safeRuntime,
|
||||
restart: 'no',
|
||||
environment: { CORE_SOURCE_MODE: 'bind', RUNTIME_MODE: 'development' },
|
||||
environment: {
|
||||
CORE_SOURCE_MODE: 'bind',
|
||||
RUNTIME_MODE: 'development',
|
||||
NODE_OPTIONS: '--max-old-space-size=1536',
|
||||
RAYON_NUM_THREADS: '2',
|
||||
},
|
||||
};
|
||||
assert.deepEqual(validateComposeModel({ services }, 'development'), []);
|
||||
});
|
||||
@@ -47,3 +56,17 @@ test('rejects an unbounded or production-mode development runtime', () => {
|
||||
assert.ok(errors.some((error) => error.includes('literal development')));
|
||||
assert.ok(errors.some((error) => error.includes('restart policy must be no')));
|
||||
});
|
||||
|
||||
test('rejects missing or excessive build memory and parallelism limits', () => {
|
||||
const runtime = {
|
||||
...safeRuntime,
|
||||
environment: {
|
||||
CORE_SOURCE_MODE: 'clone',
|
||||
NODE_OPTIONS: '--max-old-space-size=4096',
|
||||
RAYON_NUM_THREADS: '8',
|
||||
},
|
||||
};
|
||||
const errors = validateComposeModel({ services: { runtime } }, 'production');
|
||||
assert.ok(errors.some((error) => error.includes('Node heap limit')));
|
||||
assert.ok(errors.some((error) => error.includes('Rayon thread count')));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user