fix tests affected by refreshGracePeriod

A couple tests require lowering the grace period to keep the test from
taking the full 30s timeout.

The Retry_hang test also needed to be removed from the Parallel group,
becuase it modifies the global refreshGracePeriod variable.
This commit is contained in:
James Bardin 2017-04-19 14:19:08 -04:00
parent af1628eaa4
commit eb4b45941c
2 changed files with 12 additions and 2 deletions

View File

@ -147,6 +147,12 @@ func TestWaitForState_inconsistent_negative(t *testing.T) {
}
func TestWaitForState_timeout(t *testing.T) {
old := refreshGracePeriod
refreshGracePeriod = 5 * time.Millisecond
defer func() {
refreshGracePeriod = old
}()
conf := &StateChangeConf{
Pending: []string{"pending", "incomplete"},
Target: []string{"running"},

View File

@ -54,14 +54,18 @@ func TestRetry_timeout(t *testing.T) {
}
func TestRetry_hang(t *testing.T) {
t.Parallel()
old := refreshGracePeriod
refreshGracePeriod = 50 * time.Millisecond
defer func() {
refreshGracePeriod = old
}()
f := func() *RetryError {
time.Sleep(2 * time.Second)
return nil
}
err := Retry(1*time.Second, f)
err := Retry(50*time.Millisecond, f)
if err == nil {
t.Fatal("should error")
}