mirror of
https://github.com/containers/podman.git
synced 2025-12-03 11:49:18 +08:00
Since commit f250560a80 the play kube command uses its own network.
this is racy be design because we create the network followed by
creating/running pod/containers. This means in the meantime another
prune or reset process could wipe out the network config because we have
to share the network config directory by design in the test.
The problem is we only have one host netns which is shared between
tests. If the network config dir is not shared we cannot make conflict
checks for interface names and ip address. This results in different
tests trying to use the same interface and/or ip address which will
cause runtime failures in CNI and netavark.
The only solution I see is to make sure only the reset/prune tests are
using a custom network dir. This makes sure they do not wipe configs
that are otherwise required by other parallel running tests.
Fixes #17946
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
102 lines
3.1 KiB
Go
102 lines
3.1 KiB
Go
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
. "github.com/containers/podman/v4/test/utils"
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
. "github.com/onsi/gomega/gexec"
|
|
)
|
|
|
|
var _ = Describe("podman system reset", func() {
|
|
var (
|
|
tempdir string
|
|
err error
|
|
podmanTest *PodmanTestIntegration
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
tempdir, err = CreateTempDirInTempDir()
|
|
if err != nil {
|
|
os.Exit(1)
|
|
}
|
|
podmanTest = PodmanTestCreate(tempdir)
|
|
podmanTest.Setup()
|
|
})
|
|
|
|
AfterEach(func() {
|
|
podmanTest.Cleanup()
|
|
f := CurrentGinkgoTestDescription()
|
|
timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
|
|
_, _ = GinkgoWriter.Write([]byte(timedResult))
|
|
})
|
|
|
|
It("podman system reset", func() {
|
|
SkipIfRemote("system reset not supported on podman --remote")
|
|
// system reset will not remove additional store images, so need to grab length
|
|
useCustomNetworkDir(podmanTest, tempdir)
|
|
|
|
session := podmanTest.Podman([]string{"rmi", "--force", "--all"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
session = podmanTest.Podman([]string{"images", "-n"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
l := len(session.OutputToStringArray())
|
|
|
|
podmanTest.AddImageToRWStore(ALPINE)
|
|
session = podmanTest.Podman([]string{"volume", "create", "data"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
session = podmanTest.Podman([]string{"create", "-v", "data:/data", ALPINE, "echo", "hello"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
session = podmanTest.Podman([]string{"network", "create"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
session = podmanTest.Podman([]string{"system", "reset", "-f"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
Expect(session.ErrorToString()).To(Not(ContainSubstring("Failed to add pause process")))
|
|
Expect(session.ErrorToString()).To(Not(ContainSubstring("/usr/share/containers/storage.conf")))
|
|
|
|
session = podmanTest.Podman([]string{"images", "-n"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
Expect(session.OutputToStringArray()).To(HaveLen(l))
|
|
|
|
session = podmanTest.Podman([]string{"volume", "ls"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
Expect(session.OutputToStringArray()).To(BeEmpty())
|
|
|
|
session = podmanTest.Podman([]string{"container", "ls", "-q"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
Expect(session.OutputToStringArray()).To(BeEmpty())
|
|
|
|
session = podmanTest.Podman([]string{"network", "ls", "-q"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
// default network should exists
|
|
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
|
|
|
// TODO: machine tests currently don't run outside of the machine test pkg
|
|
// no machines are created here to cleanup
|
|
// machine commands are rootless only
|
|
if isRootless() {
|
|
session = podmanTest.Podman([]string{"machine", "list", "-q"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
Expect(session.OutputToStringArray()).To(BeEmpty())
|
|
}
|
|
})
|
|
})
|