Closed erikgb closed 1 year ago
Great initiative looking forward to see the PR
Great initiative looking forward to see the PR
@chen-keinan I am glad you like the idea! Here's a teaser (spoiler-alert): https://github.com/aquasecurity/trivy-operator/pull/337/files ;-)
Working with trivy-operator for a couple of weeks, I already managed to propose changes that introduced bugs. And these bugs were not detected by CI and merged into main. That tells me we need better tests. 😄
I am unable to run integration tests locally for two reasons:
To mend this, I am suggesting to introduce envtest clusters to run (integration) tests. How this might look like, is fairly well documented in the kubebuilder book. This will allow the integration tests to run in a standard Go test - without bootstrapping a full cluster (like kind).
make
will be supported without requirements to install anything, as there is a nice tool to setup envtest available. Running tests for multiple versions of Kubernetes is also possible with ease.I can prepare a PR suggesting envtest integration tests for vulnerability scanning, so you can have a look at the details in this proposal. We (as in my team/company) are currently only interested in the vulnerability scanning feature in trivy-operator, so I am not prepared to do the work on the other controllers. But if the community likes this idea, I hope that someone else can contribute writing tests for the remaining controllers!
If you think this approach looks good, I think this could be an overall plan for refactoring/improving the tests in trivy-operator: