One tally, printed twice, and a summary you can read back (#1417) #1418
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1418
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/counters-and-summary"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #1417.
The guard that was missing. The per-port counters live in the engine's flow state, published by
fullState()asruntime[id].counters.ports, and are printed byshow interfacesone block per port. Six pairs of surfaces in this repository have drifted apart after being written twice (port state, PoE, the routes table, the switchport sentence,show arp,show vrrp); counters had no test comparing them at all, andweb/app.jsdoes not read them yet, so a disagreement would have been discovered by whoever writes the next table.test/counters-agreement.test.js(32 checks) compares the two directly, engine-only so it is deterministic:flow.resetFlowState()zeroes the console and the payload together;The defect that fell out of writing it. A drop summary is one bracketed list of reasons, and a reason is prose that can bring its own brackets:
A reason that brings brackets is now quoted, so a summary is one level deep whatever the reason says. The suite reads a summary back into exactly the reasons and counts the payload recorded, and checks a reason with no brackets is not quoted for nothing.
Three existing assertions pinned the old rendering; they now accept either, because what they check is that the reason and its count are present - not the punctuation.
Evidence. 32 checks; with
engine/cli.jsreverted the quoting assertion fails (31/1). Suite: 209 suites, 8,021 assertions, 0 failed; syntax 277 files OK. Docs:docs/CLI.mdunder "What the port threw away".The per-port counters exist in two places: the engine's flow state, which fullState() publishes as runtime[id].counters.ports, and show interfaces, which prints one block per port. Every other pair of surfaces in this codebase that reimplemented one rule had drifted - port state, PoE, the routes table, the switchport sentence - and counters had no guard at all, because web/app.js does not read them yet: an agreement bug here would be found by whoever writes the next table, not by us. test/counters-agreement.test.js compares the two directly (21 checks, engine-only, so deterministic), over the five ways a frame can end: a clean crossing, a flooded frame, a policy refusal, a shut port, and a reset - then over every switch in the catalogue with a console (one block per interface, nothing counted when nothing crossed). Port by port and reason by reason, the console and the payload must be the same numbers. Writing that comparison found the second thing. A drop summary is one bracketed list of reasons, and a reason is prose that can bring its own brackets: '2 drops (ACL 101 denied (in) x2)' closes the list early for anyone reading it as a list. A reason that brings brackets is now quoted - '2 drops ("ACL 101 denied (in)" x2)' - so the summary is one level deep whatever the reason says, and the new section reads a summary back into exactly the reasons and counts the payload recorded (and checks a reason with no brackets is not quoted for nothing). Three existing assertions pinned the old rendering; they now accept either, since what they check is that the reason and its count are present. Evidence: test/counters-agreement.test.js 32 checks. With engine/cli.js reverted, the quoting assertion fails (31/1). Suite: 209 suites, 8,021 assertions, 0 failed; syntax 277 files OK.