Skip to content

Commit

Permalink
Infra setup waits for loadbalancer services
Browse files Browse the repository at this point in the history
This could help with the flaky imagescan test, by waiting for the git
loadbalancer to be ready.
  • Loading branch information
Mario Manno authored and manno committed Dec 7, 2023
1 parent 80a77e8 commit b34fe3b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions e2e/testenv/infra/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ var setupCmd = &cobra.Command{
}

if externalIP == "" {
externalIP = eventually(func() (string, error) {
return k.Get("service", "zot-service", "-o", "jsonpath={.status.loadBalancer.ingress[0].ip}")
})
externalIP = waitForLoadbalancer(k, "zot-service")
}
OCIHost := fmt.Sprintf("%s:5000", externalIP)

Expand Down Expand Up @@ -195,9 +193,7 @@ var setupCmd = &cobra.Command{
wgHelm.Wait()

if externalIP == "" {
externalIP = eventually(func() (string, error) {
return k.Get("service", "chartmuseum-service", "-o", "jsonpath={.status.loadBalancer.ingress[0].ip}")
})
externalIP = waitForLoadbalancer(k, "chartmuseum-service")
}

_ = eventually(func() (string, error) {
Expand Down Expand Up @@ -258,6 +254,7 @@ func spinUpGitServer(k kubectl.Command, wg *sync.WaitGroup) {
}

waitForPodReady(k, "git-server")
waitForLoadbalancer(k, "git-service")

fmt.Println("git server up.")
}
Expand Down Expand Up @@ -367,6 +364,13 @@ func waitForPodReady(k kubectl.Command, appName string) {
})
}

func waitForLoadbalancer(k kubectl.Command, name string) string {
ip := eventually(func() (string, error) {
return k.Get("service", name, "-o", "jsonpath={.status.loadBalancer.ingress[0].ip}")
})
return ip
}

// fail prints err and exits.
func fail(err error) {
fmt.Println(err.Error())
Expand Down

0 comments on commit b34fe3b

Please sign in to comment.