Skip to content

cnff-network: Added ipforwarding tests#1333

Open
evgenLevin wants to merge 1 commit intorh-ecosystem-edge:mainfrom
evgenLevin:ipforwatrding
Open

cnff-network: Added ipforwarding tests#1333
evgenLevin wants to merge 1 commit intorh-ecosystem-edge:mainfrom
evgenLevin:ipforwatrding

Conversation

@evgenLevin
Copy link
Copy Markdown
Collaborator

@evgenLevin evgenLevin commented Apr 14, 2026

Summary by CodeRabbit

  • Tests

    • Added comprehensive test suite for IP forwarding validation with MetalLB and BGP connectivity.
    • Added helper functions for network configuration policy testing.
  • Chores

    • Updated ecosystem module dependency to the latest version.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

Warning

Rate limit exceeded

@evgenLevin has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 1 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 1 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0c11b826-6277-4058-ba65-877eb9e22651

📥 Commits

Reviewing files that changed from the base of the PR and between 46314e1 and d0b7f8d.

📒 Files selected for processing (3)
  • tests/cnf/core/network/internal/netnmstate/netnmstate.go
  • tests/cnf/core/network/metallb/internal/tsparams/consts.go
  • tests/cnf/core/network/metallb/tests/ip-forwarding.go
📝 Walkthrough

Walkthrough

The pull request updates the eco-goinfra module dependency to a newer commit version and adds new NMState policy helpers for configuring IPv4/IPv6 interface forwarding. A comprehensive MetalLB and BGP connectivity test suite is introduced to validate IP forwarding controls across multiple scenarios and interfaces.

Changes

Cohort / File(s) Summary
Dependency Update
go.mod
Updated github.com/rh-ecosystem-edge/eco-goinfra pinned version from v0.0.0-20260409141811-844d58190e06 to v0.0.0-20260414160522-87e98cb3a528.
Network State Helpers
tests/cnf/core/network/internal/netnmstate/netnmstate.go
Added exported functions WithInterfaceIPv4Forwarding, WithInterfaceIPv6Forwarding, and UpdatePolicyAndWaitUntilItsDegraded for NMState policy mutation. Introduced shared withInterfaceForwardingMutator helper that validates, unmarshals, locates interfaces, applies mutations, and marshals policy state back.
IP Forwarding Test Suite
tests/cnf/core/network/metallb/tests/ip-forwarding.go
New end-to-end test suite validating MetalLB + BGP (FRR-based) connectivity with per-interface IP forwarding controls. Tests verify routing behavior via NMState policies and global IP forwarding settings across IPv4 and IPv6, including edge cases like worker reboots and traffic failures when forwarding is disabled.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: adding IP forwarding tests for the CNF network test suite.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/cnf/core/network/internal/netnmstate/netnmstate.go (1)

420-435: Minor API inconsistency with existing update function.

