Skip to content

Introduce additional test coverage for datapath connector#44079

Merged
ti-mo merged 5 commits intocilium:mainfrom
ajmmm:pr/datapath-mode-auto-3-tests
Feb 24, 2026
Merged

Introduce additional test coverage for datapath connector#44079
ti-mo merged 5 commits intocilium:mainfrom
ajmmm:pr/datapath-mode-auto-3-tests

Conversation

@ajmmm
Copy link
Copy Markdown
Member

@ajmmm ajmmm commented Jan 30, 2026

Does what it says on the tin.

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jan 30, 2026
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Jan 30, 2026

/test

@ajmmm ajmmm force-pushed the pr/datapath-mode-auto-3-tests branch from fcb1549 to acc2f65 Compare February 2, 2026 09:58
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Feb 2, 2026

/test

@ajmmm ajmmm marked this pull request as ready for review February 2, 2026 10:06
@ajmmm ajmmm requested review from a team as code owners February 2, 2026 10:06
@ajmmm ajmmm requested review from aditighag and ti-mo February 2, 2026 10:06
Copy link
Copy Markdown
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Thanks! Left a few comments.

@ajmmm ajmmm force-pushed the pr/datapath-mode-auto-3-tests branch from acc2f65 to ba21597 Compare February 2, 2026 18:02
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Feb 2, 2026

/test

@ajmmm ajmmm force-pushed the pr/datapath-mode-auto-3-tests branch from ba21597 to 3c338e0 Compare February 2, 2026 18:10
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Feb 2, 2026

/test

@ajmmm ajmmm requested a review from ti-mo February 2, 2026 18:13
Copy link
Copy Markdown
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Thanks for the changes so far. All asserts in a ns.Do() will need to be moved out ('need' as in 'hard to debug when things do start failing'). From looking at a few snippets of test code, there's a lot of:

ns.Do(func() error {
	ctl := sysctl.NewDirectSysctl(afero.NewOsFs(), "/proc")
	hostLink, peerLink, err := setupVethPair(log, tt.cfg, ctl)

... asserts and open-coded netlink calls ...
}

You have a few options to improve this:

  • Make setupVethPair and friends take an (optional?) netlink.Handle, but this will involve some refactoring, and may not make work due to also managing sysctls there.
  • Pass a netns.NetNS to the functions under test, but I'd consider that strictly worse than the netlink.Handle option.
  • Multiple ns.Do() blocks in tests, but this will get messy and invites bugs with variable shadowing.
  • My preferred option: call safenetlink.NewHandle() at the end of ns.Do() and use the handle in the outer test scope to interact with the netlink socket in the netns from the host netns. Haven't read all the test code in detail to know if this makes sense in all cases, but applies pretty broadly. I prioritize minimizing the amount of code within a ns.Do() to make bugs/mistakes as obvious as possible, even if it means refactoring, but use your own judgement ofc.

This would turn the above into:

var h *netlink.Handle
require.NoError(t, ns.Do(func() error {
	ctl := sysctl.NewDirectSysctl(afero.NewOsFs(), "/proc")
	hostLink, peerLink, err := setupVethPair(log, tt.cfg, ctl)
	if err != nil {
		return fmt.Errorf("setting up veth pair: %w", err)
	}

	h, err = safenetlink.NewHandle(nil)
	if err != nil {
		return err
	}
})

hl1,err := h.LinkByName(...)
assert.True(
... etc. ...

@joestringer joestringer removed the request for review from aditighag February 4, 2026 20:01
@ajmmm ajmmm force-pushed the pr/datapath-mode-auto-3-tests branch from 3c338e0 to 663668a Compare February 5, 2026 13:07
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Feb 5, 2026

/test

@ajmmm ajmmm force-pushed the pr/datapath-mode-auto-3-tests branch from 663668a to a91fe5d Compare February 5, 2026 13:50
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Feb 5, 2026

/test

@ajmmm ajmmm requested a review from ti-mo February 5, 2026 14:36
@ti-mo ti-mo added the release-note/misc This PR makes changes that have no direct user impact. label Feb 10, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 10, 2026
@ajmmm ajmmm force-pushed the pr/datapath-mode-auto-3-tests branch from a91fe5d to f1a9f85 Compare February 12, 2026 09:38
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Feb 12, 2026

/test

@ajmmm ajmmm force-pushed the pr/datapath-mode-auto-3-tests branch from f1a9f85 to 9897dc0 Compare February 20, 2026 17:33
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Feb 20, 2026

/test

Previously the connector newConfig() routine would error under certain
conditions, for example if the provided user config was not viable. This
changed with the introduction of automatic datapath mode, but the tests
didn't properly reflect this change.

This commit tweaks tests that call newConfig() test to better reflect the
error handling of that function.

This commit also modifies the logic of CalculateTunedBufferMargins() test
to utilise a namespace per test to isolate interfaces from the underlying
host. The fake interfaces are now created once at startup, to query the
values that the buffer margins the host kernel will use, and also on
each test iteration.

Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
Introduce test that verifies the datapath connector rejects unsupported
datapath modes.

Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
Add additional testing for link pairs, which also moves existing
test logic to use temporary namespaces.

Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
Introduce testing that verifies netkit setup is correct. This doesn't
probe too far, because we don't want to start testing the kernel. We
are primarily looking that the netkit driver is running in the right
mode, with the right settings.

This also introduces an additional probe to check if the host supports
tunable buffer margins on netkit devices. Requires kernel 6.18.

Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
Introduce some basic testing on the veth connector too. Like netkit, we
don't probe too far, because we don't want to start testing the kernel.

Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
@ajmmm ajmmm force-pushed the pr/datapath-mode-auto-3-tests branch from 9897dc0 to 4e2bb6f Compare February 23, 2026 14:45
@ajmmm
Copy link
Copy Markdown
Member Author

ajmmm commented Feb 23, 2026

/test

Copy link
Copy Markdown
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Thanks!

@ti-mo ti-mo enabled auto-merge February 23, 2026 15:49
@julianwiedmann julianwiedmann removed the release-note/misc This PR makes changes that have no direct user impact. label Feb 24, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 24, 2026
@julianwiedmann julianwiedmann added area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/ci This PR makes changes to the CI. and removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Feb 24, 2026
Copy link
Copy Markdown
Member

@julianwiedmann julianwiedmann left a comment

Choose a reason for hiding this comment

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

lgtm, thank you!

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 24, 2026
@julianwiedmann
Copy link
Copy Markdown
Member

There's a bunch of unresolved comments, then this should auto-merge.

@ti-mo ti-mo added this pull request to the merge queue Feb 24, 2026
Merged via the queue into cilium:main with commit 3c42381 Feb 24, 2026
77 checks passed
@ajmmm ajmmm deleted the pr/datapath-mode-auto-3-tests branch February 24, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/ci This PR makes changes to the CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants