skip to content

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

replay of recorded traffic

This lesson builds a replay suite from recorded lab traffic and measures its fidelity against a live lab page.

status of this lesson: from a public source

purpose

A fix for a collector must pass on real inputs, but each live test is load on a third party. A replay suite gives the extractor and the oracle recorded responses, and it sends nothing to the site. You must also know which recorded flows the suite cannot test.

objectives

  1. Write a capture rule that records only own lab flows and permitted flows, and scrubs each recording.
  2. Name the WARC record types that a replay suite reads.
  3. Build a replay of recorded flows through the extractor and the oracle, and compare each record with the expected record.
  4. Calculate the replay fidelity of a set of flows against a live lab page.
  5. Explain what a replay suite cannot prove.

new terms

replay fidelity
The share of recorded flows whose replay gives the same record as the live page.

how it works

A replay suite is one test layer of the plan. It holds recorded responses, and the expected record of each one. In each build, the extractor and the oracle read the recorded responses with no live request. A record that differs from the expected record is a fail.

the recording and the capture rule

A recording is a capture of the own requests of the collector and of the responses that came back. The capture rule says what the suite can record:

  • the flows of the own lab pages;
  • the flows of a target whose owner gave permission;
  • nothing else.

Each recording goes through a scrub step before it goes into the store. The step removes each cookie value, each authorization header, each token, each account name, and each personal value. A typed placeholder takes the place of each value, for example <cookie:web-session>.

A HAR file of a browser can hold such values in its headers. Thus the scrub step runs on each file, also on a file from the own lab. The suite records no input of a real person.

the warc record

WARC 1.1 states that a WARC file is "the simple concatenation of one or more WARC records" IIPC, source 1. The standard gives eight record types:

  • warcinfo, response, resource, request;
  • metadata, revisit, conversion, continuation.

A request record holds the details of a complete request. A response record holds the complete response. Each record must have the four fields WARC-Record-ID, Content-Length, WARC-Date, and WARC-Type.

the replay and the record compare

A replay suite reads the response records. It uses the request records to find the response of each request.

The replay runner reads each response record of a flow. It gives the body to the extractor, and it gives the extracted record to the oracle. Then it compares the result with the expected record of that flow.

For example, a recorded product page must give the record {"sku": "A-100", "price": "19.90"} and the verdict pass of the oracle. A changed price parser gives "price": "" from the same bytes. The suite shows the fail before the release, with no request to the site.

replay fidelity

A replay suite is useful only when its records equal the records of the live page. replay fidelity measures this. It is the share of recorded flows whose replay gives the same record as the live page.

The fidelity check runs on the own lab pages only. The operator records a flow, and later reads the same lab page live. Then the operator compares the record from the replay with the record from the live lab page.

A flow can fail the check for a reason in the request. For example, a page adds a time parameter or a random request ID to each request. Each new request then has a new address, and no recorded response agrees with it.

The suite marks such a flow as a known gap. The plan covers it with a different test layer.

what a replay cannot prove

A replay has no live transport, no fresh token, and no live detection script. Thus a pass shows that the extractor and the oracle work on the recorded bytes. It does not show that the collector still gets access to the site.

For example, a site can add a new check on its live pages, and the recorded bytes do not show it. A change of access belongs to the canary of The release gate and the permitted live canary.

A replay also tests only the pages that somebody recorded. The regression corpus of stored pages has the same limit.

the two sides

automation sidedetection side
A replay suite tests the extractor and the oracle with no load on a target. It cannot show a change of access.A replay sends no traffic to the target, so the defender sees nothing. A defender uses recorded traffic in the same way to test a rule change.

design decisions

optiongaincostwhen it is correct
Store WARC filesOne standard format with request and response recordsA recorder must make them.For a suite that many tools read
Store HAR filesA person can record them in the browser tools.The file can hold header values that the scrub step must remove.For lab flows that a person records in a browser
Record each flow one timeA small storeA flow with a changed request parameter does not replay.For flows that the fidelity check accepts
Mark a flow that does not replay as a known gapThe plan shows the open risk.A different test layer must cover the flow.Always, when the fidelity check fails for a flow
Run the fidelity check on each new page classA new class gets a measured fidelity.Each check reads a live lab page.When the lab adds a page class

diagram

the replay suite: from the capture rule to the record compare and the fidelity check

The replay suite reads only scrubbed recordings, and the fidelity check reads only a live lab page.source: My model of a replay suite

code example

The example is a replay runner. It builds a small WARC file of synthetic lab flows in memory, and it holds the expected record of each flow.

m54-x02-replay.tstypescript

Read a WARC file, find the response of each request, run the extractor and the oracle, and compare each record with its expected record.

