test(netprobe): cover process_netprobe_icmp via handcrafted IcmpLayers#774
Merged
Conversation
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.
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
LCOV of commit
|
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>
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
samiura
approved these changes
May 18, 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.
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
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.