Merge pull request #18329 from edsantiago/create_2_sameip

e2e create same-IP: try to fix flake
This commit is contained in:
OpenShift Merge Robot 2023-04-25 03:59:09 -04:00 committed by GitHub
commit 242d63af80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -82,24 +82,25 @@ var _ = Describe("Podman create with --ip flag", func() {
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) 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++ { 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() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
if result.OutputToString() != "" { if result.OutputToString() == "running "+ip {
break break
} }
time.Sleep(1 * time.Second) 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. // test1 container is running with the given IP.
result = podmanTest.Podman([]string{"start", "test2"}) result = podmanTest.Podman([]string{"start", "-a", "test2"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError()) Expect(result).To(ExitWithError())
if podmanTest.NetworkBackend == CNI { 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 { } else if podmanTest.NetworkBackend == Netavark {
Expect(result.ErrorToString()).To(ContainSubstring("requested ip address %s is already allocated", ip)) Expect(result.ErrorToString()).To(ContainSubstring("requested ip address %s is already allocated", ip))
} }