Introduce additional test coverage for datapath connector#44079
Merged
ti-mo merged 5 commits intocilium:mainfrom Feb 24, 2026
Merged
Introduce additional test coverage for datapath connector#44079ti-mo merged 5 commits intocilium:mainfrom
ti-mo merged 5 commits intocilium:mainfrom
Conversation
Member
Author
|
/test |
fcb1549 to
acc2f65
Compare
Member
Author
|
/test |
ti-mo
reviewed
Feb 2, 2026
Contributor
ti-mo
left a comment
There was a problem hiding this comment.
Thanks! Left a few comments.
acc2f65 to
ba21597
Compare
Member
Author
|
/test |
ba21597 to
3c338e0
Compare
Member
Author
|
/test |
ti-mo
requested changes
Feb 3, 2026
Contributor
ti-mo
left a comment
There was a problem hiding this comment.
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
setupVethPairand 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. ...3c338e0 to
663668a
Compare
Member
Author
|
/test |
663668a to
a91fe5d
Compare
Member
Author
|
/test |
a91fe5d to
f1a9f85
Compare
Member
Author
|
/test |
f1a9f85 to
9897dc0
Compare
Member
Author
|
/test |
ti-mo
reviewed
Feb 23, 2026
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>
9897dc0 to
4e2bb6f
Compare
Member
Author
|
/test |
Member
|
There's a bunch of unresolved comments, then this should auto-merge. |
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.
Does what it says on the tin.