Skip to content

test: pin Walk and BulkWalk against an in-memory MIB agent - #39

Merged
ilyam8 merged 1 commit into
masterfrom
engine-walk
Oct 11, 2026
Merged

ilyam8 merged 1 commit into
masterfrom
engine-walk

Conversation

@ilyam8

@ilyam8 ilyam8 commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Third safety net for the request engine: what Walk, BulkWalk, WalkAll and BulkWalkAll request and return, known bugs included, so the decomposition of walk is measured against it. Test files only, no library change.

  • engine_walk_test.go: mibAgent, an in-memory v1/v2c agent on the engine harness. It answers Get, GetNext and GetBulk from a sorted MIB as RFC 3416 section 4.2 and RFC 1157 section 4.1 do: SNMPv2c exception values, SNMPv1 noSuchName with its index and the request's varbinds, GetBulk repetitions truncated after the one in which every repeater reached endOfMibView (RFC 3416 section 4.2.3). Any answer can be changed or dropped.
  • testdata/engine/walk.golden (63 scenarios): subtrees, a table column, the default root, a root without the leading dot, roots past the MIB and empty subtrees for Walk, BulkWalk and SNMPv1; the leaf fallback to a Get (value, noSuchInstance, noSuchObject, v1 noSuchName, walkFn error, the MIB's last object); every error status and one the walk does not name; empty responses; the increasing check (equal and decreasing OIDs, a decrease inside one GetBulk response, AppOpts c for GetNext and GetBulk); exception values mid-walk; the root itself in a GetBulk answer; request errors with the partial WalkAll results; MaxRepetitions 1, 2 and the default 50; walkFn errors; a v1 BulkWalk.

Known bugs pinned with known bug: notes, compared with net-snmp's snmpwalk (v5.9.3, apps/snmpwalk.c): an error status other than noSuchName ends the walk with a nil error and the values so far (snmpwalk reports it); a status the walk does not name is ignored; the increasing check compares each OID with the request's, not with the previous one; a leaf root that is the MIB's last object returns nothing (snmpwalk makes the Get for a v1 noSuchName); an answer naming the root itself skips the increasing check, reaches walkFn and ends the walk; an empty response ends the walk with a nil error.

Testing

  • go test ./... on darwin/arm64 and GOARCH=386; -race; -shuffle=on; 100 consecutive runs and -cpu 1,8,64 identical; golangci-lint v2.14.0: 0 issues.
  • Mutation probes on walk.go (each error-status case, the exception types, the leaf fallback, the root-equal branch, the increasing check and AppOpts c, the defaults, walkFn errors, walkAll, v1 GetBulk): 46 of 48 caught; the two survivors are a dead condition (the exception check above returns first) and the unsupported request type walk is never called with.
  • Coverage of the root package: walk 0% -> 98.9% (the unreachable branch), walkAll, Walk, WalkAll, BulkWalk and BulkWalkAll 0% -> 100%; package 87.1% -> 93.2%.

@ilyam8
ilyam8 added this pull request to stack #38 October 9, 2026 13:19
Base automatically changed from engine-v3 to master October 11, 2026 09:46
Before the walk is decomposed, pin what Walk, BulkWalk, WalkAll and
BulkWalkAll request and return, known bugs included.

mibAgent answers Get, GetNext and GetBulk from a sorted MIB as RFC 3416
section 4.2 and RFC 1157 section 4.1 do (SNMPv2c exception values, SNMPv1
noSuchName with its index and the request's varbinds, GetBulk repetitions
truncated once every repeater reached endOfMibView) and can change any answer.
testdata/engine/walk.golden holds 63 scenarios on the engine harness: subtrees,
a table column, the default root, a root without the leading dot, roots past
the MIB and empty subtrees, for Walk, BulkWalk and SNMPv1; the leaf fallback to
a Get (value, noSuchInstance, noSuchObject, v1 noSuchName, walkFn error, the
MIB's last object); every error status and one the walk does not name; empty
responses; the increasing check (equal and decreasing OIDs, a decrease inside
one GetBulk response, AppOpts "c" for GetNext and GetBulk); exception values
mid-walk; the root itself in a GetBulk answer; request errors with the partial
WalkAll results; MaxRepetitions 1, 2 and the default 50; walkFn errors; and a
v1 BulkWalk.

Known bugs pinned, compared with net-snmp's snmpwalk: an error status other
than noSuchName ends the walk with a nil error and the values so far (snmpwalk
reports it); a status the walk does not name is ignored; the increasing check
compares each OID with the request's, not with the previous one; a leaf root
that is the MIB's last object returns nothing (snmpwalk makes the Get for a v1
noSuchName); an answer naming the root itself skips the increasing check,
reaches walkFn and ends the walk; an empty response ends the walk with a nil
error.
@ilyam8
ilyam8 merged commit 8a2d664 into master Oct 11, 2026
21 checks passed
@ilyam8
ilyam8 deleted the engine-walk branch October 11, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants