11 lines
2.4 KiB
JavaScript
11 lines
2.4 KiB
JavaScript
import fs from 'node:fs';import assert from 'node:assert/strict';import {spawnSync} from 'node:child_process';import {session} from './sgf-single-http.mjs';
|
|
const php='C:/laragon/tools/sgf-tempo/php-8.4.27/php.exe',node='C:/laragon/tools/sgf-tempo/node-v24.22.1-win-arm64/node.exe';const run=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),root=run.root+'/private/receipt-composition-cc50a276c10c';
|
|
const call=(exe,args)=>{const r=spawnSync(exe,args,{cwd:process.cwd(),encoding:'utf8',windowsHide:true});assert.equal(r.status,0,'Existing application lifecycle operation failed');return r.stdout;};
|
|
const snapshot=()=>{const result=JSON.parse(call(php,['scripts/sgf-runtime-snapshot.php']));assert.equal(result.passed,true);return result.snapshot;};
|
|
const before=snapshot(),oldServer=JSON.parse(fs.readFileSync(root+'/demo-server.json'));assert.equal(before.native.gl_journals.records,16);assert.equal(before.native.stock_movements.records,4);
|
|
call('powershell.exe',['-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-File','scripts/stop-selected-sgf-server.ps1']);
|
|
const launch=JSON.parse(call(node,['scripts/launch-sgf.mjs','start']).trim());assert.equal(launch.same_installation,true);const server=JSON.parse(fs.readFileSync(root+'/demo-server.json'));assert.notEqual(server.pid,oldServer.pid);assert.equal(server.port,8085);
|
|
const s=await session('sgf:read_only','accounting');let r=await s.get('/api/general-ledger');assert.equal(r.status,200);const ledger=await r.json();assert.equal(ledger.journals.length,16);assert.equal(ledger.chart_accounts.length,14);assert.equal(ledger.stock[0].physical_balance_milli,1500);
|
|
r=await s.get('/api/v1/integration/sgc/invoices');assert.equal(r.status,404);await r.text();const after=snapshot();assert.deepEqual(after,before,'All29 canonical tables retain exact records across restart and authenticated reads');
|
|
const proof=root+'/single-restart-proof-20261110.json';fs.writeFileSync(proof,JSON.stringify({passed:true,before,after,old_pid:oldServer.pid,new_pid:server.pid,same_port:8085,canonical_tables_compared:29,authenticated_after_restart:true,journals:16,stock_balance_milli:1500,sgc_gateway_absent:true,postgres_cluster_stopped:false,other_servers_stopped:false,cache_cleared:false,full_operating_system_reboot_tested:false},null,2));console.log(JSON.stringify({passed:true,same_port:8085,canonical_tables:29,proof}));
|