forked from wangziqi/gongxue-base
chore: gate production postgres tuning and taro handoff
This commit is contained in:
38
scripts/postgres-tuning-evidence-test.js
Normal file
38
scripts/postgres-tuning-evidence-test.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
const repoRoot = process.cwd();
|
||||
const scriptPath = path.join(repoRoot, 'scripts', 'postgres-tuning-evidence.js');
|
||||
|
||||
function run(args) {
|
||||
return spawnSync(process.execPath, [scriptPath, ...args], {
|
||||
cwd: repoRoot,
|
||||
encoding: 'utf8',
|
||||
env: {
|
||||
PATH: process.env.PATH || '',
|
||||
Path: process.env.Path || '',
|
||||
SystemRoot: process.env.SystemRoot || '',
|
||||
ComSpec: process.env.ComSpec || '',
|
||||
TEMP: process.env.TEMP || '',
|
||||
TMP: process.env.TMP || '',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const sharedSql = run(['--print-sql', '--profile=shared-host']);
|
||||
assert.equal(sharedSql.status, 0, sharedSql.stderr);
|
||||
assert.match(sharedSql.stdout, /alter system set shared_buffers = '3GB';/);
|
||||
assert.match(sharedSql.stdout, /alter system set statement_timeout = '30s';/);
|
||||
assert.match(sharedSql.stdout, /alter system set jit = 'off';/);
|
||||
|
||||
const dedicatedSql = run(['--print-sql', '--profile=dedicated-db']);
|
||||
assert.equal(dedicatedSql.status, 0, dedicatedSql.stderr);
|
||||
assert.match(dedicatedSql.stdout, /alter system set shared_buffers = '4GB';/);
|
||||
assert.match(dedicatedSql.stdout, /alter system set max_wal_size = '8GB';/);
|
||||
|
||||
const invalidProfile = run(['--print-sql', '--profile=unknown']);
|
||||
assert.notEqual(invalidProfile.status, 0, 'unknown profile should fail');
|
||||
assert.match(`${invalidProfile.stderr}${invalidProfile.stdout}`, /Unknown PostgreSQL tuning profile/);
|
||||
|
||||
console.log('[PASS] PostgreSQL tuning evidence helpers');
|
||||
Reference in New Issue
Block a user