Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
debugging info for test timeouts
Browse files Browse the repository at this point in the history
 - add a try counter and total duration
 - reuse of util/wait instead of custom code
  • Loading branch information
MHBauer authored and kibbles-n-bytes committed Apr 14, 2017
1 parent 80dcffc commit 77f5c9a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
3 changes: 2 additions & 1 deletion test/integration/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,14 @@ func newTestController(t *testing.T) (
serviceCatalogSharedInformers.Bindings(),
brokerClFunc,
)
t.Log("controller start")
if err != nil {
t.Fatal(err)
}

stopCh := make(chan struct{})
informerFactory.Start(stopCh)

t.Log("informers start")
return fakeKubeClient, catalogClient, catalogCl, instanceCl, bindingCl,
testController, serviceCatalogSharedInformers, shutdownServer
}
43 changes: 25 additions & 18 deletions test/integration/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/golang/glog"
"github.com/pborman/uuid"

"k8s.io/apimachinery/pkg/util/wait"

"k8s.io/client-go/pkg/api"
restclient "k8s.io/client-go/rest"

Expand Down Expand Up @@ -107,23 +109,28 @@ func getFreshApiserverAndClient(t *testing.T, storageTypeStr string) (servicecat
return clientset, shutdown
}

func waitForApiserverUp(insecureAddr string, stopCh <-chan struct{}) error {
minuteTimeout := time.After(2 * time.Minute)
for {
select {
case <-stopCh:
return fmt.Errorf("apiserver failed")
case <-minuteTimeout:
return fmt.Errorf("waiting for apiserver timed out")
default:
glog.Infof("Waiting for : %#v", insecureAddr)
_, err := http.Get(insecureAddr)
if err == nil {
return nil
func waitForApiserverUp(serverURL string, stopCh <-chan struct{}) error {
interval := 1 * time.Second
timeout := 30 * time.Second
startWaiting := time.Now()
tries := 0
return wait.PollImmediate(interval, timeout,
func() (bool, error) {
select {
// we've been told to stop, so no reason to keep going
case <-stopCh:
return true, fmt.Errorf("apiserver failed")
default:
glog.Infof("Waiting for : %#v", serverURL)
_, err := http.Get(serverURL)
if err == nil {
glog.Infof("Found server after %v tries and duration %v",
tries, time.Since(startWaiting))
return true, nil
}
tries++
return false, nil
}
}
// no success or overall timeout or stop due to failure
// wait and go around again
<-time.After(10 * time.Second)
}
},
)
}

0 comments on commit 77f5c9a

Please sign in to comment.