skip to content

test strategy for a collection product · lesson 1 of 7 · sources checked 2026-11-30

the test layers of a collector

This lesson writes the test plan of a collector, with the proof, the place, the gate, and the limit of each test layer.

status of this lesson: from a public source

purpose

A collector reads sites that change without notice, and each live test is load on a third party. A test plan shows which test can prove what, and which risk stays open.

objectives

  1. Name the seven test layers of a collector and the proof of each test layer.
  2. Give each test layer its place, its gate, its owner, and its limit.
  3. Explain why a test on a live page is a canary and not a regression test.
  4. Map a regression pattern to the first test layer that can catch it.

new terms

test plan
The set of test layers of one product, with the gate of each layer and the risk that no layer covers.
replay suite
A set of recorded responses that the extractor and the oracle read with no live request.
lab detection target
A lab page behind an own detection system that a release client must pass with a known class.
upstream contract test
A test that compares a recorded upstream shape with the stored shape of the same flow.
shadow on the response
A shadow comparison in which one fetch feeds two versions of the extractor and the oracle.
release gate
One check that reads the result of each test layer and refuses a release that fails a layer.

how it works

A test plan is a list of test layers. Each test layer has four fields:

  • the proof: what a pass shows;
  • the place: where the test runs, and if it sends traffic to a target;
  • the gate: which change must pass the test before it goes on;
  • the limit: what a pass does not show.

The limit is the important field. Each test layer misses some risk. A plan with a written limit for each test layer shows the risk that no test layer covers.

seven test layers, from offline to live

I use seven test layers. The first four send no request to a third party:

  1. Stored pages. The extractor reads a regression corpus and must give the expected record. More detail is in The extraction regression suite and selector drift (not yet published).
  2. Replay suite. A replay suite gives recorded responses to the extractor and the oracle. The next lesson builds it.
  3. Lab target. The release client must get its known class on a lab detection target.
  4. Contract tests. An upstream contract test compares a new recording of a flow with the stored shape of that flow.

A lab target uses two control clients, a known-good client and a known-bad client. Each is a positive control of the own detection. If a control client gets the wrong class, the fault is in the lab target, not in the release client.

The last three test layers touch production or a live site:

  1. Shadow. A shadow on the response gives one fetch to the old and the new version. Then it compares the two records.
  2. Canary. A canary runs first on lab targets. Then it sends a small, declared volume to a target whose owner gave permission.
  3. Release gate. A release gate reads the result of each test layer and refuses a release that fails one of them.

For example, a change of a shared date parser must pass test layers 1, 2, and 5 before the gate opens.

where each test layer runs, and what it cannot prove

An offline test layer runs on the build host with no network. It is fast, and it is repeatable. But it tests only the inputs of the past. For example, a stored page from last month cannot show the new key that the site added this week.

A live test layer sees the site as it is today. Its cost is load on a third party, and each request is a signal to the defender of that site. Thus the plan keeps the live part small, and it never sends a live test to a site without permission.

For a collector, the result of a live test depends on the page of that day. A pass today and a fail tomorrow can come from a change of the site, with no change of the code. Thus a live test is a canary.

A regression test must use a stored input. Then only the code can change its result.

a test on a live page is a canary

The Google SRE workbook defines canarying as "a partial and time-limited deployment of a change in a service and its evaluation" Google, source 1.

The same chapter calls the part of the service with the change "the canary", and the remainder "the control". The evaluation decides if the rollout goes on.

map each regression pattern to its first test layer

A regression pattern is a known form of regression in general code. The edge-case tail holds many such patterns, and more detail is in General code and the edge-case tail. For each pattern, the plan names the first test layer that can catch it.

For example, a fix for one target can break other targets that share the same function. Stored pages catch it. A differential run compares the old and the new records on the full corpus. More detail is in The regression corpus and the differential run.

A check that stays green over an empty set is a different case. Only the release gate catches it, when each input must prove that it examined something.

Two other test layers come from other modules. A new browser image must pass the regression suite of The regression suite for each release (not yet published). The plan also names the failure drills of the collector. More detail is in Failure drills for a collector.

the two sides

automation sidedetection side
A plan with a stated limit for each test layer shows which risk no test layer covers. A test on a live page measures the page today, not the code.A detection team has the same test layers: unit tests of rules, tests on recorded traffic, a lab of known clients, and a shadow mode. The release of a rule in count mode is in Release a rule in count mode (not yet published).

