diff options
author | Ed Santiago <santiago@redhat.com> | 2020-02-20 14:19:24 -0700 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2020-02-20 14:56:02 -0700 |
commit | a1dcfd47a1a35d47c51c10cc644d70f177bfdc0f (patch) | |
tree | 8dac38172b0b2aab7deefe446d5781180a1c9d31 /test/e2e/create_staticip_test.go | |
parent | 83a9b318e150e96ba381f2fdf0db9d979e0740f0 (diff) | |
download | podman-a1dcfd47a1a35d47c51c10cc644d70f177bfdc0f.tar.gz podman-a1dcfd47a1a35d47c51c10cc644d70f177bfdc0f.tar.bz2 podman-a1dcfd47a1a35d47c51c10cc644d70f177bfdc0f.zip |
Flake fix: race condition in same-IP test
The "create two containers with the same IP" test failed:
https://api.cirrus-ci.com/v1/task/5992323062431744/logs/integration_test.log#t--Podman-create-two-containers-with-the-same-IP
...
(basically, expected error exit code, got 0)
Analysis: the sequence is 'start test1, start test2'. Perhaps it's
possible that 'podman start' exits before the test1 container has
an IP address assigned? There are no checks in the test, so it's
impossible to know what happened.
Solution: add a wait-loop invoking 'podman inspect', waiting
for a nonempty IP address on test 1; then assert that it's
what we expect it to be.
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/e2e/create_staticip_test.go')
-rw-r--r-- | test/e2e/create_staticip_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/e2e/create_staticip_test.go b/test/e2e/create_staticip_test.go index 72a0638f9..693795637 100644 --- a/test/e2e/create_staticip_test.go +++ b/test/e2e/create_staticip_test.go @@ -4,6 +4,7 @@ package integration import ( "os" + "time" . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" @@ -86,8 +87,23 @@ var _ = Describe("Podman create with --ip flag", func() { result = podmanTest.Podman([]string{"start", "test1"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) + + // race prevention: wait until IP address is assigned + for i := 0; i < 5; i++ { + result = podmanTest.Podman([]string{"inspect", "--format", "{{.NetworkSettings.IPAddress}}", "test1"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + if result.OutputToString() != "" { + break + } + time.Sleep(1 * time.Second) + } + Expect(result.OutputToString()).To(Equal(ip)) + + // test1 container is running with the given IP. result = podmanTest.Podman([]string{"start", "test2"}) result.WaitWithDefaultTimeout() Expect(result).To(ExitWithError()) + Expect(result.ErrorToString()).To(ContainSubstring("requested IP address " + ip + " is not available")) }) }) |