type WarcRecord = { headers: Record<string, string>; body: Buffer };
type Item = { sku: string; price: string };
// Build one synthetic WARC record. The values are invented.
let count = 0;
function record(type: string, uri: string, block: string): Buffer {
  const bytes = Buffer.from(block, "utf8");
  count += 1;
  const head = `WARC/1.1\r\nWARC-Record-ID: <urn:example:lab-${count}>\r\nWARC-Date: 2000-01-01T00:00:00Z\r\n`
    + `WARC-Type: ${type}\r\nWARC-Target-URI: ${uri}\r\nContent-Length: ${bytes.length}\r\n\r\n`;
  return Buffer.concat([Buffer.from(head), bytes, Buffer.from("\r\n\r\n")]);
}
function* records(file: Buffer): Generator<WarcRecord> {
  let pos = 0;
  while (pos < file.length) {
    const end = file.indexOf("\r\n\r\n", pos);
    if (end < 0) return;
    const headers: Record<string, string> = {};
    for (const line of file.subarray(pos, end).toString("utf8").split("\r\n").slice(1)) {
      const i = line.indexOf(":");
      headers[line.slice(0, i).trim()] = line.slice(i + 1).trim();
    }
    const start = end + 4, length = Number(headers["Content-Length"]);
    yield { headers, body: file.subarray(start, start + length) };
    pos = start + length + 4;
  }
}
function extract(http: Buffer): Item {
  // Synthetic extractor of the lab product page.
  const html = http.toString("utf8").split("\r\n\r\n").slice(1).join("\r\n\r\n");
  const field = (name: string) => html.match(new RegExp(`data-${name}="([^"]*)"`))?.[1] ?? "";
  return { sku: field("sku"), price: field("price") };
}
const oracle = (item: Item) => (item.sku && item.price ? "pass" : "fail");

// Three synthetic lab flows: request path, response path, page attributes, expected record.
// The request of flow 3 has a new time parameter.
const lab = "urn:example:lab-shop";
const get = (path: string) => `GET ${path} HTTP/1.1\r\nHost: lab.example\r\n\r\n`;
const page = (attrs: string) => `HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<div ${attrs}></div>`;
const flows: [string, string, string, Item][] = [
  ["/p/1", "/p/1", 'data-sku="A-100" data-price="19.90"', { sku: "A-100", price: "19.90" }],
  ["/p/2", "/p/2", 'data-sku="A-200" data-cost="5.00"', { sku: "A-200", price: "5.00" }],
  ["/p/3?t=1001", "/p/3?t=1000", 'data-sku="A-300" data-price="7.50"', { sku: "A-300", price: "7.50" }],
];
const warc = Buffer.concat(flows.flatMap(([req, res, attrs]) => [record("request", lab + req, get(req)), record("response", lab + res, page(attrs))]));
const expected = new Map(flows.map(([req, , , item]) => [lab + req, item]));
// Use each request record to find its response record. Each expected verdict is "pass".
const all = [...records(warc)];
const responses = new Map(all.filter((r) => r.headers["WARC-Type"] === "response").map((r) => [r.headers["WARC-Target-URI"], r]));
let differ = 0;
for (const request of all.filter((r) => r.headers["WARC-Type"] === "request")) {
  const uri = request.headers["WARC-Target-URI"];
  const response = responses.get(uri);
  const item = response ? extract(response.body) : undefined;
  const verdict = item ? oracle(item) : "no response found";
  const same = item !== undefined && verdict === "pass" && JSON.stringify(expected.get(uri)) === JSON.stringify(item);
  if (!same) differ += 1;
  console.log(`${uri}: ${verdict} ${same ? "same" : "DIFFERENT"}`);
}
console.log(`result: ${differ} records differ`);

output

One line for each request, with the verdict and the result of the compare, and the count of records that differ.

urn:example:lab-shop/p/1: pass same
urn:example:lab-shop/p/2: fail DIFFERENT
urn:example:lab-shop/p/3?t=1001: no response found DIFFERENT
result: 2 records differ

Flow 2 gives an empty price, so the oracle gives fail. Flow 3 has a new time parameter in its request, so no recorded response agrees with it.

data

replay of recorded flows: share with the same record as the live page

status of this figure: measured by me

replay of recorded flows: share with the same record as the live pageby page class, all variants (sample of 90)server render100%client render50%interface50%unit: %by page class and variant (sample of 90)server render, plain100%server render, redirect100%client render, plain100%client render, cache buster0%interface, plain100%interface, random request id0%unit: %

lines: interval, level 0.95

source: Lab result of this course: replay of recorded flows on my lab pages; date 2026-11-13; sample of 90; condition: My lab pages, one host, Chromium only. A stand-in record and replay function, not a proxy. Each replay sent no request to the server. Lab teaching values.

