Merge pull request #18085 from Luap99/e2e-custom-network

test/e2e: use custom network config dir where needed
This commit is contained in:
OpenShift Merge Robot
2023-04-06 16:01:35 -04:00
committed by GitHub
5 changed files with 24 additions and 20 deletions

View File

@ -904,6 +904,7 @@ RUN ls /dev/test1`, ALPINE)
It("podman system reset must clean host shared cache", func() { It("podman system reset must clean host shared cache", func() {
SkipIfRemote("podman-remote does not have system reset -f") SkipIfRemote("podman-remote does not have system reset -f")
useCustomNetworkDir(podmanTest, tempdir)
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
session := podmanTest.Podman([]string{"build", "--pull-never", "--file", "build/cache/Dockerfilecachewrite", "build/cache/"}) session := podmanTest.Podman([]string{"build", "--pull-never", "--file", "build/cache/Dockerfilecachewrite", "build/cache/"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -1198,3 +1198,15 @@ func WaitForService(address url.URL) {
} }
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
} }
// useCustomNetworkDir makes sure this test uses a custom network dir.
// This needs to be called for all test they may remove networks from other tests,
// so netwokr prune, system prune, or system reset.
// see https://github.com/containers/podman/issues/17946
func useCustomNetworkDir(podmanTest *PodmanTestIntegration, tempdir string) {
// set custom network directory to prevent flakes since the dir is shared with all tests by default
podmanTest.NetworkConfigDir = tempdir
if IsRemote() {
podmanTest.RestartRemoteService()
}
}

View File

@ -726,11 +726,7 @@ var _ = Describe("Podman network", func() {
}) })
It("podman network prune --filter", func() { It("podman network prune --filter", func() {
// set custom network directory to prevent flakes since the dir is shared with all tests by default useCustomNetworkDir(podmanTest, tempdir)
podmanTest.NetworkConfigDir = tempdir
if IsRemote() {
podmanTest.RestartRemoteService()
}
net1 := "macvlan" + stringid.GenerateRandomID() + "net1" net1 := "macvlan" + stringid.GenerateRandomID() + "net1"
nc := podmanTest.Podman([]string{"network", "create", net1}) nc := podmanTest.Podman([]string{"network", "create", net1})
@ -774,11 +770,7 @@ var _ = Describe("Podman network", func() {
}) })
It("podman network prune", func() { It("podman network prune", func() {
// set custom network directory to prevent flakes since the dir is shared with all tests by default useCustomNetworkDir(podmanTest, tempdir)
podmanTest.NetworkConfigDir = 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

View File

@ -214,6 +214,7 @@ var _ = Describe("Podman prune", func() {
}) })
It("podman system image prune unused images", func() { It("podman system image prune unused images", func() {
useCustomNetworkDir(podmanTest, tempdir)
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true") podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true")
prune := podmanTest.Podman([]string{"system", "prune", "-a", "--force"}) prune := podmanTest.Podman([]string{"system", "prune", "-a", "--force"})
@ -260,12 +261,7 @@ var _ = Describe("Podman prune", func() {
}) })
It("podman system prune networks", func() { It("podman system prune networks", func() {
// set custom network directory to prevent flakes since the dir is shared with all tests by default useCustomNetworkDir(podmanTest, tempdir)
podmanTest.NetworkConfigDir = tempdir
if IsRemote() {
podmanTest.RestartRemoteService()
}
// Create new network. // Create new network.
session := podmanTest.Podman([]string{"network", "create", "test"}) session := podmanTest.Podman([]string{"network", "create", "test"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -308,6 +304,7 @@ var _ = Describe("Podman prune", func() {
}) })
It("podman system prune - pod,container stopped", func() { It("podman system prune - pod,container stopped", func() {
useCustomNetworkDir(podmanTest, tempdir)
session := podmanTest.Podman([]string{"pod", "create"}) session := podmanTest.Podman([]string{"pod", "create"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -340,6 +337,7 @@ var _ = Describe("Podman prune", func() {
}) })
It("podman system prune with running, exited pod and volume prune set true", func() { It("podman system prune with running, exited pod and volume prune set true", func() {
useCustomNetworkDir(podmanTest, tempdir)
// Start and stop a pod to get it in exited state. // Start and stop a pod to get it in exited state.
session := podmanTest.Podman([]string{"pod", "create"}) session := podmanTest.Podman([]string{"pod", "create"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -417,6 +415,7 @@ var _ = Describe("Podman prune", func() {
}) })
It("podman system prune - with dangling images true", func() { It("podman system prune - with dangling images true", func() {
useCustomNetworkDir(podmanTest, tempdir)
session := podmanTest.Podman([]string{"pod", "create"}) session := podmanTest.Podman([]string{"pod", "create"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -465,6 +464,7 @@ var _ = Describe("Podman prune", func() {
}) })
It("podman system prune --volumes --filter", func() { It("podman system prune --volumes --filter", func() {
useCustomNetworkDir(podmanTest, tempdir)
session := podmanTest.Podman([]string{"volume", "create", "--label", "label1=value1", "myvol1"}) session := podmanTest.Podman([]string{"volume", "create", "--label", "label1=value1", "myvol1"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -531,6 +531,7 @@ var _ = Describe("Podman prune", func() {
}) })
It("podman system prune --external leaves referenced containers", func() { It("podman system prune --external leaves referenced containers", func() {
useCustomNetworkDir(podmanTest, tempdir)
containerStorageDir := filepath.Join(podmanTest.Root, podmanTest.ImageCacheFS+"-containers") containerStorageDir := filepath.Join(podmanTest.Root, podmanTest.ImageCacheFS+"-containers")
create := podmanTest.Podman([]string{"create", "--name", "test", BB}) create := podmanTest.Podman([]string{"create", "--name", "test", BB})
@ -561,6 +562,7 @@ var _ = Describe("Podman prune", func() {
It("podman system prune --external removes unreferenced containers", func() { It("podman system prune --external removes unreferenced containers", func() {
SkipIfRemote("Can't drop database while daemon running") SkipIfRemote("Can't drop database while daemon running")
useCustomNetworkDir(podmanTest, tempdir)
containerStorageDir := filepath.Join(podmanTest.Root, podmanTest.ImageCacheFS+"-containers") containerStorageDir := filepath.Join(podmanTest.Root, podmanTest.ImageCacheFS+"-containers")

View File

@ -36,10 +36,7 @@ var _ = Describe("podman system reset", func() {
It("podman system reset", func() { It("podman system reset", func() {
SkipIfRemote("system reset not supported on podman --remote") SkipIfRemote("system reset not supported on podman --remote")
// system reset will not remove additional store images, so need to grab length // system reset will not remove additional store images, so need to grab length
useCustomNetworkDir(podmanTest, tempdir)
// change the network dir so that we do not conflict with other tests
// that would use the same network dir and cause unnecessary flakes
podmanTest.NetworkConfigDir = tempdir
session := podmanTest.Podman([]string{"rmi", "--force", "--all"}) session := podmanTest.Podman([]string{"rmi", "--force", "--all"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()