Skip to content

Commit

Permalink
apiserver/storage/cacher: decrease the running time of tests in the c…
Browse files Browse the repository at this point in the history
…acher package.

It turns out that kube has a custom timeout for tests of 3 minutes.
The tests in the cacher package are utilizing nearly the
entire time and are being terminated, resulting in failing jobs.

Before the change, the TestWatchSemantics took ~43s to run. With this simple change, it now takes ~18s.

When we created the tests, we didn't measure the running time and assumed that waiting 1 second on a watch channel
to make sure no more events are received was sufficient.
This PR decreases the waiting time to 300 milliseconds.
Modern computers can perform many tasks within that time.
In addition to that, the tests are serial in nature, meaning that there is no other
actor that could add items to the database, which could result in receiving new items.

After the change the total running time decreased by 17%.
Before the tests needed ~176s after they need ~146s.
The changes also improved TestWatchSemanticInitialEventsExtended.

Kubernetes-commit: d9ca300598e7195545ca38ab9e5e640a2379d553
  • Loading branch information
p0lyn0mial authored and k8s-publishing-bot committed Mar 12, 2024
1 parent 582da82 commit 0946a03
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion pkg/storage/testing/watcher_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,6 @@ func RunWatchSemantics(ctx context.Context, t *testing.T, store storage.Interfac
// make sure we only get initial events
testCheckResultsInStrictOrder(t, w, scenario.expectedInitialEvents(createdPods))
testCheckResultsInStrictOrder(t, w, scenario.expectedInitialEventsBookmark(createdPods))
testCheckNoMoreResults(t, w)

createdPods = []*example.Pod{}
// add a pod that is greater than the storage's RV when the watch was started
Expand Down

0 comments on commit 0946a03

Please sign in to comment.