1
0
mirror of https://github.com/containers/podman.git synced 2026-02-05 06:45:31 +01:00

Remove CNI-specific test cases

Remove test cases that only tested CNI-specific functionality:
- Remove "podman --cni-config-dir backwards compat" test
- Remove "podman CNI network create with internal should not have dnsname" test

Update CNI-specific test names to be network-backend agnostic:
- Rename "podman inspect container single CNI network" to "podman inspect container single network"
- Rename "podman inspect container two CNI networks (container not running)" to "podman inspect container two networks (container not running)"
- Rename "podman inspect container two CNI networks" to "podman inspect container two networks"
- Rename "podman run in custom CNI network with --static-ip" to "podman run in custom network with --static-ip"
- Rename "podman rootless cni adds /usr/sbin to PATH" to "podman rootless adds /usr/sbin to PATH"

Update test content to be backend-agnostic:
- Update skip reasons from "Requires root CNI networking" to "Requires root networking"
- Change --rootless-cni flag usage to --rootless-netns
- Update comments from "CNI network" to "network"
- Update comments from "iptables" to "nftables" for netavark
- Update test assertions to remove CNI-specific messaging

Remove CNI-related test documentation and comments:
- Remove commented-out CNI error messages from Python API tests
- Remove CNI network namespace error documentation from upgrade tests
- Remove CNI-related comments from BATS tests

Remove unused import of github.com/containernetworking/plugins/pkg/ns
from test/e2e/run_networking_test.go (test-only usage).

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
This commit is contained in:
Lokesh Mandvekar
2025-12-25 13:59:53 -05:00
parent 94f5c3b201
commit 858cb58c90
10 changed files with 17 additions and 74 deletions

View File

@@ -22,21 +22,6 @@ class NetworkTestCase(APITestCase):
"Cmd": ["top"],
"Image": "alpine:latest",
"NetworkDisabled": False,
# FIXME adding these 2 lines cause: (This is sampled from docker-py)
# "network already exists","message":"container
# 01306e499df5441560d70071a54342611e422a94de20865add50a9565fd79fb9 is already connected to CNI
# network \"TestDefaultNetwork\": network already exists"
# "HostConfig": {"NetworkMode": "TestDefaultNetwork"},
# "NetworkingConfig": {"EndpointsConfig": {"TestDefaultNetwork": None}},
# FIXME These two lines cause:
# CNI network \"TestNetwork\" not found","message":"error configuring network namespace for container
# 369ddfa7d3211ebf1fbd5ddbff91bd33fa948858cea2985c133d6b6507546dff: CNI network \"TestNetwork\" not
# found"
# "HostConfig": {"NetworkMode": "TestNetwork"},
# "NetworkingConfig": {"EndpointsConfig": {"TestNetwork": None}},
# FIXME no networking defined cause: (note this error is from the container inspect below)
# "internal libpod error","message":"network inspection mismatch: asked to join 2 CNI network(s) [
# TestDefaultNetwork podman], but have information on 1 network(s): internal libpod error"
},
)
self.assertEqual(create.status_code, 201, create.text)

View File

