Adjust error messages for new netavark create

c/common uses the new netavark create command, so some of the error messages have slightly changed. Adjust the tests so they pass.

Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
Ashley Cui
2026-04-23 15:36:14 -04:00
parent 09103756cc
commit bb02e49080
4 changed files with 12 additions and 12 deletions

View File

@@ -115,7 +115,7 @@ All drivers accept the `mtu`, `metric`, `no_default_route` and options.
- `mtu`: Sets the Maximum Transmission Unit (MTU) and takes an integer value.
- `metric` Sets the Route Metric for the default route created in every container joined to this network. Accepts a positive integer value. Can only be used with the Netavark network backend.
- `no_default_route`: If set to 1, Podman will not automatically add a default route to subnets. Routes can still be added
- `no_default_route`: If set to true, Podman will not automatically add a default route to subnets. Routes can still be added
manually by creating a custom route using `--route`.
Additionally the `bridge` driver supports the following options:
@@ -196,7 +196,7 @@ $ podman network create --subnet 192.168.33.0/24 --route 10.1.0.0/24,192.168.33.
Create a network with a static subnet and a static route without a default
route.
```
$ podman network create --subnet 192.168.33.0/24 --route 10.1.0.0/24,192.168.33.10 --opt no_default_route=1 newnet
$ podman network create --subnet 192.168.33.0/24 --route 10.1.0.0/24,192.168.33.10 --opt no_default_route=true newnet
```
Create a Macvlan based network using the host interface eth0. Macvlan networks can only be used as root.

View File

@@ -190,7 +190,7 @@ var _ = Describe("Podman network create", func() {
defer removeNetworkDevice(result.NetworkInterface)
})
It("podman network create with name and subnet with --opt no_default_route=1", func() {
It("podman network create with name and subnet with --opt no_default_route=true", func() {
netName := "subnet-" + stringid.GenerateRandomID()
nc := podmanTest.Podman([]string{
"network",
@@ -198,7 +198,7 @@ var _ = Describe("Podman network create", func() {
"--subnet",
"10.19.15.0/24",
"--opt",
"no_default_route=1",
"no_default_route=true",
netName,
})
nc.WaitWithDefaultTimeout()
@@ -405,7 +405,7 @@ var _ = Describe("Podman network create", func() {
ncFail := podmanTest.Podman([]string{"network", "create", netName})
ncFail.WaitWithDefaultTimeout()
Expect(ncFail).To(ExitWithError(125, fmt.Sprintf("network name %s already used: network already exists", netName)))
Expect(ncFail).To(ExitWithError(125, "network already exists"))
})
It("podman network create two networks with same subnet should fail", func() {
@@ -433,13 +433,13 @@ var _ = Describe("Podman network create", func() {
ncFail := podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:4:4:4:4::/64", "--ipv6", netName2})
ncFail.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName2)
Expect(ncFail).To(ExitWithError(125, "subnet fd00:4:4:4::/64 is already used on the host or by another config"))
Expect(ncFail).To(ExitWithError(125, "subnet fd00:4:4:4:4::/64 is already used on the host or by another config"))
})
It("podman network create with invalid network name", func() {
nc := podmanTest.Podman([]string{"network", "create", "2bad!"})
nc.WaitWithDefaultTimeout()
Expect(nc).To(ExitWithError(125, "network name 2bad! invalid: names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: invalid argument"))
Expect(nc).To(ExitWithError(125, "Invalid characters in network name \"2bad!\": must match [a-zA-Z0-9][a-zA-Z0-9_.-]*"))
})
It("podman network create with mtu option", func() {
@@ -471,7 +471,7 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--opt", "foo=bar", net})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(net)
Expect(nc).To(ExitWithError(125, "unsupported bridge network option foo"))
Expect(nc).To(ExitWithError(125, "unsupported bridge network option: foo"))
})
It("podman Netavark network create with internal should have dnsname", func() {
@@ -586,7 +586,7 @@ var _ = Describe("Podman network create", func() {
nc = podmanTest.Podman(networkCreateCommand)
nc.WaitWithDefaultTimeout()
Expect(nc).To(ExitWithError(125, fmt.Sprintf("network name %s already used: network already exists", name)))
Expect(nc).To(ExitWithError(125, fmt.Sprintf("network already exists %s", name)))
})
It("podman network create same name - succeed with ignore", func() {

View File

@@ -1114,7 +1114,7 @@ options ndots:1
nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet, "--subnet", subnet, netName})
nc.WaitWithDefaultTimeout()
Expect(nc).ShouldNot(ExitCleanly())
Expect(nc.ErrorToString()).To(ContainSubstring("duplicate subnets"))
Expect(nc.ErrorToString()).To(ContainSubstring("duplicate subnet"))
})
It("podman network create with same IPv6 subnets", func() {
@@ -1124,7 +1124,7 @@ options ndots:1
nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet, "--subnet", subnet, netName})
nc.WaitWithDefaultTimeout()
Expect(nc).ShouldNot(ExitCleanly())
Expect(nc.ErrorToString()).To(ContainSubstring("duplicate subnets"))
Expect(nc.ErrorToString()).To(ContainSubstring("duplicate subnet"))
})
It("podman network create with overlapping subnets", func() {

View File

@@ -292,7 +292,7 @@ function run_pod_etc_hosts_test(){
# Cannot create network with the same name
run_podman 125 network create $mynetname
is "$output" "Error: network name $mynetname already used: network already exists" \
is "$output" "Error: netavark: network already exists $mynetname" \
"Trying to create an already-existing network"
run_podman rm -t 0 -f $cid