summaryrefslogtreecommitdiff
path: root/test/e2e/libpod_suite_test.go
diff options
context:
space:
mode:
authorYiqiao Pu <ypu@redhat.com>2018-04-10 18:48:22 +0800
committerYiqiao Pu <ypu@redhat.com>2018-04-16 10:55:21 +0800
commitd6d7edb841a8c3044c81386fdb4113dd895a26f3 (patch)
tree80d26947ffdd018f03148956a3210a9ed89a4ca2 /test/e2e/libpod_suite_test.go
parent0fe0c79dc9f7074e30466c81e0fbc157faa00db2 (diff)
downloadpodman-d6d7edb841a8c3044c81386fdb4113dd895a26f3.tar.gz
podman-d6d7edb841a8c3044c81386fdb4113dd895a26f3.tar.bz2
podman-d6d7edb841a8c3044c81386fdb4113dd895a26f3.zip
Add WaitContainerReady for wait for docker registry ready
Sometime podman push local registry still failed caused by the docker registry is not start yet after sleep 5s in the test. So add this function to check the container status by its output and skip the test when the docker registry can not start normally instead of failed the case. Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Diffstat (limited to 'test/e2e/libpod_suite_test.go')
-rw-r--r--test/e2e/libpod_suite_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go
index 8e3b4254a..8887fd96e 100644
--- a/test/e2e/libpod_suite_test.go
+++ b/test/e2e/libpod_suite_test.go
@@ -593,3 +593,22 @@ func IsKernelNewThan(version string) (bool, error) {
return false, nil
}
+
+//Wait process or service inside container start, and ready to be used.
+func WaitContainerReady(p *PodmanTest, id string, expStr string, timeout int, step int) bool {
+ startTime := time.Now()
+ s := p.Podman([]string{"logs", id})
+ s.WaitWithDefaultTimeout()
+ fmt.Println(startTime)
+ for {
+ if time.Since(startTime) >= time.Duration(timeout)*time.Second {
+ return false
+ }
+ if strings.Contains(s.OutputToString(), expStr) {
+ return true
+ }
+ time.Sleep(time.Duration(step) * time.Second)
+ s = p.Podman([]string{"logs", id})
+ s.WaitWithDefaultTimeout()
+ }
+}