Skip to content

Commit

Permalink
chore: fix flaky e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Cezar Rata <[email protected]>
  • Loading branch information
cezar-r committed Sep 17, 2024
1 parent 504dcaf commit b8bde5d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions e2e/tests/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,20 +464,24 @@ func ContainerCreate(opt *option.Option) {
// start and kill a container
command.Run(opt, "start", testContainerName)
command.Run(opt, "kill", "--signal=SIGKILL", testContainerName)
time.Sleep(5 * time.Second)

// inspect container
resp := command.Stdout(opt, "inspect", testContainerName)
var inspect []*dockercompat.Container
err := json.Unmarshal(resp, &inspect)
Expect(err).Should(BeNil())
Expect(inspect).Should(HaveLen(1))

// verify container is still running
Expect(inspect[0].State.Running).Should(BeTrue())

// verify restart count is 1
Expect(inspect[0].RestartCount).Should(Equal(1))
// check every 500 ms if container restarted
ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()
for range ticker.C {
// inspect container
resp := command.Stdout(opt, "inspect", testContainerName)
var inspect []*dockercompat.Container
err := json.Unmarshal(resp, &inspect)
Expect(err).Should(BeNil())
Expect(inspect).Should(HaveLen(1))

// if container is running, verify it was restarted
if inspect[0].State.Running {
Expect(inspect[0].RestartCount).Should(Equal(1))
return
}
}
})
})
}
Expand Down

0 comments on commit b8bde5d

Please sign in to comment.