pkg/controller
Antoine Cotten c56f5e203b
Reduce delays in controller tests (#1603)
* TestEnqueue: remove unnecessary calls to Sleep

The rate limiter applies only when multiple items are put onto the
workqueue, which is not the case in those tests.

Execution: ~7.6s -> ~2.1s

* TestEnqueueAfter: remove assumptions on execution times

Instead of sleeping for a conservative amount of time, keep watching the
state of the workqueue in a goroutine, and notify the test logic as soon
as the item is observed.

Execution: ~1s -> ~0.05s

* TestEnqueueKeyAfter: remove assumptions on execution times

Instead of sleeping for a conservative amount of time, keep watching the
state of the workqueue in a goroutine, and notify the test logic as soon
as the item is observed.

Execution: ~1s -> ~0.05s

* TestStartAndShutdownWithErroringWork: remove sleep

Instead of sleeping for a conservative amount of time, keep watching the
state number of requeues in a goroutine, and notify the test logic as
soon as the expected threshold is reached.

Logs, for an idea of timings
----------------------------
Started workers
Processing from queue bar (depth: 0)
Reconcile error {"error": "I always error"}
Requeuing key bar due to non-permanent error (depth: 0)
Reconcile failed. Time taken: 104µs     {"knative.dev/key": "bar"}
Processing from queue bar (depth: 0)
Reconcile error {"error": "I always error"}
Requeuing key bar due to non-permanent error (depth: 0)
Reconcile failed. Time taken: 48.2µs    {"knative.dev/key": "bar"}

Execution: ~1s -> ~0.01s

* TestStart*/TestRun*: reduce sleep time

There is no need to sleep for that long. If an error was returned, it
would activate the second select case immediately.

Execution: ~1s -> ~0.05s

* TestImplGlobalResync: reduce sleep time

We know the fast lane is empty in this test, so we can safely assume
immediate enqueuing of all items on the slow lane.

Logs, for an idea of timings
----------------------------
Started workers
Processing from queue foo/bar (depth: 0)
Reconcile succeeded. Time taken: 11.5µs {"knative.dev/key": "foo/bar"}
Processing from queue bar/foo (depth: 1)
Processing from queue fizz/buzz (depth: 0)
Reconcile succeeded. Time taken: 9.7µs  {"knative.dev/key": "fizz/buzz"}
Reconcile succeeded. Time taken: 115µs  {"knative.dev/key": "bar/foo"}
Shutting down workers

Execution: ~4s -> ~0.05s

* review: Replace for/select with PollUntil

* review: Remove redundant duration multiplier

* review: Replace defer with t.Cleanup
2020-08-26 10:09:06 -07:00
..
testing Remove key in tags to reduce metrics count (#1494) 2020-07-15 01:29:32 -07:00
OWNERS add self to aliases and add reviewers to OWNERS (#1409) 2020-06-22 12:30:27 -07:00
controller.go Optimize and clean the controller code (#1639) 2020-08-21 22:20:46 -07:00
controller_test.go Reduce delays in controller tests (#1603) 2020-08-26 10:09:06 -07:00
helper.go Avoid copying object if TypeMeta is already correct. (#1561) 2020-07-28 00:09:58 -07:00
helper_test.go Avoid copying object if TypeMeta is already correct. (#1561) 2020-07-28 00:09:58 -07:00
options.go Add an option to skip automated status updates in a reconciler. (#1456) 2020-06-30 08:02:29 -07:00
stats_reporter.go Remove key in tags to reduce metrics count (#1494) 2020-07-15 01:29:32 -07:00
stats_reporter_test.go Fix the flaky test. (#1632) 2020-08-18 17:06:13 -07:00
two_lane_queue.go Allow creating controller with custom RateLimiter. (#1546) 2020-08-03 14:31:28 -07:00
two_lane_queue_test.go Fix the flaky test. (#1632) 2020-08-18 17:06:13 -07:00