-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add tests for main Perses controller #5
Conversation
ef2c318
to
e956072
Compare
Signed-off-by: Gabriel Bernal <[email protected]>
"sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
) | ||
|
||
var _ = Describe("Perses controller", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit torn about this approach.
Thinking if don't make a bit harder for other go developers get starting with tests.
wdyt @Nexucis ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I forgot to comment about this. I'm thinking the same, it's more a php/javascript approach I believe.
The "Golang way" is more about creating a list of cases and then looping other it to run the tested function.
Like that for example: https://github.com/perses/perses/blob/main/pkg/model/api/v1/metadata_test.go#L24-L47
Or for more complicated use case that requires more struct, then you could have something like that:
https://github.com/perses/perses/blob/main/internal/cli/test/test.go
Which is used like that: https://github.com/perses/perses/blob/main/internal/cli/cmd/apply/apply_test.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thnx for your feedback, I followed the docs on testing operators. In which test are run using envtest
controller runtime so the eventual state of the operator can be asserted, I believe the goal here is not to test expected outputs of a function as the reconcilers creates resources in a cluster as a side effect. Are there other approaches or suggestions @simonpasquier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion on the topic. In fact all the operators I've been working on have developed their own home-made framework (based on the Go testing library) to run end-to-end tests. In my current experiences, the end-to-end tests require a running Kube cluster (typically Kind), they setup all required resources (e.g. CRDs, service accounts, roles, bindings, ...) then they run the operator binary and exercise various scenarios.
So I've got no direct experience with the envtest framework and I understand that it can feel a bit daunting at first but at the same time, it may simplify the setup and teardown of the test environment.
@nicolastakashi @Nexucis would you be ok to proceed with this approach for e2e tests? |
ah yeah sorry I forgot to reply here. So yeah on my side I'm ok to move forward on this PR if like Simon said, using this framework is simplifying the setup I'm good with that |
This PR adds testing for the main Perses controller. Asserting that the service, configMap, deployment are reconciled based on Perses CR