test(router-parity): a late teapot is served after it connects for CARD-19 (owner approval required)
owner-mesh-lifetime.json froze phase B2 (teapot absent at boot, then up) at 404 for GET and POST /api/remote/ping. The table was built once at boot, so a late teapot was never spliced in. CARD-19 (#124, D15) changes that. B2 now answers GET 200 {"from":"teapot"} and POST 405 with Allow: GET, HEAD, OPTIONS, the same as A1. Only those two entries change. A1, A2 and B1 are identical. The fixture's teacup goes from reconnect: false to reconnect with a fast backoff (20-60ms). Under D15, reconnect: false makes a dropped teapot "gone" (404), and an absent one is not retried. The card's phases describe the reconnecting teacup: A2 stays 503 and B2 becomes 200. B2 now waits for the mesh:routes event before probing. The fixture comment and the corpus README line describing "built once at boot" are updated. Owner approval required (CARD-08 rule): this edits a frozen file and the fixture under test/router-parity/. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
3 files changed
+27
-10
No files matched your search
@@ -31,7 +31,7 @@ Nothing can regenerate the baseline by accident:
|
||||
| `frozen/matcher-*.json` | Captured matcher outputs: declaration ID, decoded params, `implicitHead`, ordered `Allow`, or the normalization error. The generated file also stores the seed, the generator rules and every generated input. |
|
||||
| `frozen/app-*.json` | Status, headers, `Allow` and body through `app.fetch` and through a Node socket, including HEAD body suppression. |
|
||||
| `frozen/ws-*.json` | WS upgrade selection through `app.upgrade` and the Node listener, plus HTTP requests at the WS paths. |
|
||||
| `frozen/owner-*.json` | Owner additions needing a running app: cross-pattern `Allow` through both adapters, and the mesh HTTP route table across a peer's lifetime (it is built once at boot and never changes — see `owner.test.ts`). |
|
||||
| `frozen/owner-*.json` | Owner additions needing a running app: cross-pattern `Allow` through both adapters, and the mesh HTTP route table across a peer's lifetime (built once at boot at the pinned revision; since CARD-19 it follows teapot membership — see `owner.test.ts`). |
|
||||
| `frozen/boot-*.json` | Boot-time rejections: pattern compilation, local ambiguity, mesh splicing. |
|
||||
| `frozen/golden-*.json` | `graph()`, `explain()`, `openapi({ title: 'Parity', version: '1' })`, and a mesh teacup before and after `ready()`. |
|
||||
|
||||
|
||||
@@ -101,17 +101,17 @@
|
||||
"phase": "B2 teapot up after boot",
|
||||
"method": "GET",
|
||||
"path": "/api/remote/ping",
|
||||
"status": 404,
|
||||
"status": 200,
|
||||
"allow": null,
|
||||
"body": "{\"error\":\"Not Found\"}"
|
||||
"body": "{\"from\":\"teapot\"}"
|
||||
},
|
||||
{
|
||||
"phase": "B2 teapot up after boot",
|
||||
"method": "POST",
|
||||
"path": "/api/remote/ping",
|
||||
"status": 404,
|
||||
"allow": null,
|
||||
"body": "{\"error\":\"Not Found\"}"
|
||||
"status": 405,
|
||||
"allow": "GET, HEAD, OPTIONS",
|
||||
"body": "{\"error\":\"Method Not Allowed\"}"
|
||||
},
|
||||
{
|
||||
"phase": "B2 teapot up after boot",
|
||||
|
||||
@@ -88,15 +88,30 @@ const teacupFor = (port: number) =>
|
||||
teapots: [{ url: `ws://127.0.0.1:${port}/__mesh__/control`, secret: SECRET }],
|
||||
bootTimeoutMs: 300,
|
||||
timeoutMs: 500,
|
||||
reconnect: false,
|
||||
// Reconnect on (CARD-19, D15): a dropped teapot is "reconnecting" and keeps its routes (A2),
|
||||
// and one absent at boot is retried in the background (B). Captured at ed47836 with
|
||||
// `reconnect: false`, when neither depended on it. Fast backoff keeps the test short.
|
||||
reconnect: { initialDelayMs: 20, maxDelayMs: 60 },
|
||||
},
|
||||
});
|
||||
|
||||
/** Resolves on the teacup's next `mesh:routes` event: its remote table changed. */
|
||||
const routesChanged = (app: App) =>
|
||||
new Promise<void>((resolve, reject) => {
|
||||
const timer = setTimeout(() => reject(new Error('no mesh:routes within 5s')), 5000);
|
||||
const off = app.bus.on('mesh:routes', () => {
|
||||
clearTimeout(timer);
|
||||
off();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Two lifetimes. A: the teapot is up at boot, then goes away. B: the teapot is absent at boot and
|
||||
* comes up afterwards. The current code builds the HTTP table once, at boot, and never changes it:
|
||||
* routes spliced at boot stay in the table after their peer leaves, and a peer that arrives late
|
||||
* is never spliced in. CARD-10 can reuse this to assert the index is not rebuilt per request.
|
||||
* comes up afterwards. At ed47836 the HTTP table was built once, at boot, and never changed, so B2
|
||||
* answered 404. Since CARD-19 (D15, owner approval) the remote routes follow membership: a teapot
|
||||
* that is reconnecting keeps its routes and answers 503 (A2), and a late one is spliced in when it
|
||||
* connects (B2). CARD-10 can reuse this to assert the index is not rebuilt per request.
|
||||
*/
|
||||
async function meshLifetimes() {
|
||||
const results = [];
|
||||
@@ -118,7 +133,9 @@ async function meshLifetimes() {
|
||||
const teapotB = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } });
|
||||
try {
|
||||
results.push(...(await probe(teacupB, 'B1 teapot absent at boot')));
|
||||
const spliced = routesChanged(teacupB);
|
||||
await teapotB.listen(portB);
|
||||
await spliced;
|
||||
results.push(...(await probe(teacupB, 'B2 teapot up after boot')));
|
||||
} finally {
|
||||
await teacupB.close();
|
||||
|
||||
Reference in new issue
Block a user