Repository navigation
test: pin Walk and BulkWalk against an in-memory MIB agent - #39
Merged
Merged
Conversation
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.
stelfrag
approved these changes
Oct 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Third safety net for the request engine: what
Walk,BulkWalk,WalkAllandBulkWalkAllrequest and return, known bugs included, so the decomposition ofwalkis 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, AppOptscfor GetNext and GetBulk); exception values mid-walk; the root itself in a GetBulk answer; request errors with the partialWalkAllresults;MaxRepetitions1, 2 and the default 50; walkFn errors; a v1 BulkWalk.Known bugs pinned with
known bug:notes, compared with net-snmp'ssnmpwalk(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 andGOARCH=386;-race;-shuffle=on; 100 consecutive runs and-cpu 1,8,64identical; golangci-lint v2.14.0: 0 issues.walk.go(each error-status case, the exception types, the leaf fallback, the root-equal branch, the increasing check and AppOptsc, 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 typewalkis never called with.walk0% -> 98.9% (the unreachable branch),walkAll,Walk,WalkAll,BulkWalkandBulkWalkAll0% -> 100%; package 87.1% -> 93.2%.