digitalocean / digitalocean-cloud-controller-manager

Kubernetes cloud-controller-manager for DigitalOcean (beta)
Apache License 2.0
524 stars 147 forks source link

Provider fake load-balancer service implementation #243

Open timoreimann opened 5 years ago

timoreimann commented 5 years ago

Similar to our fake tag service, we should also provide a fake load-balancer service. This will make testing much simpler because testers won't need to think about what each API method should return anymore. Instead, it allows to focus on what load-balancer resources the fake should be populated with initially and leave the rest to the implemented logic.

cpanato commented 4 years ago

@timoreimann can I try this one? Anything special I need to know? Thanks

timoreimann commented 4 years ago

Heya @cpanato 👋

I'd be more than happy to let you take a stab at this one.

I think the basic idea is spelled out in this issue's description. My tl;dr is that we shouldn't have to spend so much time programming/configuring the LB test doubles, at least not for happy path testing: the fake should implement the logic and mimic how the public LB API behaves as good as possible. Ideally, we'd also want this better fake framework to support stubbing out errors (though an argument could be made that we should better refer to stubs/mocks for that purpose).

I previously worked on this task but never managed to finish it off. The basic fake implementation is there (along with a means to fake out errors, modelled about client-go's fake implementation), with the major chunk of remaining work being to update the tests (and make any changes to the fake along the way as it makes sense).

You can take a look at my https://github.com/digitalocean/digitalocean-cloud-controller-manager/tree/add-lb-fake branch if you like. There's a ton of WIP commits, with the delta itself being fairly small.

I'm always open to considering alternative approaches If you think it makes sense. Happy to discuss here and/or based on a demonstrative PR.

Thanks for the offer to help out, appreciated!