Skip to content
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

Unittests for cilium k8sd feature #704

Merged
merged 6 commits into from
Oct 2, 2024
Merged

Conversation

maci3jka
Copy link
Contributor

There are lacks in unittest for cilium feature in k8sd this pr proves test coverage form 42.9% files, 44.4% statements to 85.7% files, 86.7% statements for github.com/canonical/k8s/pkg/k8sd/features/cilium package

@maci3jka
Copy link
Contributor Author

adresses also KU-1516

Copy link
Contributor

@HomayoonAlimohammadi HomayoonAlimohammadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @maci3jka! Great work. Almost LGTM, but left some minor comments.

src/k8s/pkg/k8sd/features/cilium/gateway_test.go Outdated Show resolved Hide resolved
src/k8s/pkg/k8sd/features/cilium/gateway_test.go Outdated Show resolved Hide resolved
src/k8s/pkg/k8sd/features/cilium/loadbalancer_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@eaudetcobello eaudetcobello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. I left 2 comments that are applicable to multiple places in the PR, could you please revisit?

Comment on lines 139 to 144
g.Expect(status.Message).To(Equal(fmt.Sprintf(cilium.IngressDeployFailedMsgTmpl,
fmt.Errorf("failed to rollout restart cilium to apply ingress: %v",
fmt.Errorf("failed to restart cilium-operator deployment after 3 attempts: %w",
fmt.Errorf("failed to restart cilium-operator deployment: %w",
fmt.Errorf("failed to get deployment cilium-operator in namespace kube-system: %w",
errors.New("deployments.apps \"cilium-operator\" not found"))))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too tightly coupled to the message structure and contents. I see several instances of testing the specific error message in this PR, can those be reverted? I would much rather use a simple errors.Is, if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood other review comments. I updated the test. Regarding errors when it makes sense i use gomega expect(err).To(ErrorMatch()) which checks if the error is in the chain of errors will that be enough?

Copy link
Contributor

@eaudetcobello eaudetcobello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks!

Copy link
Contributor

@HomayoonAlimohammadi HomayoonAlimohammadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @maci3jka!

@maci3jka maci3jka merged commit 83ca3ed into main Oct 2, 2024
18 of 19 checks passed
@maci3jka maci3jka deleted the KU-1517/cilium-unittests branch October 2, 2024 13:42
evilnick pushed a commit to evilnick/k8s-snap that referenced this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants