Skip to content

test(flow): cover NetFlow v1/v7 and sFlow IPv6 parse paths#775

Merged
leoparente merged 3 commits into
developfrom
chore/coverage-flow-fixtures
May 18, 2026
Merged

test(flow): cover NetFlow v1/v7 and sFlow IPv6 parse paths#775
leoparente merged 3 commits into
developfrom
chore/coverage-flow-fixtures

Conversation

@leoparente
Copy link
Copy Markdown
Contributor

Summary

  • Adds three minimal hand-rolled pcap fixtures — nf1.pcap, nf7.pcap, sflow_ipv6.pcap — under src/tests/fixtures/.
  • Adds three test cases in src/handlers/flow/test_flows.cpp that drive FlowInputStream against each fixture.
  • Targets parser arms not previously exercised: NetflowData.h version-1 and version-7 dispatch (case 1/case 7 at lines 686-691), and SflowData.h's decodeIPV6() path for SFLADDRESSTYPE_IP_V6 sampled headers.

Test plan

  • unit-tests-handler-flow "Parse netflow v1 stream" passes
  • unit-tests-handler-flow "Parse netflow v7 stream" passes
  • unit-tests-handler-flow "Parse sflow IPv6 sample" passes
  • CI green

Adds three minimal hand-rolled pcap fixtures (nf1.pcap, nf7.pcap,
sflow_ipv6.pcap) and accompanying test cases that exercise dispatch
arms in NetflowData.h (versions 1 and 7) and the IPv6 sampled-header
path in SflowData.h. Existing flow tests only cover v5/v9/IPFIX and
sFlow with IPv4 payloads.

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

@codex review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

LCOV of commit 7a04354 during Debug Builds #124

  lines......: 82.7% (13927 of 16844 lines)
  functions..: 73.0% (1414 of 1937 functions)
  branches...: no data found

Files changed coverage rate: n/a

Full coverage report

Adds sflow_keyed.pcap, a single sFlow v5 datagram with two flow_samples
whose elements use tag=3 (SFLFLOW_IPV4) and tag=4 (SFLFLOW_IPV6) — the
key-only sampled-flow formats that exercise readFlowSample_IPv4 and
readFlowSample_IPv6 in SflowData.h. Previous sflow fixtures only carried
SFLFLOW_HEADER (tag=1) elements, so those two decoders were uncovered.

Asserts that the resulting per-interface metrics reflect both elements:
one IPv4 TCP flow (1500 bytes) and one IPv6 UDP flow (1280 bytes).

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. Keep them coming!

ℹ️ 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
@leoparente leoparente marked this pull request as ready for review May 18, 2026 19:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 853f87bee2

ℹ️ 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".

Comment thread src/handlers/flow/test_flows.cpp Outdated
samiura
samiura previously approved these changes May 18, 2026
Codex pointed out that the IPv6 sflow test asserted only
records_flows >= 1, which would pass even if decodeIPV6 regressed.
Investigating uncovered a real bug in the original fixture: it set
SFLHEADER_IPv6 to 11 (which is SFLHEADER_IPv4), so the parser took
the IPv4 branch and decodeIPV6 never ran.

Regenerates sflow_ipv6.pcap with header_protocol=12 and asserts the
IPv6/UDP per-interface counters land in their IPv6 buckets.

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 requested a review from samiura May 18, 2026 20:10
@leoparente leoparente merged commit 86f1b13 into develop May 18, 2026
18 checks passed
@leoparente leoparente deleted the chore/coverage-flow-fixtures branch May 18, 2026 20:20
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