fix podman network prune integration test flakes

The podman integration tests run in parallel. Because all tests use the
same CNI config dir the podman network prune test will remove networks
which are used by other tests at the moment and thus creating
unexpected flakes.

The solution use an extra cni config dir for the network prune test.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2021-09-27 15:47:37 +02:00
parent 1df0646b01
commit ca3c08bf9c

View File

@ -603,6 +603,11 @@ var _ = Describe("Podman network", func() {
}) })
It("podman network prune --filter", func() { It("podman network prune --filter", func() {
// set custom cni directory to prevent flakes
podmanTest.CNIConfigDir = tempdir
if IsRemote() {
podmanTest.RestartRemoteService()
}
net1 := "macvlan" + stringid.GenerateNonCryptoID() + "net1" net1 := "macvlan" + stringid.GenerateNonCryptoID() + "net1"
nc := podmanTest.Podman([]string{"network", "create", net1}) nc := podmanTest.Podman([]string{"network", "create", net1})
@ -613,11 +618,10 @@ var _ = Describe("Podman network", func() {
list := podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"}) list := podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"})
list.WaitWithDefaultTimeout() list.WaitWithDefaultTimeout()
Expect(list).Should(Exit(0)) Expect(list).Should(Exit(0))
Expect(list.OutputToStringArray()).Should(HaveLen(2))
Expect(StringInSlice(net1, list.OutputToStringArray())).To(BeTrue()) Expect(list.OutputToStringArray()).Should(ContainElement(net1))
if !isRootless() { Expect(list.OutputToStringArray()).Should(ContainElement("podman"))
Expect(StringInSlice("podman", list.OutputToStringArray())).To(BeTrue())
}
// -f needed only to skip y/n question // -f needed only to skip y/n question
prune := podmanTest.Podman([]string{"network", "prune", "-f", "--filter", "until=50"}) prune := podmanTest.Podman([]string{"network", "prune", "-f", "--filter", "until=50"})
@ -627,11 +631,10 @@ var _ = Describe("Podman network", func() {
listAgain := podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"}) listAgain := podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"})
listAgain.WaitWithDefaultTimeout() listAgain.WaitWithDefaultTimeout()
Expect(listAgain).Should(Exit(0)) Expect(listAgain).Should(Exit(0))
Expect(listAgain.OutputToStringArray()).Should(HaveLen(2))
Expect(StringInSlice(net1, listAgain.OutputToStringArray())).To(BeTrue()) Expect(listAgain.OutputToStringArray()).Should(ContainElement(net1))
if !isRootless() { Expect(listAgain.OutputToStringArray()).Should(ContainElement("podman"))
Expect(StringInSlice("podman", list.OutputToStringArray())).To(BeTrue())
}
// -f needed only to skip y/n question // -f needed only to skip y/n question
prune = podmanTest.Podman([]string{"network", "prune", "-f", "--filter", "until=5000000000000"}) prune = podmanTest.Podman([]string{"network", "prune", "-f", "--filter", "until=5000000000000"})
@ -641,14 +644,18 @@ var _ = Describe("Podman network", func() {
listAgain = podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"}) listAgain = podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"})
listAgain.WaitWithDefaultTimeout() listAgain.WaitWithDefaultTimeout()
Expect(listAgain).Should(Exit(0)) Expect(listAgain).Should(Exit(0))
Expect(listAgain.OutputToStringArray()).Should(HaveLen(1))
Expect(StringInSlice(net1, listAgain.OutputToStringArray())).To(BeFalse()) Expect(listAgain.OutputToStringArray()).ShouldNot(ContainElement(net1))
if !isRootless() { Expect(listAgain.OutputToStringArray()).Should(ContainElement("podman"))
Expect(StringInSlice("podman", list.OutputToStringArray())).To(BeTrue())
}
}) })
It("podman network prune", func() { It("podman network prune", func() {
// set custom cni directory to prevent flakes
podmanTest.CNIConfigDir = tempdir
if IsRemote() {
podmanTest.RestartRemoteService()
}
// Create two networks // Create two networks
// Check they are there // Check they are there
// Run a container on one of them // Run a container on one of them
@ -669,13 +676,11 @@ var _ = Describe("Podman network", func() {
list := podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"}) list := podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"})
list.WaitWithDefaultTimeout() list.WaitWithDefaultTimeout()
Expect(list).Should(Exit(0)) Expect(list.OutputToStringArray()).Should(HaveLen(3))
Expect(StringInSlice(net1, list.OutputToStringArray())).To(BeTrue()) Expect(list.OutputToStringArray()).Should(ContainElement(net1))
Expect(StringInSlice(net2, list.OutputToStringArray())).To(BeTrue()) Expect(list.OutputToStringArray()).Should(ContainElement(net2))
if !isRootless() { Expect(list.OutputToStringArray()).Should(ContainElement("podman"))
Expect(StringInSlice("podman", list.OutputToStringArray())).To(BeTrue())
}
session := podmanTest.Podman([]string{"run", "-dt", "--net", net2, ALPINE, "top"}) session := podmanTest.Podman([]string{"run", "-dt", "--net", net2, ALPINE, "top"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -688,13 +693,10 @@ var _ = Describe("Podman network", func() {
listAgain := podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"}) listAgain := podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}}"})
listAgain.WaitWithDefaultTimeout() listAgain.WaitWithDefaultTimeout()
Expect(listAgain).Should(Exit(0)) Expect(listAgain).Should(Exit(0))
Expect(listAgain.OutputToStringArray()).Should(HaveLen(2))
Expect(StringInSlice(net1, listAgain.OutputToStringArray())).To(BeFalse()) Expect(listAgain.OutputToStringArray()).ShouldNot(ContainElement(net1))
Expect(StringInSlice(net2, listAgain.OutputToStringArray())).To(BeTrue()) Expect(listAgain.OutputToStringArray()).Should(ContainElement(net2))
// Make sure default network 'podman' still exists Expect(listAgain.OutputToStringArray()).Should(ContainElement("podman"))
if !isRootless() {
Expect(StringInSlice("podman", list.OutputToStringArray())).To(BeTrue())
}
}) })
}) })