UpdatePolicyAndWaitUntilItsDegraded returns (*nmstate.PolicyBuilder, error) while the existing UpdatePolicyAndWaitUntilItsAvailable (line 77) returns only error. Consider aligning the signatures for consistency, or document why the differing return types are intentional.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/cnf/core/network/internal/netnmstate/netnmstate.go` around lines 420 -
435, The function UpdatePolicyAndWaitUntilItsDegraded currently returns
(*nmstate.PolicyBuilder, error) while the existing
UpdatePolicyAndWaitUntilItsAvailable returns only error; make the API consistent
by choosing one signature and updating code accordingly. Either change
UpdatePolicyAndWaitUntilItsDegraded to return only error (update its signature,
remove nmstatePolicy from the return, and ensure callers of
UpdatePolicyAndWaitUntilItsDegraded are adjusted) or change
UpdatePolicyAndWaitUntilItsAvailable to return (*nmstate.PolicyBuilder, error)
and propagate the builder where needed; locate the functions
UpdatePolicyAndWaitUntilItsDegraded and UpdatePolicyAndWaitUntilItsAvailable and
the nmstate.PolicyBuilder usages to perform the corresponding signature and
caller updates.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/cnf/core/network/metallb/tests/ip-forwarding.go`:
- Around line 324-325: The test is accidentally marked as focused using FIt
which will skip other tests; change the test declaration from FIt("Basic
functionality with MetalLB", reportxml.ID("80340"), func() { ... }) to a normal
It invocation (It("Basic functionality with MetalLB", reportxml.ID("80340"),
func() { ... })) so the test runs normally with the suite; update the occurrence
of FIt to It in the test function definition to remove the focus artifact.
- Around line 583-586: The IPv6 Context's AfterAll only calls cleanupIPFwdNNCP
and omits cleanupIPFwdContextResources, leaving BGP peers/IP
pools/advertisements/services created in the IPv6 BeforeAll uncleaned; update
the IPv6 Context AfterAll to call cleanupIPFwdContextResources() in addition to
cleanupIPFwdNNCP (same order/arguments used in the IPv4 Context AfterAll) so all
context resources created in BeforeAll are properly torn down.

---

Nitpick comments:
In `@tests/cnf/core/network/internal/netnmstate/netnmstate.go`:
- Around line 420-435: The function UpdatePolicyAndWaitUntilItsDegraded
currently returns (*nmstate.PolicyBuilder, error) while the existing
UpdatePolicyAndWaitUntilItsAvailable returns only error; make the API consistent
by choosing one signature and updating code accordingly. Either change
UpdatePolicyAndWaitUntilItsDegraded to return only error (update its signature,
remove nmstatePolicy from the return, and ensure callers of
UpdatePolicyAndWaitUntilItsDegraded are adjusted) or change
UpdatePolicyAndWaitUntilItsAvailable to return (*nmstate.PolicyBuilder, error)
and propagate the builder where needed; locate the functions
UpdatePolicyAndWaitUntilItsDegraded and UpdatePolicyAndWaitUntilItsAvailable and
the nmstate.PolicyBuilder usages to perform the corresponding signature and
caller updates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bf6fd7f4-6811-47c3-84e7-9b9bd5680d9b

📥 Commits

Reviewing files that changed from the base of the PR and between fe63d23 and 46314e1.

⛔ Files ignored due to path filters (5)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/rh-ecosystem-edge/eco-goinfra/pkg/network/operator.go is excluded by !vendor/**
  • vendor/github.com/rh-ecosystem-edge/eco-goinfra/pkg/nmstate/policy.go is excluded by !vendor/**
  • vendor/github.com/rh-ecosystem-edge/eco-goinfra/pkg/nmstate/shared.go is excluded by !vendor/**
  • vendor/modules.txt is excluded by !vendor/**
📒 Files selected for processing (3)
  • go.mod
  • tests/cnf/core/network/internal/netnmstate/netnmstate.go
  • tests/cnf/core/network/metallb/tests/ip-forwarding.go

Comment thread tests/cnf/core/network/metallb/tests/ip-forwarding.go Outdated
Comment thread tests/cnf/core/network/metallb/tests/ip-forwarding.go
@evgenLevin evgenLevin force-pushed the ipforwatrding branch 2 times, most recently from 858ab82 to 5b68fcd Compare April 15, 2026 16:33
const (
labelIPForwardingTestCases = "ipforwarding"
ipFwdNNCPName = "ip-fwd-policy"
ipFwdBridgeNADName = "internal"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few of these const we already have in metallb/internal/consts.go

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

replaced

sriovInterfaces, err = NetConfig.GetSriovInterfaces(2)
if err != nil || len(sriovInterfaces) < 2 {
Skip("Skipping: need at least 2 SR-IOV interfaces for IP forwarding test")
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}
secInterfaces, err = NetConfig.GetSriovInterfaces(2)
if err != nil || len(secInterfaces) < 2 {
Skip("Skipping: need at least 2 secondary interfaces for IP forwarding test")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

changed

state2, _ := frr.BGPNeighborshipHasState(frrRouter2, neighborIP2, "Established")

return state1 && state2
}, 4*time.Minute, tsparams.DefaultRetryInterval).Should(BeTrue(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}, 4*time.Minute, tsparams.DefaultRetryInterval).Should(BeTrue(),
}, 3*time.Minute, tsparams.DefaultRetryInterval).Should(BeTrue(),

slightly more than 2 mins should be enough for bgp sessions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

changed

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.

3 participants