Skip to content

Commit

Permalink
Add timeouts when waiting on OpenShift or the registry to start
Browse files Browse the repository at this point in the history
... so that we terminate with the full context and pointing at
the relevant code, instead of relying
on the overall test suite timeout.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Jul 30, 2021
1 parent b6b7bd9 commit ce6035b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions integration/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package main

import (
"bufio"
"context"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/docker/docker/pkg/homedir"
"github.com/go-check/check"
Expand Down Expand Up @@ -109,6 +111,8 @@ func (cluster *openshiftCluster) startMaster(c *check.C) {

gotPortCheck := false
gotLogCheck := false
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
for !gotPortCheck || !gotLogCheck {
c.Logf("Waiting for master")
select {
Expand All @@ -121,6 +125,8 @@ func (cluster *openshiftCluster) startMaster(c *check.C) {
c.Fatal("log check done, success message not found")
}
gotLogCheck = true
case <-ctx.Done():
c.Fatalf("Timed out waiting for master: %v", ctx.Err())
}
}
c.Logf("OK, master started!")
Expand Down Expand Up @@ -166,8 +172,14 @@ func (cluster *openshiftCluster) startRegistryProcess(c *check.C, port int, conf
terminatePortCheck <- true
}()
c.Logf("Waiting for registry to start")
<-portOpen
c.Logf("OK, Registry port open")
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel()
select {
case <-portOpen:
c.Logf("OK, Registry port open")
case <-ctx.Done():
c.Fatalf("Timed out waiting for registry to start: %v", ctx.Err())
}

return cmd
}
Expand Down

0 comments on commit ce6035b

Please sign in to comment.