-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v3: Client introduce a wait timeout with different polling strategy (#…
…674) Signed-off-by: Pierre-Emmanuel Jacquier <[email protected]>
- Loading branch information
1 parent
b80c7c3
commit 2c4b980
Showing
5 changed files
with
173 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package v3 | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestPollInterval(t *testing.T) { | ||
tests := []struct { | ||
runTime time.Duration | ||
expectedMin time.Duration | ||
expectedMax time.Duration | ||
description string | ||
}{ | ||
{ | ||
runTime: 10 * time.Second, | ||
expectedMin: 3 * time.Second, | ||
expectedMax: 3 * time.Second, | ||
description: "Polling at 10 seconds should return 3 seconds", | ||
}, | ||
{ | ||
runTime: 30 * time.Second, | ||
expectedMin: 3 * time.Second, | ||
expectedMax: 3 * time.Second, | ||
description: "Polling at 30 seconds should still return 3 seconds", | ||
}, | ||
{ | ||
runTime: 60 * time.Second, | ||
expectedMin: 3 * time.Second, | ||
expectedMax: 7 * time.Second, // Expected range after 30s should increase linearly | ||
description: "Polling at 60 seconds should return a value greater than 3 seconds but less than 7 seconds", | ||
}, | ||
{ | ||
runTime: 300 * time.Second, | ||
expectedMin: 3 * time.Second, | ||
expectedMax: 24 * time.Second, // Interval keeps increasing linearly | ||
description: "Polling at 5 minutes should return a value in the correct range (up to 24 seconds)", | ||
}, | ||
{ | ||
runTime: 900 * time.Second, // 15 minutes | ||
expectedMin: 60 * time.Second, | ||
expectedMax: 60 * time.Second, | ||
description: "Polling at 15 minutes should return exactly 60 seconds", | ||
}, | ||
{ | ||
runTime: 1200 * time.Second, // 20 minutes | ||
expectedMin: 60 * time.Second, | ||
expectedMax: 60 * time.Second, | ||
description: "Polling beyond 15 minutes should cap at 60 seconds", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.description, func(t *testing.T) { | ||
interval := pollInterval(test.runTime) | ||
if interval < test.expectedMin || interval > test.expectedMax { | ||
t.Errorf("pollInterval(%v) = %v, expected between %v and %v", | ||
test.runTime, interval, test.expectedMin, test.expectedMax) | ||
} | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters