|
|
|
|
@ -75,7 +75,8 @@ func TestWaitForState_inconsistent_positive(t *testing.T) {
|
|
|
|
|
Pending: []string{"replicating"},
|
|
|
|
|
Target: []string{"done"},
|
|
|
|
|
Refresh: InconsistentStateRefreshFunc(),
|
|
|
|
|
Timeout: 10 * time.Second,
|
|
|
|
|
Timeout: 90 * time.Millisecond,
|
|
|
|
|
PollInterval: 10 * time.Millisecond,
|
|
|
|
|
ContinuousTargetOccurence: 3,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -95,14 +96,19 @@ func TestWaitForState_inconsistent_negative(t *testing.T) {
|
|
|
|
|
Pending: []string{"replicating"},
|
|
|
|
|
Target: []string{"done"},
|
|
|
|
|
Refresh: InconsistentStateRefreshFunc(),
|
|
|
|
|
Timeout: 10 * time.Second,
|
|
|
|
|
Timeout: 90 * time.Millisecond,
|
|
|
|
|
PollInterval: 10 * time.Millisecond,
|
|
|
|
|
ContinuousTargetOccurence: 4,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := conf.WaitForState()
|
|
|
|
|
|
|
|
|
|
if err == nil && err.Error() != "timeout while waiting for state to become 'done'" {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("Expected timeout error. No error returned.")
|
|
|
|
|
}
|
|
|
|
|
expectedErr := "timeout while waiting for state to become 'done' (last state: 'done')"
|
|
|
|
|
if err.Error() != expectedErr {
|
|
|
|
|
t.Fatalf("Errors don't match.\nExpected: %q\nGiven: %q\n", expectedErr, err.Error())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -116,8 +122,13 @@ func TestWaitForState_timeout(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
obj, err := conf.WaitForState()
|
|
|
|
|
|
|
|
|
|
if err == nil && err.Error() != "timeout while waiting for state to become 'running'" {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("Expected timeout error. No error returned.")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expectedErr := "timeout while waiting for state to become 'running'"
|
|
|
|
|
if err.Error() != expectedErr {
|
|
|
|
|
t.Fatalf("Errors don't match.\nExpected: %q\nGiven: %q\n", expectedErr, err.Error())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if obj != nil {
|
|
|
|
|
@ -162,6 +173,28 @@ func TestWaitForState_successEmpty(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestWaitForState_failureEmpty(t *testing.T) {
|
|
|
|
|
conf := &StateChangeConf{
|
|
|
|
|
Pending: []string{"pending", "incomplete"},
|
|
|
|
|
Target: []string{},
|
|
|
|
|
NotFoundChecks: 1,
|
|
|
|
|
Refresh: func() (interface{}, string, error) {
|
|
|
|
|
return 42, "pending", nil
|
|
|
|
|
},
|
|
|
|
|
PollInterval: 10 * time.Millisecond,
|
|
|
|
|
Timeout: 100 * time.Millisecond,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := conf.WaitForState()
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("Expected timeout error. Got none.")
|
|
|
|
|
}
|
|
|
|
|
expectedErr := "timeout while waiting for resource to be gone (last state: 'pending')"
|
|
|
|
|
if err.Error() != expectedErr {
|
|
|
|
|
t.Fatalf("Errors don't match.\nExpected: %q\nGiven: %q\n", expectedErr, err.Error())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestWaitForState_failure(t *testing.T) {
|
|
|
|
|
conf := &StateChangeConf{
|
|
|
|
|
Pending: []string{"pending", "incomplete"},
|
|
|
|
|
@ -171,8 +204,12 @@ func TestWaitForState_failure(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj, err := conf.WaitForState()
|
|
|
|
|
if err == nil && err.Error() != "failed" {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("Expected error. No error returned.")
|
|
|
|
|
}
|
|
|
|
|
expectedErr := "failed"
|
|
|
|
|
if err.Error() != expectedErr {
|
|
|
|
|
t.Fatalf("Errors don't match.\nExpected: %q\nGiven: %q\n", expectedErr, err.Error())
|
|
|
|
|
}
|
|
|
|
|
if obj != nil {
|
|
|
|
|
t.Fatalf("should not return obj")
|
|
|
|
|
|