design decisions

optiongaincostwhen it is correct
Offline test layers onlyNo load on a third party, and fast resultsNo test sees a change of the site after the recording.Never alone. Use them as the gate of each merge.
A live test as the regression testThe test sees the site of today.A change of the site looks like a fault of the code, and each run is load on the site.Never. A live test is a canary.
A written limit for each test layerThe open risk is visible.The plan is longer.Always
One owner for each test layerSomebody repairs a red test.Each owner has more work.Always
A release gate over all test layersOne failed test layer stops the release.A flaky test layer stops good releases too.When each test layer has a known noise level

diagram

the seven test layers of a collector, with the proof and the place of each

  1. Stored pagesProof: the extractor gives the expected record from a stored page. Place: the build host, no network.
  2. Replay suiteProof: the extractor and the oracle give the expected record from a recorded flow. Place: the build host, no network.
  3. Lab targetProof: the release client keeps its known class against the own detection. Place: the own lab.
  4. Contract testsProof: a new recording has the stored shape of its flow. Place: the build host, with recordings from a lab page or a permitted target.
  5. Shadow on the responseProof: the old and the new version give the same record from one fetch. Place: production, with no extra request.
  6. CanaryProof: a permitted flow works on the page of today. Place: a permitted live target, with a small declared volume.
  7. Release gateProof: each test layer passed and examined something. Place: the release step.
The first four test layers send no request to a third party. Only the canary sends extra requests to a live site.source: My model of the test layers of a collector

The second diagram maps regression patterns to the first test layer that can catch each one.

A matrix of six regression patterns against the first test layer that can catch each one, the gate of that test layer, and its limit. Each pattern has a different first test layer, from the stored pages to the release gate.

regression patterns of general code against the first test layer that can catch each one
regression patternfirst test layergatelimit
A fix for one target breaks other targetsStored pagesEach mergePast pages only
A fix fails on the production shapeReplay suiteEach mergeNo live transport
A new browser image changes the classLab targetEach new imageOwn detection only
The target adds or removes a keyContract testsEach buildShows a change, not its cause
A new version changes records in productionShadow on the responseEach releaseTraffic of today only
A check stays green over an empty setRelease gateEach releaseA count from each input is necessary
Each regression pattern has one first test layer, and the plan names it.source: My model of the map from regression patterns to test layers

code example

The example holds a synthetic test plan. It checks that each test layer has a proof, a place, a gate, an owner, and a limit. It also checks that each regression pattern maps to a test layer, and that no live test layer gates a merge.

m54-x01-plan.tstypescript

Check a synthetic test plan. Each test layer must have all five fields, each regression pattern must map to a test layer, and no live test gates a merge.

type Place = "build host" | "own lab" | "production" | "permitted live target";
type Layer = { id: string; proof: string; place: Place; gate: string; owner: string; limit: string };
type Plan = { layers: Layer[]; patterns: Record<string, string> };

const LIVE: Place[] = ["permitted live target"];

// A synthetic plan with two faults: a missing limit, and a canary on each merge.
const plan: Plan = {
  layers: [
    { id: "stored-pages", proof: "same record from a stored page", place: "build host", gate: "each merge", owner: "team-a", limit: "past pages only" },
    { id: "replay", proof: "same record from a recorded flow", place: "build host", gate: "each merge", owner: "team-a", limit: "no live transport" },
    { id: "lab-target", proof: "release client keeps its class", place: "own lab", gate: "each image", owner: "team-b", limit: "own detection only" },
    { id: "contract", proof: "stored shape equals new shape", place: "build host", gate: "each build", owner: "team-a", limit: "" },
    { id: "shadow", proof: "old and new give the same record", place: "production", gate: "each release", owner: "team-c", limit: "today's traffic only" },
    { id: "canary", proof: "permitted flow works today", place: "permitted live target", gate: "each merge", owner: "team-c", limit: "page of today, not the code" },
  ],
  patterns: {
    "shared function breaks other targets": "stored-pages",
    "fix fails on the production shape": "replay",
    "new image changes the class": "lab-target",
    "target adds or removes a key": "contract",
    "green check over an empty set": "release-gate",
  },
};