@@ -341,7 +341,6 @@ var _ = Describe("Podman checkpoint", func() {
Fail("Container failed to get ready")
}
// clunky format needed because CNI uses dashes in net names
IP := podmanTest.Podman([]string{"inspect", cid, fmt.Sprintf("--format={{(index .NetworkSettings.Networks \"%s\").IPAddress}}", netname)})
IP.WaitWithDefaultTimeout()
Expect(IP).Should(ExitCleanly())
@@ -491,7 +490,6 @@ var _ = Describe("Podman checkpoint", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
// clunky format needed because CNI uses dashes in net names
IPBefore := podmanTest.Podman([]string{"inspect", "test_name", fmt.Sprintf("--format={{(index .NetworkSettings.Networks \"%s\").IPAddress}}", netname)})
IPBefore.WaitWithDefaultTimeout()
Expect(IPBefore).Should(ExitCleanly())

View File

@@ -445,7 +445,7 @@ var _ = Describe("Podman inspect", func() {
})
It("Verify container inspect has default network", func() {
SkipIfRootless("Requires root CNI networking")
SkipIfRootless("Requires root networking")
ctrName := "testctr"
session := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
@@ -457,7 +457,7 @@ var _ = Describe("Podman inspect", func() {
})
It("Verify stopped container still has default network in inspect", func() {
SkipIfRootless("Requires root CNI networking")
SkipIfRootless("Requires root networking")
ctrName := "testctr"
session := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "top"})
session.WaitWithDefaultTimeout()

View File

@@ -11,7 +11,6 @@ import (
. "github.com/containers/podman/v6/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"go.podman.io/common/libnetwork/types"
"go.podman.io/storage/pkg/stringid"
)
@@ -523,25 +522,6 @@ var _ = Describe("Podman network create", func() {
Expect(nc).To(ExitWithError(125, "unsupported bridge network option foo"))
})
It("podman CNI network create with internal should not have dnsname", func() {
SkipIfNetavark(podmanTest)
net := "internal-test" + stringid.GenerateRandomID()
nc := podmanTest.Podman([]string{"network", "create", "--internal", net})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(net)
// Cannot ExitCleanly(): "dnsname and internal networks are incompatible"
Expect(nc).Should(Exit(0))
// Not performing this check on remote tests because it is a logrus error which does
// not come back via stderr on the remote client.
if !IsRemote() {
Expect(nc.ErrorToString()).To(ContainSubstring("dnsname and internal networks are incompatible"))
}
nc = podmanTest.Podman([]string{"network", "inspect", net})
nc.WaitWithDefaultTimeout()
Expect(nc).Should(ExitCleanly())
Expect(nc.OutputToString()).ToNot(ContainSubstring("dnsname"))
})
It("podman Netavark network create with internal should have dnsname", func() {
SkipIfCNI(podmanTest)
net := "internal-test" + stringid.GenerateRandomID()

View File

@@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"net"
"path/filepath"
"time"
"github.com/containers/podman/v6/pkg/domain/entities"
@@ -18,16 +17,6 @@ import (
)
var _ = Describe("Podman network", func() {
It("podman --cni-config-dir backwards compat", func() {
SkipIfRemote("--cni-config-dir only works locally")
netDir := filepath.Join(podmanTest.TempDir, "networks123")
session := podmanTest.Podman([]string{"--cni-config-dir", netDir, "network", "ls", "--noheading"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
// default network always exists
Expect(session.OutputToStringArray()).To(HaveLen(1))
})
It("podman network list", func() {
name, path := generateNetworkConfig(podmanTest)
defer removeConf(path)
@@ -247,7 +236,6 @@ var _ = Describe("Podman network", func() {
expectedNetworks := []string{name}
if !isRootless() {
// rootful image contains "podman/cni/87-podman-bridge.conflist" for "podman" network
expectedNetworks = append(expectedNetworks, "podman")
}
session := podmanTest.Podman(append([]string{"network", "inspect"}, expectedNetworks...))
@@ -266,7 +254,7 @@ var _ = Describe("Podman network", func() {
Expect(session.OutputToString()).To(ContainSubstring("bridge"))
})
It("podman inspect container single CNI network", func() {
It("podman inspect container single network", func() {
netName := "net-" + stringid.GenerateRandomID()
network := podmanTest.Podman([]string{"network", "create", "--subnet", "10.50.50.0/24", netName})
network.WaitWithDefaultTimeout()
@@ -294,7 +282,7 @@ var _ = Describe("Podman network", func() {
Expect(net).To(HaveField("IPPrefixLen", 24))
Expect(net.IPAddress).To(HavePrefix("10.50.50."))
// Necessary to ensure the CNI network is removed cleanly
// Necessary to ensure the network is removed cleanly
rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName})
rmAll.WaitWithDefaultTimeout()
Expect(rmAll).Should(ExitCleanly())
@@ -321,7 +309,7 @@ var _ = Describe("Podman network", func() {
}
})
It("podman inspect container two CNI networks (container not running)", func() {
It("podman inspect container two networks (container not running)", func() {
netName1 := "net1-" + stringid.GenerateRandomID()
network1 := podmanTest.Podman([]string{"network", "create", netName1})
network1.WaitWithDefaultTimeout()
@@ -360,13 +348,13 @@ var _ = Describe("Podman network", func() {
net2 := conData[0].NetworkSettings.Networks[netName2]
Expect(net2).To(HaveField("NetworkID", netID2))
// Necessary to ensure the CNI network is removed cleanly
// Necessary to ensure the network is removed cleanly
rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName})
rmAll.WaitWithDefaultTimeout()
Expect(rmAll).Should(ExitCleanly())
})
It("podman inspect container two CNI networks", func() {
It("podman inspect container two networks", func() {
netName1 := "net1-" + stringid.GenerateRandomID()
network1 := podmanTest.Podman([]string{"network", "create", "--subnet", "10.50.51.0/25", netName1})
network1.WaitWithDefaultTimeout()
@@ -409,7 +397,7 @@ var _ = Describe("Podman network", func() {
Expect(net2).To(HaveField("IPPrefixLen", 26))
Expect(net2.IPAddress).To(HavePrefix("10.50.51."))
// Necessary to ensure the CNI network is removed cleanly
// Necessary to ensure the network is removed cleanly
rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName})
rmAll.WaitWithDefaultTimeout()
Expect(rmAll).Should(ExitCleanly())

View File

@@ -1020,7 +1020,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
Expect(session).To(ExitWithError(125, "faccessat /run/netns/xxy: no such file or directory"))
})
It("podman run in custom CNI network with --static-ip", func() {
It("podman run in custom network with --static-ip", func() {
netName := stringid.GenerateRandomID()
ipAddr := "10.25.30.128"
create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.30.0/24", netName})

View File

@@ -85,8 +85,7 @@ host.slirp4netns.executable | $expr_path
@test "podman info - confirm desired network backend" {
if [[ -z "$CI_DESIRED_NETWORK" ]]; then
# When running on RHEL, CI_DESIRED_NETWORK *must* be defined
# in gating.yaml because some versions of RHEL use CNI, some
# use netavark.
# in gating.yaml for RHEL testing.
local osrelease=/etc/os-release
if [[ -e $osrelease ]]; then
local osname=$(source $osrelease; echo $NAME)

View File

@@ -286,7 +286,7 @@ load helpers.network
# FIXME: debugging for #11871
run_podman exec $cid cat /etc/resolv.conf
if is_rootless && ! is_remote; then
run_podman unshare --rootless-cni cat /etc/resolv.conf
run_podman unshare --rootless-netns cat /etc/resolv.conf
fi
ps uxww
@@ -430,15 +430,15 @@ load helpers.network
}
# bats test_tags=ci:parallel
@test "podman rootless cni adds /usr/sbin to PATH" {
@test "podman rootless adds /usr/sbin to PATH" {
is_rootless || skip "only meaningful for rootless"
local mynetname=testnet-$(safename)
run_podman --noout network create $mynetname
is "$output" "" "output should be empty"
# Test that rootless cni adds /usr/sbin to $PATH
# iptables is located under /usr/sbin and is needed for the CNI plugins.
# Test that rootless podman adds /usr/sbin to $PATH
# nftables is located under /usr/sbin and is needed for netavark.
# Debian doesn't add /usr/sbin to $PATH for rootless users so we have to add it.
PATH=/usr/local/bin:/usr/bin run_podman run --rm --network $mynetname $IMAGE ip addr
is "$output" ".*eth0.*" "Interface eth0 not found in ip addr output"
@@ -473,7 +473,7 @@ load helpers.network
assert "$output" =~ "$ipv6_regex" "resolv.conf should contain ipv6 nameserver"
fi
# ipv4 cni
# ipv4 network
local mysubnet=$(random_rfc1918_subnet)
local netname=testnet1-$(safename)
@@ -485,7 +485,7 @@ load helpers.network
run_podman network rm -t 0 -f $netname
# ipv6 cni
# ipv6 network
mysubnet=fd00:4:4:4:4::/64
netname=testnet2-$(safename)

View File

@@ -67,13 +67,6 @@ I realize that it's kind of stupid not to test 1.6, since that's
precisely the test that would've caught #8613 early, but I just
don't think it's worth the hassle of setting up cgroupsv1 VMs.
For posterity, in an earlier incantation of this script I tried
booting f32 into cgroupsv1 and ran into the following warnings
when running new-podman on old-containers:
```
ERRO[0000] error joining network namespace for container 322b66d94640e31b2e6921565445cf0dade4ec13cabc16ee5f29292bdc038341: error retrieving network namespace at /var/run/netns/cni-577e2289-2c05-2e28-3c3d-002a5596e7da: failed to Statfs "/var/run/netns/cni-577e2289
```
Where To Go From Here
=====================

View File

@@ -197,7 +197,7 @@ EOF
@test "info - network" {
run_podman info --format '{{.Host.NetworkBackend}}'
assert "$output" = "netavark" "As of Feb 2024, CNI will never be default"
assert "$output" = "netavark" "Netavark is the only supported network backend"
}
# Whichever DB was picked by old_podman, make sure we honor it