From ae5ed6d8511f4b0fa9034fba3b2317a51c503b7d Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 24 Apr 2023 13:44:46 -0600 Subject: [PATCH] e2e create same-IP: try to fix flake Our friend #7096 is still not fixed: it continues to flake, singletons only, and only in the "create" test (not "run"). My guess: maybe there's a race somewhere in IP assignment, such that container1 can have an IP, but not yet be running, and a container2 can sneak in and start with that IP, and container1 is the one that fails? Solution: tighten the logic so we wait for container1 to truly be running before we start container2. And, when we start container2, do so with -a so we get to see stdout. (Am not expecting it to be helpful, but who knows). Also very minor cleanup Signed-off-by: Ed Santiago --- test/e2e/create_staticip_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/e2e/create_staticip_test.go b/test/e2e/create_staticip_test.go index fac7c5a2cb..b45b2b5db8 100644 --- a/test/e2e/create_staticip_test.go +++ b/test/e2e/create_staticip_test.go @@ -82,24 +82,25 @@ var _ = Describe("Podman create with --ip flag", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - // race prevention: wait until IP address is assigned + // race prevention: wait until IP address is assigned and + // container is running. for i := 0; i < 5; i++ { - result = podmanTest.Podman([]string{"inspect", "--format", "{{.NetworkSettings.IPAddress}}", "test1"}) + result = podmanTest.Podman([]string{"inspect", "--format", "{{.State.Status}} {{.NetworkSettings.IPAddress}}", "test1"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - if result.OutputToString() != "" { + if result.OutputToString() == "running "+ip { break } time.Sleep(1 * time.Second) } - Expect(result.OutputToString()).To(Equal(ip)) + Expect(result.OutputToString()).To(Equal("running " + ip)) // test1 container is running with the given IP. - result = podmanTest.Podman([]string{"start", "test2"}) + result = podmanTest.Podman([]string{"start", "-a", "test2"}) result.WaitWithDefaultTimeout() Expect(result).To(ExitWithError()) if podmanTest.NetworkBackend == CNI { - Expect(result.ErrorToString()).To(ContainSubstring("requested IP address " + ip + " is not available")) + Expect(result.ErrorToString()).To(ContainSubstring("requested IP address %s is not available", ip)) } else if podmanTest.NetworkBackend == Netavark { Expect(result.ErrorToString()).To(ContainSubstring("requested ip address %s is already allocated", ip)) }