Wait for the route to be withdrawn rather than sleeping through it
This assertion passed twice and failed once on nothing but timing, which is the worst kind of green: it says the mechanism works when what it measured was the clock. `status` cannot stand in for the wait either. A machine that has not applied yet is not a machine that failed — "not yet" and "never" look identical there, and only one of them is worth failing over. So it waits for the thing itself, and says on failure that the machine did apply, which is what separates "the mesh still thinks this contributes" from "nothing was sent".
This commit is contained in:
@@ -939,20 +939,24 @@ test("a route is a grant: a workload is reached by the name it asked for", {
|
|||||||
// fails more visibly than a stale grant, so it must not survive the module leaving.
|
// fails more visibly than a stale grant, so it must not survive the module leaving.
|
||||||
await mesh("unassign laptop storefront");
|
await mesh("unassign laptop storefront");
|
||||||
await mesh("push");
|
await mesh("push");
|
||||||
await new Promise((r) => setTimeout(r, 20_000));
|
|
||||||
|
|
||||||
// The provider has to have applied before the file means anything. **The mesh withdrawing a
|
// **Waited for, not slept through.** The mesh withdrawing a route and the machine acting on it
|
||||||
// route and the machine acting on it are different things**, and a test that reads the file
|
// are different things, and a fixed sleep between them tests whichever the clock happened to
|
||||||
// without checking the second reports the first wrongly whenever the machine is behind for any
|
// land on — this assertion passed twice and failed once on nothing but timing.
|
||||||
// unrelated reason.
|
//
|
||||||
const applied = await mesh("status");
|
// A machine that has not applied yet is also not a machine that failed, so `status` cannot
|
||||||
assert.doesNotMatch(applied, /anchor\s+(failed|refused)/,
|
// stand in for this: "not yet" and "never" look identical there, and only one of them is worth
|
||||||
`the provider did not apply, so what its file says is not what the mesh decided:\n${applied}`);
|
// failing over.
|
||||||
|
let after = "";
|
||||||
const after = await must("anchor", `cat /etc/frontdoor/routes.json`);
|
let withdrawn = false;
|
||||||
assert.doesNotMatch(after, /shop\.mesh\.test/,
|
for (let i = 0; i < 20 && !withdrawn; i++) {
|
||||||
|
after = await must("anchor", `cat /etc/frontdoor/routes.json`);
|
||||||
|
withdrawn = !after.includes("shop.mesh.test");
|
||||||
|
if (!withdrawn) await new Promise((r) => setTimeout(r, 3000));
|
||||||
|
}
|
||||||
|
assert.ok(withdrawn,
|
||||||
`the route outlived the module that asked for it:\n${after}\n\n` +
|
`the route outlived the module that asked for it:\n${after}\n\n` +
|
||||||
`what the mesh would send now:\n` +
|
`the machine did apply — this is what the mesh would send now:\n` +
|
||||||
`${(await on("anchor", `docker exec mesh-control /mesh-control plan anchor --files`)).out}`);
|
`${(await on("anchor", `docker exec mesh-control /mesh-control plan anchor --files`)).out}`);
|
||||||
|
|
||||||
let gone = false;
|
let gone = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user