data table
replay of recorded flows: share with the same record as the live page
seriespage class or variant%interval
by page class, all variantsserver render10088.64 to 100 (level 0.95)
by page class, all variantsclient render5033.15 to 66.85 (level 0.95)
by page class, all variantsinterface5033.15 to 66.85 (level 0.95)
by page class and variantserver render, plain10079.61 to 100 (level 0.95)
by page class and variantserver render, redirect10079.61 to 100 (level 0.95)
by page class and variantclient render, plain10079.61 to 100 (level 0.95)
by page class and variantclient render, cache buster00 to 20.39 (level 0.95)
by page class and variantinterface, plain10079.61 to 100 (level 0.95)
by page class and variantinterface, random request id00 to 20.39 (level 0.95)
A replay gives the same record for plain flows. Flows with a time parameter or a random request id never replay. The class value depends on the variant mix. Intervals are Wilson 95%.

The chart is a lab result of this course, from my own lab pages. Plain flows of each page class give the same record as the live page. The flows with a time parameter or a random request ID do not.

failure modes

problemcausecorrection
A recording holds a cookie value or a token.The recorder wrote the headers as they were, with no scrub step.Run the scrub step on each recording before it goes into the store.
A flow never replays.The page adds a time parameter or a random request ID, so no recorded response agrees with the request.Mark the flow as a known gap, and cover it with a different test layer.
The suite is green, but the collector gets no access to the site.A replay has no live transport and no live detection script.Read a replay pass as a test of the extractor and the oracle only.
The fidelity of a page class looks low.The value depends on the mix of flows in the class.Give the fidelity for each kind of flow, not only for each page class.
A recording of a site enters the store with no permission.The capture rule does not name the permitted targets.Record only the own lab flows and the flows of a permitted target.

check questions

  1. Which recording can go into the store of a replay suite?

    1. A recording of a flow on a site with no permission
    2. A scrubbed recording of a flow on an own lab page
    3. A recording that holds the cookie values of a web session
    4. A recording of the input of a real person
    answer

    b. A scrubbed recording of a flow on an own lab page

    The capture rule permits only own lab flows and the flows of a permitted target. The scrub step removes each secret and each personal value before the recording goes into the store.

  2. Name the WARC record types that a replay suite reads, and say what each one holds.

    sample answer

    The suite reads the response records, which hold the complete response, and the request records, which hold the details of the complete request. It uses the request records to find the response of each request.

  3. A replay gives the record with an empty price for a recorded product page. The expected record has the price 19.90. What is the result of the replay suite?

    1. A fail before the release
    2. A pass, because the page bytes did not change
    3. A known gap for a different test layer
    answer

    a. A fail before the release

    The record differs from the expected record. Thus the suite gives a fail before the release, with no request to the site.

  4. Of 10 lab flows, 9 give the same record in the replay and on the live lab page. What is the replay fidelity?

    1. 10%
    2. 50%
    3. 90%
    4. 100%
    answer

    c. 90%

    The replay fidelity is the share of recorded flows whose replay gives the same record as the live page: 9 of 10, or 90%.

  5. Explain why a green replay suite does not show that the collector still gets access to the site.

    sample answer

    A replay has no live transport, no fresh token, and no live detection script. A pass shows only that the extractor and the oracle work on the recorded bytes. A change of access belongs to the canary.

exercise

exercise Do this task on paper. The input is a list of five synthetic lab flows. Each item gives the record from the replay and the record from the live lab page:

  • Flow 1: replay sku A-100, price 19.90; live sku A-100, price 19.90.
  • Flow 2: replay sku A-200, price 5.00; live sku A-200, price 5.00.
  • Flow 3: replay no response found; live sku A-300, price 7.50. Each request of the flow holds a time parameter.
  • Flow 4: replay sku A-400, price 12.00; live sku A-400, price 12.00.
  • Flow 5: replay sku A-500, price 3.10; live sku A-500, price 3.10.
  1. For each flow, write if the replay record equals the live record.
  2. Calculate the replay fidelity of the five flows.
  3. For each flow that fails, write the cause and the action of the plan.
sample answer

The answer uses the five synthetic flows of the task.

Flows 1, 2, 4, and 5 give the same record in the replay and on the live lab page. Flow 3 does not, because no recorded response agrees with a request that holds a new time parameter. The replay fidelity is 4 of 5 flows, or 80%. The plan marks flow 3 as a known gap and covers it with a different test layer.

sources

  1. WARC 1.1, IIPC, standard, read 2026-11-22
  2. My model of a replay suite, its capture rule, and its fidelity check, 2026-11 (not public).