Skip to content

-ptr tests: -max-queries case cannot fail; pool, deadline and failure paths untested #466

Done

Description

@TMHSDigital

Summary

The -ptr pass (new in v0.12.0) has an end-to-end test whose -max-queries case cannot fail, and several of its branches (pool routing, deadline, failure verdict) never run in the suite.

Where

  • internal/cli/ptr_test.go:147 ("-max-queries caps the PTR queries" case)
  • internal/cli/ptr.go:104-107 (cap branch: count 0 under -coverpkg=./...)
  • internal/cli/ptr.go:138, internal/dns/ptr.go:68 ((*Pool).LookupPTR, 0% covered)
  • internal/cli/ptr.go:129, :211 (-max-duration expiry), :225 (refound names)
  • internal/cli/session.go:921, internal/cli/summary.go:76-86 (failed pass verdict)

Details

The fixture produces one address, so the assertion of 1 PTR query holds with the cap deleted.

Impact

A regression in the PTR budget, pool routing, deadline handling or failure verdict ships silently. The verdict and exit code are what CI users gate on with the Action's fail-on.

Suggested fix

Add cases, each against a local dnstest server:

  • 3 public addresses with -ptr -max-queries 2: exactly 2 PTR queries, ptr_addresses 3, and the "left 1 addresses unasked" line.
  • -ptr with a -r pool of two dnstest servers: PTR queries spread over members, and a member answering NXDOMAIN for every PTR stays healthy.
  • Pool with no healthy member: LookupPTR returns "no healthy resolver in the pool" and the pass is not reported complete.
  • -ptr -max-duration that expires mid-pass (slow reverse server): verdict degraded, the reason names -max-duration, and the exit code follows the degraded rule.
  • A PTR pass that fails: run marked failed, summary verdict degraded with the PTR reason.
  • A PTR name already found by -resume is not counted twice in ptr_found.

Getting started

  • Relevant files: internal/cli/ptr.go, internal/cli/ptr_test.go, internal/dnstest
  • How to run tests: go test ./internal/cli -run TestE2EPTR -coverprofile=c.out

Filed by repo-audit/full-audit at a45b999. Severity: medium. Effort: M. audit-key: testing|internal/cli/ptr.go|lookupPTRs

Activity

  1. added
    help wanted
    area: cli
    testing
    severity: medium
    on Nov 29, 2026
  2. TMHSDigital commented on Nov 29, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in f0db944: new tests TestE2EPTRMaxQueriesCapsAddresses (3 addresses, -max-queries 2: exactly 2 PTR queries, ptr_addresses 2, the 'left 1 addresses unasked' line; fails with the cap branch removed), TestE2EPTRThroughPool (PTR queries reach both -r members, and a member answering NXDOMAIN for every PTR leaves the run complete), TestE2EPTRMaxDuration (slow reverse server: the expiry line, verdict degraded naming -max-duration), TestPoolLookupPTRNoHealthyMember, and TestTargetSummaryFailedPTRPass (an unfinished or expired PTR pass gives degraded with the PTR reason). The last checklist item, a PTR name restored by -resume not counted twice, is still covered only by the existing TestPTRResume (the restored hit is not looked up again); I added no ptr_found assertion for it. Gate (gofmt, vet, golangci-lint v2.15.0, full suite) passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: clihelp wantedseverity: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions