improve retry logic with standard wait.Poll()

Signed-off-by: He Simei <hesimei@zju.edu.cn>
This commit is contained in:
He Simei
2015-05-18 08:40:18 +08:00
parent 10339d72b6
commit 09fc2a5013
10 changed files with 123 additions and 119 deletions

View File

@@ -26,6 +26,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
influxdb "github.com/influxdb/influxdb/client"
. "github.com/onsi/ginkgo"
@@ -223,15 +224,12 @@ func testMonitoringUsingHeapsterInfluxdb(c *client.Client) {
expectedNodes, err := getAllNodesInCluster(c)
expectNoError(err)
startTime := time.Now()
for {
expectNoError(wait.Poll(sleepBetweenAttempts, testTimeout, func() (bool, error) {
if validatePodsAndNodes(influxdbClient, expectedPods, expectedNodes) {
return
return true, nil
}
if time.Since(startTime) >= testTimeout {
break
}
time.Sleep(sleepBetweenAttempts)
}
return false, nil
}))
Failf("monitoring using heapster and influxdb test failed")
}