reconcilerio / runtime

Kubernetes reconciler framework building on controller-runtime
https://reconciler.io/runtime
Apache License 2.0
24 stars 5 forks source link

install watch reaction function to fake client #550

Open AshishNaware opened 1 month ago

AshishNaware commented 1 month ago

This PR adds ability to install watch reaction function to the fake client. This will help in writing tests where its required to simulate behavior of the watcher.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 58.85%. Comparing base (7437a9b) to head (c533767). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
testing/config.go 0.00% 2 Missing and 1 partial :warning:
testing/client.go 33.33% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #550 +/- ## ========================================== - Coverage 58.93% 58.85% -0.09% ========================================== Files 33 33 Lines 2981 2987 +6 ========================================== + Hits 1757 1758 +1 - Misses 1130 1134 +4 - Partials 94 95 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

scothis commented 1 month ago

Hi @AshishNaware. Thanks for the contribution. This change is heading in the right direction, but is also incomplete as it has no runtime effect. WithWatchReactors needs to be plumbed into the test cases (ReconcilerTestCase/SubReconcilerTestCase/AdmissionWebhookTestCase) the same way WithReactors is. That part is relatively simple. The more complicated part will be consuming the WatchReactionFunc. The client wrapper doesn't currently implement Watch that method will need to be implemented and consume the reaction funcs. The DuckAwareClientWrapper also needs to have Watch added.

Let me know if you need any pointers into the code base.

AshishNaware commented 1 month ago

Hi @AshishNaware. Thanks for the contribution. This change is heading in the right direction, but is also incomplete as it has no runtime effect. WithWatchReactors needs to be plumbed into the test cases (ReconcilerTestCase/SubReconcilerTestCase/AdmissionWebhookTestCase) the same way WithReactors is. That part is relatively simple. The more complicated part will be consuming the WatchReactionFunc. The client wrapper doesn't currently implement Watch that method will need to be implemented and consume the reaction funcs. The DuckAwareClientWrapper also needs to have Watch added.

Let me know if you need any pointers into the code base.

Hey. Thanks for the feedback. Let me dig more into the code-base. I will create a thread here if i have any questions :)

AshishNaware commented 4 weeks ago

@scothis - I just took a quick glance at the code and I see a Watch method already implemented for duckAwareClientWrapper that returns a watch.Interface. I assume that we need a similar implementation for the clientWrapper as well. thoughts?

scothis commented 4 weeks ago

I assume that we need a similar implementation for the clientWrapper as well. thoughts?

Yep. This is also where the watch reaction funcs should be applied.