Skip to content

Commit

Permalink
Attempting to fix flaky tests
Browse files Browse the repository at this point in the history
Some tests which relied on timeouts were a bit flaky in CI. This PR
raises the timeouts, which seemed to help with the flakiness on local
testing.
  • Loading branch information
MbolotSuse committed Apr 3, 2024
1 parent 9b00eb3 commit 7cf97fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/debounce/refresher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestRefreshAfter(t *testing.T) {
}
debounce.RefreshAfter(time.Millisecond * 2)
debounce.RefreshAfter(time.Microsecond * 2)
time.Sleep(time.Millisecond * 1)
time.Sleep(time.Millisecond * 2)
// test that the second refresh call overrode the first - Micro < Milli so this should have ran
require.True(t, ref.wasRefreshed.Load())
ref.wasRefreshed.Store(false)
Expand All @@ -42,6 +42,6 @@ func TestRefreshAfter(t *testing.T) {
}
debounce.RefreshAfter(time.Microsecond * 2)
// test the error case
time.Sleep(time.Millisecond * 1)
time.Sleep(time.Millisecond * 2)
require.True(t, ref.wasRefreshed.Load())
}
10 changes: 5 additions & 5 deletions pkg/schema/definitions/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Test_onChangeCRD(t *testing.T) {
}
refreshHandler := refreshHandler{
debounceRef: &refresher,
debounceDuration: time.Microsecond * 5,
debounceDuration: time.Microsecond * 2,
}
input := apiextv1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -51,7 +51,7 @@ func Test_onChangeAPIService(t *testing.T) {
}
refreshHandler := refreshHandler{
debounceRef: &refresher,
debounceDuration: time.Microsecond * 5,
debounceDuration: time.Microsecond * 2,
}
input := apiregv1.APIService{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -74,11 +74,11 @@ func Test_startBackgroundRefresh(t *testing.T) {
}
refreshHandler := refreshHandler{
debounceRef: &refresher,
debounceDuration: time.Microsecond * 5,
debounceDuration: time.Microsecond * 2,
}
ctx, cancel := context.WithCancel(context.Background())
refreshHandler.startBackgroundRefresh(ctx, time.Microsecond*10)
time.Sleep(time.Millisecond * 2)
refreshHandler.startBackgroundRefresh(ctx, time.Microsecond*2)
time.Sleep(time.Millisecond * 4)
require.True(t, internalRefresh.wasRefreshed.Load())
cancel()
}

0 comments on commit 7cf97fe

Please sign in to comment.