summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/e2e/libpod_suite_test.go19
-rw-r--r--test/e2e/push_test.go12
2 files changed, 26 insertions, 5 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()
+ }
+}
diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go
index 8593c3e99..f5bfc0c53 100644
--- a/test/e2e/push_test.go
+++ b/test/e2e/push_test.go
@@ -4,7 +4,6 @@ import (
"os"
"path/filepath"
"strings"
- "time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -56,12 +55,13 @@ var _ = Describe("Podman push", func() {
})
It("podman push to local registry", func() {
- session := podmanTest.Podman([]string{"run", "-d", "-p", "5000:5000", "docker.io/library/registry:2", "/entrypoint.sh", "/etc/docker/registry/config.yml"})
+ session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", "docker.io/library/registry:2", "/entrypoint.sh", "/etc/docker/registry/config.yml"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- // Give the registry 5 seconds to warm up before pushing
- time.Sleep(5 * time.Second)
+ if !WaitContainerReady(&podmanTest, "registry", "listening on", 20, 1) {
+ Skip("Can not start docker registry.")
+ }
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"})
push.WaitWithDefaultTimeout()
@@ -108,7 +108,9 @@ var _ = Describe("Podman push", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- time.Sleep(5 * time.Second)
+ if !WaitContainerReady(&podmanTest, "registry", "listening on", 20, 1) {
+ Skip("Can not start docker registry.")
+ }
session = podmanTest.Podman([]string{"logs", "registry"})
session.WaitWithDefaultTimeout()