Fix flaky store cooldown test

This commit is contained in:
Pavel Škoda
2020-05-27 10:06:23 +02:00
committed by James Houlahan
parent cc14b523cb
commit 8cdebb6d05
2 changed files with 10 additions and 9 deletions

View File

@ -16,6 +16,8 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
* GODT-390 Don't logout user if AuthRefresh fails because internet was off. * GODT-390 Don't logout user if AuthRefresh fails because internet was off.
* GODT-358 Bad timeouts with Alternative Routing * GODT-358 Bad timeouts with Alternative Routing
* GODT-390 Don't logout user if AuthRefresh fails because internet was off
* GODT-341 Fixed flaky unittest for Store synchronization cooldown
## [v1.2.7] Donghai-hotfix - beta (2020-05-07) ## [v1.2.7] Donghai-hotfix - beta (2020-05-07)

View File

@ -117,17 +117,16 @@ func TestCooldownIncreaseAndReset(t *testing.T) {
func TestCooldownNotSooner(t *testing.T) { func TestCooldownNotSooner(t *testing.T) {
var testCooldown cooldown var testCooldown cooldown
waitTime := 100 * time.Millisecond waitTime := 100 * time.Millisecond
retries := int64(10)
retryWait := time.Duration(waitTime.Milliseconds()/retries) * time.Millisecond
testCooldown.setWaitTimes(waitTime) testCooldown.setWaitTimes(waitTime)
// first time it should never be too soon // First time it should never be too soon.
assert.False(t, testCooldown.isTooSoon()) assert.False(t, testCooldown.isTooSoon())
// these retries should be too soon
for i := retries; i > 0; i-- { // Only half of given wait time should be too soon.
assert.True(t, testCooldown.isTooSoon()) time.Sleep(waitTime / 2)
time.Sleep(retryWait) assert.True(t, testCooldown.isTooSoon())
}
// after given wait time it shouldn't be soon anymore // After given wait time it shouldn't be soon anymore.
time.Sleep(waitTime / 2)
assert.False(t, testCooldown.isTooSoon()) assert.False(t, testCooldown.isTooSoon())
} }