Add better unit tests for watcher
#1528
Labels
automation
ci and testing related
help wanted
Not immediately prioritised, please help!
runtime
controller runtime related
What problem are you trying to solve?
Avoiding releasing accidentally breaking watcher changes in the future.
0.92.0 had a change that passed 3 different types of tests; #1524 (comment) and still failed.
Describe the solution you'd like
Create a
#[cfg(test)]
struct inwatcher.rs
and provide an injectable test implementation ofApiMode
for it:kube/kube-runtime/src/watcher.rs
Lines 158 to 170 in 01f9c0c
This would allow us to use this test struct to inject synthetic events (via e.g.
TestStruct::new(list, stream)
) that model actual apiserver responses (but without actually calling watch). This should allow us to verify a bunch of things from unit tests, such as (but not limited to):list
N times (depending on page sizes), and thenwatch
list
in streaming listsIt also lets us verify that that we are handling edge cases (currently we have very little error testing here).
Describe alternatives you've considered
Extend mock tests in https://github.com/kube-rs/kube/blob/main/kube/src/mock_tests.rs#L29-L159
This has already been somewhat done to avoid the previous case triggering, but would like something a little more robust ideally. There's little distinction between
list
andwatch
in these mock tests atm and I have not been able to test the watch side with it. If this test harness can be made more robust then this is also helpful, but ideally we should have unit tests in the are where the code is present (rather than rely on top level stuff too much).Target crate for feature
kube-runtime
The text was updated successfully, but these errors were encountered: