|
7 | 7 | "fmt" |
8 | 8 | "os" |
9 | 9 | "path/filepath" |
| 10 | + "time" |
10 | 11 |
|
11 | 12 | "github.com/onsi/ginkgo/v2" |
12 | 13 | "github.com/onsi/gomega" |
@@ -45,14 +46,25 @@ var testCosign = func(o *option.Option) { |
45 | 46 | htpasswdDir := filepath.Dir(ffs.CreateTempFile(filename, htpasswd)) |
46 | 47 | ginkgo.DeferCleanup(os.RemoveAll, htpasswdDir) |
47 | 48 | port = fnet.GetFreePort() |
48 | | - command.Run(o, "run", |
| 49 | + containerID := command.StdoutStr(o, "run", |
49 | 50 | "-dp", fmt.Sprintf("%d:5000", port), |
50 | 51 | "--name", "registry", |
51 | 52 | "-v", fmt.Sprintf("%s:/auth", htpasswdDir), |
52 | 53 | "-e", "REGISTRY_AUTH=htpasswd", |
53 | 54 | "-e", "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm", |
54 | 55 | "-e", fmt.Sprintf("REGISTRY_AUTH_HTPASSWD_PATH=/auth/%s", filename), |
55 | 56 | registryImage) |
| 57 | + // Wait for container to be running |
| 58 | + tries := 0 |
| 59 | + for command.StdoutStr(o, "inspect", "-f", "{{.State.Running}}", containerID) != "true" { |
| 60 | + if tries >= 5 { |
| 61 | + ginkgo.Fail("Registry container failed to start after 5 seconds") |
| 62 | + } |
| 63 | + time.Sleep(1 * time.Second) |
| 64 | + tries++ |
| 65 | + } |
| 66 | + // Wait for registry service to be ready |
| 67 | + time.Sleep(10 * time.Second) |
56 | 68 | registry = fmt.Sprintf(`localhost:%d`, port) |
57 | 69 | tag = fmt.Sprintf(`%s/test-login:tag`, registry) |
58 | 70 | }) |
|
0 commit comments