-
Notifications
You must be signed in to change notification settings - Fork 199
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
Added Koperator end to end tests #987
Conversation
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.
Sorry, got a lot of comments, many of them are repeating though, so it's okay to answer those only once and they shouldn't require too much effort to fix. Overall I've got some suggestions that I'd like to see implemented, but these are suggestions, it's all up for discussion.
Makefile
Outdated
@@ -102,7 +102,11 @@ test: generate fmt vet manifests bin/setup-envtest | |||
test-e2e: | |||
go test github.com/banzaicloud/koperator/tests/e2e \ | |||
-v \ | |||
-timeout 5m | |||
-timeout 15m \ | |||
--ginkgo.fail-fast \ |
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 think we agreed the tests should be slow failing, so this line might need to be removed when we're done with testing the tests. Just a note really.
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.
It is now only for testing purposes after Patrik PR I will change it.
tests/e2e/cert_manager_test.go
Outdated
fmt.Sprintf(managedByHelmLabelTemplate, "cert-manager"), | ||
"", | ||
kubectlArgGoTemplateKindNameNamespace, | ||
"--all-namespaces") |
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.
Question: Will this overwrite the namespace in the kubectlOptions?
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.
Yes, the --all-namespaces overwrites the -n namespace parameter effect
1f98ba9
to
9db5a56
Compare
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.
Implementation looks great! Just something very minor
tests/e2e/helm_test.go
Outdated
purge bool, | ||
extraArgs ...string, | ||
) { | ||
By(fmt.Sprintf("Checking for existing Helm release names %s", helmReleaseName)) |
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.
We shouldn't use plural since we are checking for one single here
By(fmt.Sprintf("Checking for existing Helm release names %s", helmReleaseName)) | |
By(fmt.Sprintf("Checking for existing Helm release name %s", helmReleaseName)) |
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.
fixed: b0b2558
tests/e2e/helm_test.go
Outdated
} | ||
|
||
// installHelmChart deploys a Helm chart to the specified kubectl context and | ||
// namespace using the specified infos, extra arguments can be any of the helm |
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.
// namespace using the specified infos, extra arguments can be any of the helm | |
// namespace using the specified info, extra arguments can be any of the helm |
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.
fixed: b0b2558
tests/e2e/helm_test.go
Outdated
// installHelmChart checks whether the specified named Helm release exists in | ||
// the provided kubectl context and namespace, logs it if it does and returns or | ||
// alternatively deploys the Helm chart to the specified kubectl context and | ||
// namespace using the specified infos, extra arguments can be any of the helm |
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.
// namespace using the specified infos, extra arguments can be any of the helm | |
// namespace using the specified info, extra arguments can be any of the helm |
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.
fixed:b0b2558
b905456
to
56b6b8a
Compare
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.
LGTM
tests/e2e/helm.go
Outdated
// uninstallHelmChart uninstall Helm chart from the specified kubectl context and | ||
// namespace using the specified helm release name. When purge is true, it removes records | ||
// and make that name free to be reused for another installation. | ||
// Extra arguments can be any of the helm CLI uninstall flag arguments. |
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.
// uninstallHelmChart uninstall Helm chart from the specified kubectl context and | |
// namespace using the specified helm release name. When purge is true, it removes records | |
// and make that name free to be reused for another installation. | |
// Extra arguments can be any of the helm CLI uninstall flag arguments. | |
// uninstallHelmChart uninstalls a Helm chart from the specified kubectl context and | |
// namespace using the specified helm release name. When purge is true, it removes records | |
// and makes that name free to be reused for another installation. | |
// Extra arguments can be any of the helm CLI uninstall flag arguments. |
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.
There are multiple files in which the It(...)
executed functions should be error-checked. (At some places this is fixed, but you missed a couple. Let me know if I should provide a list of places.)
tests/e2e/uninstall.go
Outdated
k8sResourceKinds, err := listK8sAllResourceKind(kubectlOptions) | ||
Expect(err).ShouldNot(HaveOccurred()) | ||
|
||
koperatorAvailableResourceKinds := stringSlicesUnion(koperatorCRDs(), k8sResourceKinds) | ||
koperatorAvailableResourceKinds = append(koperatorAvailableResourceKinds, basicK8sResourceKinds()...) | ||
|
||
remainedResources, err := getK8sResources(kubectlOptions, | ||
koperatorAvailableResourceKinds, | ||
fmt.Sprintf(managedByHelmLabelTemplate, koperatorLocalHelmDescriptor.ReleaseName), | ||
"", | ||
kubectlArgGoTemplateKindNameNamespace, | ||
"--all-namespaces") | ||
|
||
Expect(err).ShouldNot(HaveOccurred()) | ||
Expect(remainedResources).Should(BeEmpty()) | ||
}) |
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.
Note: This is fine like this for now, but in a follow-up ticket we want to move these kind of checks higher up onto case level when this becomes unnecessary.
Then everything will fold up because the Helm chart uninstallation becomes only 1 line, the Koperator uninstallation becomes only 1 line so we can omit those and put the uninstall Koperator It(...)
directly into the uninstall test case.
Same thing I did at the last refactor of the install test case.
Same holds true for the other components.
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 dont understand what do you mean. Please explain in priv.
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 know you put in your test_install.go directly those tests under When containers. Somehow I felt that it is clener and maybe more reusable if I kept the original form and put evreything in functions.
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 wrote in private.
c31e4dd
to
1a732a8
Compare
1a732a8
to
46b2d71
Compare
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.
Earlier unresolved threads:
- Added Koperator end to end tests #987 (comment)
- Added Koperator end to end tests #987 (comment)
- (fixed since) Added Koperator end to end tests #987 (comment)
The fixes were great, thanks.
There were a couple error checks missed so I'm commenting them by line to make it easier to go through.
Test after my suggestions, I wrote them from the top of my mind.
}, | ||
) | ||
err := waitK8sResourceCondition(kubectlOptions, kafkaTopicKind, "jsonpath={.status.state}=created", defaultTopicCreationWaitTime, "", topicName) | ||
Expect(err).ShouldNot(HaveOccurred()) |
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.
Note: According to https://pkg.go.dev/github.com/onsi/gomega#Assertion typically expect uses NotTo
compared to ShouldNot
, but I'm not picky about that, but we should use one of the two throughout the tests for easier human pattern recognition. I don't mind which one we use, if we feel like ShouldNot is easier to read, fine for me. I used NotTo due to being used to that, but no hard feelings.
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 saw somewhere (gomega tooltip) that the "Expect(err).ShouldNot(HaveOccurred())" should be used to check error
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.
Could you search around just quickly in 5m what is the official suggestion here?
What I linked is the official gomega docs, so I don't understand why some tooltip would be the direct opposite.
But as I said, I don't care which, whatever is preferred officially is fine for me, I care about not mixing the two.
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 personally have no preference in this, both are easy to understand really. My only issue is that it would be nice to be consistent across our code, so we should really pick one. I'm not saying we have to fix this now as all occurrences can be easily replaced at any time but at some point we should I think.
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.
Optional: I MAY consider renaming this file to string.go
for now.
Generic util packages and files are an anti-pattern because they are used as dumps instead of thinking through the organization of the units, currently this only has a string function so I would use this as string function collector file, in the future we can figure out if there is anything else to add.
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.
Im sure that we will have things what will need to be added into the utils.go later.
Creating a new file for one function I think is not worth.
Because it is optional from you I would keep it as it is.
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.
Ok, consider this resolved, feel free to mark the conversation as resolved.
Context: The problem is, when you are looking for something in a structured way util.go is difficult to decipher without looking into it and if there are multiple not connected functions in it, it will become a mess internally.
Instead if we structurize these functions based on their nature/topic/etc. such as string modification functions it is easier to look at the files list in the package and quickly guess where you should look for different top level functions.
That was behind the helm.go, k8s.go files as well.
It("Setting globals", func() { | ||
err := dependencyCRDs.Initialize(kubectlOptions) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) |
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.
Note: This needs to be moved to the per case before once we handle that ticket. Nothing to do now.
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.
Couple optional things and arguable recommendations, otherwise looks ok.
@@ -0,0 +1,52 @@ | |||
package e2e |
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.
(For some reason my file level commend does not work this morning.)
Optional: IMO this other than the version type which I commented, the rest of the file would fit into k8s.go
with the dependencyCRDsType
and the functions because we are doing k8s related ops with those.
I'm fine to leave this here if others agree it's more clear this way, but it's weird for me.
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.
Still looks good to me overall
Description
Adding basic end to end tests for Koperator.
Included tests:
Type of Change
Checklist