Node e2e test fixes:

- Improve documentation and method naming
- Fix command this is run remotely
- Never reschedule the busybox logging test pod since it is supposed to terminate
- Update log test condition retrylogic to correctly retry instead of failing the test
- localhost -> 127.0.0.1 to work on coreos
- give name to etcd to work on coreos
- allow using full hostname for nodename for coreos
This commit is contained in:
Phillip Wittrock
2015-12-03 14:27:51 -08:00
parent 229f40e69f
commit ad37e2654e
5 changed files with 76 additions and 54 deletions

View File

@@ -18,16 +18,27 @@ package e2e_node
import (
"time"
client "k8s.io/kubernetes/pkg/client/unversioned"
)
type RetryFn func(cl *client.Client) error
// RetryFn represents a retryable test condition. It returns an error if the condition is not met
// otherwise returns nil for success.
type RetryFn func() error
func Retry(maxWait time.Duration, wait time.Duration, cl *client.Client, retry RetryFn) []error {
// Retry retries the RetryFn for a maximum of maxWait time. The wait duration is waited between
// retries. If the success condition is not met in maxWait time, the list of encountered errors
// is returned. If successful returns an empty list.
// Example:
// Expect(Retry(time.Minute*1, time.Second*2, func() error {
// if success {
// return nil
// } else {
// return errors.New("Failed")
// }
// }).To(BeNil(), fmt.Sprintf("Failed"))
func Retry(maxWait time.Duration, wait time.Duration, retry RetryFn) []error {
errs := []error{}
for start := time.Now(); time.Now().Before(start.Add(maxWait)); {
if err := retry(cl); err != nil {
if err := retry(); err != nil {
errs = append(errs, err)
} else {
return []error{}