summaryrefslogtreecommitdiff
path: root/pkg/bindings/test
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-02-27 10:59:53 -0600
committerBrent Baude <bbaude@redhat.com>2020-02-28 09:36:53 -0600
commit09048731000e73b44a0243a0339d8c122eb8a165 (patch)
treedb939805cbb41f4ddd2db610256ba2186a8367db /pkg/bindings/test
parentbaf27fa25eed668b5a73a1d7d4fe16214f1c260f (diff)
downloadpodman-09048731000e73b44a0243a0339d8c122eb8a165.tar.gz
podman-09048731000e73b44a0243a0339d8c122eb8a165.tar.bz2
podman-09048731000e73b44a0243a0339d8c122eb8a165.zip
rework apiv2 wait endpoint|binding
added the ability to wait on a condition (stopped, running, paused...) for a container. if a condition is not provided, wait will default to the stopped condition which uses the original wait code paths. if the condition is stopped, the container exit code will be returned. also, correct a mux issue we discovered. Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/bindings/test')
-rw-r--r--pkg/bindings/test/containers_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go
index 6756e81c7..e875fb2f8 100644
--- a/pkg/bindings/test/containers_test.go
+++ b/pkg/bindings/test/containers_test.go
@@ -250,4 +250,61 @@ var _ = Describe("Podman containers ", func() {
Expect(data.State.Status).To(Equal("exited"))
})
+ It("podman wait no condition", func() {
+ var (
+ name = "top"
+ exitCode int32 = -1
+ )
+ _, err := containers.Wait(connText, "foobar", nil)
+ Expect(err).ToNot(BeNil())
+ code, _ := bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusNotFound))
+
+ errChan := make(chan error)
+ bt.RunTopContainer(&name, nil, nil)
+ go func() {
+ exitCode, err = containers.Wait(connText, name, nil)
+ errChan <- err
+ close(errChan)
+ }()
+ err = containers.Stop(connText, name, nil)
+ Expect(err).To(BeNil())
+ wait := <-errChan
+ Expect(wait).To(BeNil())
+ Expect(exitCode).To(BeNumerically("==", 143))
+ })
+
+ It("podman wait to pause|unpause condition", func() {
+ var (
+ name = "top"
+ exitCode int32 = -1
+ pause = "paused"
+ unpause = "running"
+ )
+ errChan := make(chan error)
+ bt.RunTopContainer(&name, nil, nil)
+ go func() {
+ exitCode, err = containers.Wait(connText, name, &pause)
+ errChan <- err
+ close(errChan)
+ }()
+ err := containers.Pause(connText, name)
+ Expect(err).To(BeNil())
+ wait := <-errChan
+ Expect(wait).To(BeNil())
+ Expect(exitCode).To(BeNumerically("==", -1))
+
+ errChan = make(chan error)
+ go func() {
+ exitCode, err = containers.Wait(connText, name, &unpause)
+ errChan <- err
+ close(errChan)
+ }()
+ err = containers.Unpause(connText, name)
+ Expect(err).To(BeNil())
+ unPausewait := <-errChan
+ Expect(unPausewait).To(BeNil())
+ Expect(exitCode).To(BeNumerically("==", -1))
+ })
+
})