integration: Add a new networking integration test suite #46531
integration: Add a new networking integration test suite #46531thaJeztah merged 2 commits intomoby:masterfrom
Conversation
| const bridge1Opts = "bridge1" | ||
| const bridge2Opts = "bridge2" |
There was a problem hiding this comment.
Nit: define a struct type instead of using maps with a fixed set of keys. Types can be declared inside a function body, BTW.
There was a problem hiding this comment.
Types can be declared inside a function body, BTW.
Yeah, I was hesitant on this one; didn't know what approach would be more idiomatic. Will fix that.
6ca3ccc to
71857cf
Compare
|
DOH! Looks like there's some failures though. So the good news; "tests are testing", The bad news.. something's failing; ☝️ Also wondering if |
e927e0f to
e71b692
Compare
d2d07e8 to
65760ae
Compare
1766768 to
9882c65
Compare
9882c65 to
ce61164
Compare
ce61164 to
e6a6c0b
Compare
| bridge1Opts: []func(*types.NetworkCreate){network.WithInternal()}, | ||
| bridge2Opts: []func(*types.NetworkCreate){network.WithInternal()}, | ||
| }, | ||
| stderr: "sendto: Network is unreachable", |
There was a problem hiding this comment.
@corhere @thaJeztah Since #46603 has been merged, the error for such case has changed from "no response" to "network is unreachable".
| assert.Check(t, res.ExitCode == 0) | ||
| assert.Check(t, res.Stderr.Len() == 0) |
There was a problem hiding this comment.
| assert.Check(t, res.ExitCode == 0) | |
| assert.Check(t, res.Stderr.Len() == 0) | |
| assert.Check(t, is.Equal(res.ExitCode, 0)) | |
| assert.Check(t, is.Equal(res.Stderr.Len(), 0)) |
This is kinda repetitive. Have you considered extracting these assertions to a test helper function?
e6a6c0b to
ebd96ee
Compare
|
@corhere I coalesced both |
ebd96ee to
ddab566
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM, but left one tiny comment
(CI is currently happy, so once that's addressed we can bring this one in)
integration/networking/main_test.go
Outdated
| func TestMain(m *testing.M) { | ||
| shutdown := testutil.ConfigureTracing() | ||
| ctx, span := otel.Tracer("").Start(context.Background(), "integration/network.TestMain") | ||
| ctx, span := otel.Tracer("").Start(context.Background(), "integration/networking.TestMain") |
There was a problem hiding this comment.
I guess this was meant to be in the first commit 🙈
This commit introduces a new integration test suite aimed at testing networking features like inter-container communication, network isolation, port mapping, etc... and how they interact with daemon-level and network-level parameters. So far, there's pretty much no tests making sure our networks are well configured: 1. there're a few tests for port mapping, but they don't cover all use cases ; 2. there're a few tests that check if a specific iptables rule exist, but that doesn't prevent that specific iptables rule to be wrong in the first place. As we're planning to refactor how iptables rules are written, and change some of them to fix known security issues, we need a way to test all combinations of parameters. So far, this was done by hand, which is particularly painful and time consuming. As such, this new test suite is foundational to upcoming work. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Following tests are implemented in this specific commit: - Inter-container communications for internal and non-internal bridge networks, over IPv4 and IPv6. - Inter-container communications using IPv6 link-local addresses for internal and non-internal bridge networks. - Inter-network communications for internal and non-internal bridge networks, over IPv4 and IPv6, are disallowed. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
ddab566 to
c1ab6ed
Compare
- What I did
This PR introduces a new integration test suite aimed at testing networking features like inter-container communication, network isolation, port mapping, what happens when the userland proxy is enabled or disabled, etc... and how these features interact with daemon-level and network-level parameters.
So far, there's pretty much no tests making sure our networks are working as expected. For instance, there's a few tests for port mapping, but they don't cover all cases (eg. IPv6, disabling the userland proxy, etc...), and a few tests check if a specific iptables rule exists, but that doesn't prevent that specific rule from be wrong in the first place.
As we're planning to refactor how iptables rules are written and change some of them to fix known security issues, we need a way to test all parameter combinations (at least, the important ones). So far, this was done by hand which is painful and time consuming. As such, this new test suite is foundational to upcoming work.
This test suite should help:
Following tests are implemented in this PR:
- How to verify it
CI is green.
- A picture of a cute animal (not mandatory but encouraged)