Unify trunk on main: initialization → main #3
@@ -340,3 +340,47 @@ test("a machine keeps what it was given when the mesh says nothing about it", {
|
||||
assert.ok((await on("laptop", `grep -q anchor.internal /etc/hosts`)).ok,
|
||||
"the mesh's names are gone");
|
||||
});
|
||||
|
||||
test("a machine that fell behind catches up without being named", { skip, timeout: 900_000 }, async () => {
|
||||
// `status` says which machines are not doing what they were told; something has to act on it.
|
||||
// `push --behind` is that something, and it is a command rather than a timer to begin with —
|
||||
// a scheduler is then a scheduler over this, rather than a second path to the same act.
|
||||
|
||||
// Break one machine, in a way that is fixable: a package that does not exist yet.
|
||||
await must("anchor", `printf %s '{"module":"fixable","version":"1","resources":[` +
|
||||
`{"id":"pkg","type":"package","package":"a-package-that-does-not-exist-yet"},` +
|
||||
`{"id":"note","type":"file","path":"/etc/mesh-fixable","content":"here"}]}' > /tmp/fix.json`);
|
||||
await must("anchor", `docker cp /tmp/fix.json mesh-control:/fix.json`);
|
||||
await mesh("module add /fix.json");
|
||||
await mesh("assign laptop fixable");
|
||||
await mesh("push laptop");
|
||||
await new Promise((r) => setTimeout(r, 8000));
|
||||
|
||||
assert.match(await mesh("status"), /laptop\s+failed/, "the machine did not report a failure");
|
||||
// And the resources that COULD be applied were — one broken thing no longer blocks the rest
|
||||
// (novox/hq 04-ISSUES/011).
|
||||
assert.ok((await on("laptop", `test -f /etc/mesh-fixable`)).ok,
|
||||
"a resource after the failing one was never attempted");
|
||||
|
||||
// Nothing is behind on the other machine, so nothing is pushed to it.
|
||||
const named = await mesh("push --behind");
|
||||
assert.match(named, /laptop/, named);
|
||||
assert.doesNotMatch(named, /sent anchor/, `a machine that was fine was pushed to:\n${named}`);
|
||||
|
||||
// Fix the cause, the way somebody would: the module stops asking for the impossible thing.
|
||||
await must("anchor", `printf %s '{"module":"fixable","version":"1","resources":[` +
|
||||
`{"id":"note","type":"file","path":"/etc/mesh-fixable","content":"here"}]}' > /tmp/fix.json`);
|
||||
await must("anchor", `docker cp /tmp/fix.json mesh-control:/fix.json`);
|
||||
await mesh("module add /fix.json");
|
||||
|
||||
// And nobody names the machine.
|
||||
await mesh("push --behind");
|
||||
await new Promise((r) => setTimeout(r, 8000));
|
||||
|
||||
const after = await mesh("status");
|
||||
assert.doesNotMatch(after, /laptop\s+(failed|refused)/,
|
||||
`the machine did not recover:\n${after}`);
|
||||
|
||||
// With nothing behind, it says so rather than doing nothing quietly.
|
||||
assert.match(await mesh("push --behind"), /every machine is doing what it was told/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user