All checks were successful
deploy / deploy (push) Successful in 21s
Proof: Strategy and executor arm state now survives pod restarts through durable control-state files mounted in their service state directories. Assumptions: The strategy-state PVC can be seeded before the first rollout restart, and both service state directories remain writable on the cluster. Still fake: Armed-state durability is local to the cluster volumes; there is no cross-cluster or database-backed operator control-state replication.
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
|
|
import { createArmedStateStore } from '../src/core/armed-state-store.mjs';
|
|
|
|
test('armed state store persists arm changes across reload', () => {
|
|
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), 'unrip-armed-state-'));
|
|
const store = createArmedStateStore({
|
|
stateDir,
|
|
fileName: 'strategy-engine-control.json',
|
|
initialArmed: false,
|
|
});
|
|
|
|
assert.equal(store.isArmed(), false);
|
|
|
|
const armedState = store.setArmed(true);
|
|
assert.equal(armedState.armed, true);
|
|
assert.ok(armedState.updated_at);
|
|
|
|
const reloaded = createArmedStateStore({
|
|
stateDir,
|
|
fileName: 'strategy-engine-control.json',
|
|
initialArmed: false,
|
|
});
|
|
|
|
assert.equal(reloaded.isArmed(), true);
|
|
assert.equal(reloaded.getState().armed, true);
|
|
});
|
|
|
|
test('armed state store falls back to initial state when no persisted file exists', () => {
|
|
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), 'unrip-armed-state-default-'));
|
|
const store = createArmedStateStore({
|
|
stateDir,
|
|
fileName: 'trade-executor-control.json',
|
|
initialArmed: true,
|
|
});
|
|
|
|
assert.equal(store.isArmed(), true);
|
|
assert.equal(store.getState().updated_at, null);
|
|
});
|