Skip to content

Commit 47b1c82

Browse files
committed
test/fix: wait for registry to become responsive
Signed-off-by: thediveo <thediveo@gmx.eu>
1 parent d7ea58b commit 47b1c82

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

registry_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package morbyd
1717
import (
1818
"context"
1919
"fmt"
20+
"net/http"
2021
"time"
2122

2223
"github.com/thediveo/morbyd/pull"
@@ -51,10 +52,23 @@ var _ = Describe("given a (local) registry", Ordered, Serial, func() {
5152
sess.Close(ctx)
5253
})
5354
By("starting a local container registry")
54-
_ = Successful(sess.Run(ctx, "registry:2",
55+
Expect(sess.Run(ctx, "registry:2",
5556
run.WithName("local-registry"),
5657
run.WithPublishedPort(fmt.Sprintf("127.0.0.1:%d:5000", registryPort)),
57-
run.WithAutoRemove()))
58+
run.WithAutoRemove())).Error().NotTo(HaveOccurred())
59+
By("waiting for the registry to become operational")
60+
Eventually(func() error {
61+
resp, err := http.Get(fmt.Sprintf("http://127.0.0.1:%d/v2/", registryPort))
62+
if err != nil {
63+
return err
64+
}
65+
defer resp.Body.Close()
66+
if resp.StatusCode != http.StatusOK {
67+
return fmt.Errorf("HTTP status code %d", resp.StatusCode)
68+
}
69+
return nil
70+
}).Within(5 * time.Second).ProbeEvery(250 * time.Millisecond).
71+
Should(Succeed())
5872
})
5973

6074
BeforeEach(func(ctx context.Context) {

0 commit comments

Comments
 (0)