mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
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:
parent
af1628eaa4
commit
eb4b45941c
@ -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"},
|
||||
|
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user