Skip to content

test(netprobe): cover process_netprobe_icmp via handcrafted IcmpLayers#774

Merged
leoparente merged 2 commits into
developfrom
chore/coverage-netprobe-icmp
May 18, 2026
Merged

test(netprobe): cover process_netprobe_icmp via handcrafted IcmpLayers#774
leoparente merged 2 commits into
developfrom
chore/coverage-netprobe-icmp

Conversation

@leoparente
Copy link
Copy Markdown
Contributor

Picks up where #772 left off. `NetProbeMetricsManager::process_netprobe_icmp` was the largest remaining gap in `NetProbeStreamHandler.cpp` after that PR's NetProbe unit tests — it was previously only reached through the network-dependent (now `SKIP`'d) parent tests.

pcap++ exposes `pcpp::IcmpLayer::setEchoRequestData` / `setEchoReplyData` for building a fully-formed ICMP layer in memory, no parsed pcap needed.

Three new TEST_CASEs

Case Flow Asserts
request/reply transaction lifecycle REQUEST id=0x1234 seq=1 → REPLY id=0x1234 seq=1 within TTL attempts=1, successes=1
reply that times out records a failure REQUEST → REPLY 6s later (exceeds default 5s TTL) attempts=1, packets_timeout=1
reply with no prior request is ignored bare REPLY only (no matching REQUEST) no target row created

Together these cover the ECHO_REQUEST branch, both ECHO_REPLY result paths (Valid + TimedOut), and the implicit NotExist no-op — the entire body of `process_netprobe_icmp`.

Out of scope

The original ask also called out `NetflowData.h` / `SflowData.h` (NetFlow v1+v7 PCAPs, sFlow IPv6 samples). Those need new wire-format fixtures (either hand-written byte sequences or a scapy-style generator script). Tracking as a separate task — not bundled here to keep this reviewable.

NetProbeMetricsManager::process_netprobe_icmp was the largest remaining
gap in NetProbeStreamHandler.cpp after the earlier rounds. pcap++
exposes pcpp::IcmpLayer::setEchoRequestData / setEchoReplyData which
build a fully-formed ICMP layer in memory without needing a parsed pcap
packet — perfect for unit tests.

Three new TEST_CASEs build on the existing UnitFixture:

- "request/reply transaction lifecycle": ECHO_REQUEST starts a
  transaction (id+sequence), ECHO_REPLY with the same id+sequence
  closes it within the default 5s TTL → attempts=1, successes=1.
- "reply that times out records a failure": same flow but the reply
  is 6s after the request → maybe_end_transaction returns TimedOut →
  attempts=1, packets_timeout=1.
- "reply with no prior request is ignored": orphan ECHO_REPLY hits
  Result::NotExist → no target row created.

Together these cover the ECHO_REQUEST branch, both ECHO_REPLY result
paths (Valid + TimedOut), and the implicit NotExist no-op — which is
the entire body of process_netprobe_icmp.
@leoparente
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@leoparente leoparente self-assigned this May 18, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

LCOV of commit 17123fa during Debug Builds #119

  lines......: 81.6% (13670 of 16759 lines)
  functions..: 72.7% (1405 of 1933 functions)
  branches...: no data found

Files changed coverage rate: n/a

Full coverage report

Drives one successful TCP transaction and two distinct failure modes
(Timeout, DnsLookupFailure) on separate targets, then asserts the
exact gauge totals emitted by NetProbeMetricsBucket::to_opentelemetry
for netprobe_attempts, netprobe_successes, netprobe_packets_timeout,
netprobe_dns_lookup_failures and netprobe_connect_failures.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@leoparente
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@leoparente leoparente marked this pull request as ready for review May 18, 2026 19:01
@leoparente leoparente merged commit 49a1a08 into develop May 18, 2026
18 checks passed
@leoparente leoparente deleted the chore/coverage-netprobe-icmp branch May 18, 2026 19:13
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