const faults: string[] = [];
const ids = new Set(plan.layers.map((l) => l.id));
for (const l of plan.layers) {
  const empty = (["proof", "gate", "owner", "limit"] as const).filter((k) => l[k].trim() === "");
  console.log(`layer ${l.id}: ${l.place}, gate ${l.gate}`);
  for (const k of empty) faults.push(`layer ${l.id}: no ${k}`);
  if (LIVE.includes(l.place) && l.gate === "each merge") faults.push(`layer ${l.id}: a live test cannot gate a merge`);
}
for (const [pattern, layer] of Object.entries(plan.patterns)) {
  const known = ids.has(layer);
  console.log(`pattern "${pattern}" -> ${layer}${known ? "" : " (not in the plan)"}`);
  if (!known) faults.push(`pattern "${pattern}": no test layer ${layer}`);
}
for (const f of faults) console.log(`fault: ${f}`);
console.log(faults.length === 0 ? "result: plan accepted" : `result: plan refused, ${faults.length} faults`);

output

One line for each test layer, one line for each regression pattern, each fault of the plan, and the result.

layer stored-pages: build host, gate each merge
layer replay: build host, gate each merge
layer lab-target: own lab, gate each image
layer contract: build host, gate each build
layer shadow: production, gate each release
layer canary: permitted live target, gate each merge
pattern "shared function breaks other targets" -> stored-pages
pattern "fix fails on the production shape" -> replay
pattern "new image changes the class" -> lab-target
pattern "target adds or removes a key" -> contract
pattern "green check over an empty set" -> release-gate (not in the plan)
fault: layer contract: no limit
fault: layer canary: a live test cannot gate a merge
fault: pattern "green check over an empty set": no test layer release-gate
result: plan refused, 3 faults

The output shows three faults. The contract test has no limit. The canary gates each merge, but a live test is a canary and not a regression test. The pattern of the empty set maps to a release gate that the plan does not hold.

failure modes

problemcausecorrection
A change of the site shows as a fault of the code.A live test is the regression test.Use stored pages and the replay suite for regression. Keep the live test as a canary.
A risk reaches production with all tests green.No test layer has a written limit, so nobody sees the open risk.Write the limit of each test layer, and name the risk that no test layer covers.
A red test stays red for weeks.The test layer has no owner.Give each test layer one owner.
The lab target passes a broken release client.The control clients do not get their known classes, and nobody checks them.Check both control clients before the release client.
A check passes over an empty input set.The gate accepts a green result with no count.Each input of the release gate proves that it examined something.

check questions

  1. Name the seven test layers of a collector in the order from offline to live.

    sample answer

    Stored pages, replay suite, lab target, contract tests, shadow on the response, canary, and release gate.

  2. Which field of a test layer shows the risk that the test layer does not cover?

    1. The proof
    2. The limit
    3. The gate
    4. The owner
    answer

    b. The limit

    The limit says what a pass does not show. A plan with a limit for each test layer shows the risk that no test layer covers.

  3. Explain why a test on a live page is a canary and not a regression test.

    sample answer

    The result of a live test depends on the page of that day. A change of the site can change the result with no change of the code. A regression test uses a stored input, so that only the code can change its result.

  4. A target adds a key to the response of its search interface. Which test layer is the first that can catch the change?

    1. Stored pages
    2. Release gate
    3. Canary
    4. Contract tests
    answer

    d. Contract tests

    A contract test compares a new recording of the flow with its stored shape. A new key is a change of that shape.

exercise

exercise Do this task on paper. The input is a list of five synthetic changes to a collector:

  • Change A: a new version of a shared price parser.
  • Change B: a fix for one target that failed on a page with a new wrapper element.
  • Change C: a new browser image.
  • Change D: a target added a key to the response of its search interface.
  • Change E: a new gate input that counts the records of the day.
  1. For each change, write the first test layer that can catch a regression.
  2. For each change, write the gate of that test layer.
  3. For each change, write one limit of that test layer.
sample answer

The answer uses the seven test layers of the section "How it works".

Change A goes to the stored pages, with the gate on each merge. The limit is that the stored pages show only the past. Change B goes to the replay suite, because the failed flow is a recorded flow in production shape. The limit is that the replay suite has no live transport.

Change C goes to the lab target and to the regression suite for each browser release. The gate is each new image, and the limit is that the lab target uses the own detection only. Change D goes to the contract test, on each build. The limit is that a difference shows a change but not its cause. Change E goes to the release gate. The gate input must prove that it counted something, because a green check over an empty set proves nothing.

sources

  1. Canarying Releases, Google, article, read 2026-11-22
  2. My model of the seven test layers of a collector and of the map from regression patterns to test layers, 2026-11 (not public).