A forced line rate survives a save, and so does the test that missed it (#1405) #1406
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!1406
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/forced-rate-survives-save"
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?
A forced line rate survives a save, and so does the test that missed it. Fixes #1405.
Found by asking the save question from the other end: not "does the document reload as itself" but "set one thing,
save, reload, and diff the port object field by field". The answer for
speed 100was that the field is gone.Save and reload: the port is back at its hardware rate, and
speed 100has gone from running-config as well — whichis what made it permanent, because nothing was left to put it back.
duplex, one line above it in both the writerand the reader, was saved all along.
Why the existing guarantee missed it
test/port-roundtrip.test.jsround-tripped a lab straight out of the catalogue, so every field sat at its defaultand the comparison was default-in, default-out. A setting that is only non-default after a command is invisible to
a sweep over virgin labs. The section's own claim — "every field of every port survives the round trip, for every
model in the catalogue" — was tested against a file that carried nothing.
What changed
Device.serialize()writesspeedMbpswhen the rate has been forced, and only then, following the file's own rulefor optional facts (
natRole, the combo fields): a port that negotiates its own rate must not grow aspeedMbps: nullline, and a board must not grow one on every port in the catalogue.fromJSON()restores it besideduplex, soshow interfacessays100Mb/s (forced), running-config still printsspeed 100, and the link itself runs at 100 after the reload — the value the engine uses, not just a field.Evidence
test/port-roundtrip.test.jsgained two sections — 32 checks in the suite. The sweep now configures first:one port of every model with a speed ladder is forced to its lowest supported rate (1,902 of 2,038 models),
saved, reloaded, and every field of every port compared. Then the specific case: the saved document carries the rate;
the reloaded port still has it;
show interfacesand running-config both still say so; the cable between two 1 Gbpsports runs at 100 before and after the reload;
speed autoclears it with no stale rate left in the file; a virginport's document still contains no
speedMbpsat all; and save → load → save is byte-identical.Reverting
engine/device.jsfails 5 of the 32, naming the models whose rate was lost.docs/ARCHITECTURE.md:speedMbpsadded to the lost-on-reload table, plus why a virgin-lab sweep cannot see asetting, and the two conventions (unset fields are not written; a cache the file drops is checked by behaviour — the
reloaded port must still classify into the same VLAN).
docs/CLI.md: the forced rate survives a save.Suite: 204 suites, 7,869 assertions, 0 failed. Syntax: 272 files, OK.
Found by asking the save question from the other end: not "does the document reload as itself" but "set one thing, save, reload, and diff the port object field by field". The answer for `speed 100` was that the field is gone. sw1(config-if)#speed 100 Speed 100M on Gi1/0/1 sw1#show interfaces Gi1/0/1 speed: 100Mb/s (forced), duplex: full sw1#show running-config speed 100 Then save and reload: the port is back at its hardware rate, and `speed 100` has gone from running-config as well - which is what made it permanent, because nothing was left to put it back. `duplex`, one line above it in both the writer and the reader, was saved all along. Why the existing guarantee missed it: `test/port-roundtrip.test.js` round-tripped a lab straight out of the catalogue, so every field sat at its default and the comparison was default-in, default-out. A setting that is only non-default after a command is invisible to a sweep over virgin labs. The section's own claim - "every field of every port survives the round trip, for every model in the catalogue" - was tested against a file that carried nothing. Fixed: * `Device.serialize()` writes `speedMbps` when the rate has been forced, and only then, following the file's own rule for optional facts (`natRole`, the combo fields): a port that negotiates its own rate must not grow a `speedMbps: null` line, and a board must not grow one on every port in the catalogue. * `fromJSON()` restores it beside `duplex`, so `show interfaces` says `100Mb/s (forced)`, running-config still prints `speed 100`, and the link itself runs at 100 after the reload - the value the engine uses, not just a field. Evidence: `test/port-roundtrip.test.js` gained two sections, 32 checks total. The sweep now **configures** first: one port of every model with a speed ladder is forced to its lowest supported rate (1,902 of 2,038 models), saved, reloaded, and every field of every port compared. Then the specific case: the saved document carries the rate, the reloaded port still has it, `show interfaces`, and running-config both still say so, the cable between two 1 Gbps ports runs at 100 before *and* after the reload, `speed auto` clears it with no stale rate left in the file, a virgin port's document still contains no `speedMbps` at all, and save -> load -> save is byte-identical. Reverting `engine/device.js` fails 5 of the 32, naming the models whose rate was lost. docs/ARCHITECTURE.md: `speedMbps` added to the lost-on-reload table, and the reason a virgin-lab sweep cannot see a setting, with the two conventions (unset fields are not written; a cache the file drops is checked by behaviour - the reloaded port must still classify into the same VLAN). docs/CLI.md: the forced rate survives a save. Suite: 204 suites, 7,869 assertions, 0 failed. Syntax: 272 files, OK.