-
Notifications
You must be signed in to change notification settings - Fork 82
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
Adds UT for ReconcileLoadBalancers function #1979
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: carmal891 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @carmal891! |
Hi @carmal891. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
/ok-to-test |
cloud/scope/powervs_cluster_test.go
Outdated
"go.uber.org/mock/gomock" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/utils/ptr" | ||
|
||
"sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta2" |
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 you should use the existing import infrav1beta2 "sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta2"
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.
Used existing import
c12d1a3
to
f7735d8
Compare
@Amulyam24 Adjusted UT as per issue #1937 |
f7735d8
to
9c6bdf5
Compare
/easycla |
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.
Thank you for the PR @carmal891!
Minor suggestions, overall LGTM
|
||
loadBalancerStatus, ok := clusterScope.IBMPowerVSCluster.Status.LoadBalancers["test-lb"] | ||
g.Expect(ok).To(BeTrue()) | ||
g.Expect(loadBalancerStatus.State).To(BeEquivalentTo(infrav1beta2.VPCLoadBalancerStateActive)) |
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.
would be good to check all values set in status wherever applicable such as
g.Expect(loadBalancerStatus.ControllerCreated).To(BeFalse())
g.Expect(loadBalancerStatus.Hostname).To(Equal("test-lb-hostname"))
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.
done
cloud/scope/powervs_cluster_test.go
Outdated
|
||
loadBalancer, ok := clusterScope.IBMPowerVSCluster.Status.LoadBalancers["test-lb"] | ||
g.Expect(ok).To(BeTrue()) | ||
g.Expect(loadBalancer.State).To(BeEquivalentTo(infrav1beta2.VPCLoadBalancerStateActive)) |
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.
would be good to check all values set in status
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.
Done
cloud/scope/powervs_cluster_test.go
Outdated
ID: nil, | ||
}, | ||
}, | ||
VPCSubnets: nil, |
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 no need to specify explicitly, the value would be nil
by default right?
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.
True that the default value for VPCSubnets would be nil, I think explicitly setting it to nil improves readability and clarity. Let me know your opinion
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.
Makes sense 👍🏼
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 think its not needed as it just increases number of lines of code, Its up to you to keep it or remove..
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.
corrected as to stay uniform with existing style in codebase
7a6cc35
to
e747c23
Compare
e747c23
to
9660420
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.
Overall LGTM apart from a minor comment!
|
||
loadBalancer, ok := clusterScope.IBMPowerVSCluster.Status.LoadBalancers["test-lb"] | ||
g.Expect(ok).To(BeTrue()) | ||
g.Expect(loadBalancer.State).To(BeEquivalentTo(infrav1beta2.VPCLoadBalancerStateActive)) |
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.
How about we verify the values of ControllerCreated
and Hostname
in status when the resource is created via controller?
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.
Done
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.
Non blocking minor things, LGTM.
cloud/scope/powervs_cluster_test.go
Outdated
} | ||
|
||
mockVpc.EXPECT().GetLoadBalancerByName(gomock.Any()).Return(nil, nil) | ||
mockVpc.EXPECT().CreateLoadBalancer(gomock.Any()).Return(nil, nil, errors.New("Failed loadBalancer creation")) |
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.
Not a blocking one, But its better to make sure errors are in small case.
mockVpc.EXPECT().CreateLoadBalancer(gomock.Any()).Return(nil, nil, errors.New("Failed loadBalancer creation")) | |
mockVpc.EXPECT().CreateLoadBalancer(gomock.Any()).Return(nil, nil, errors.New("failed loadBalancer creation")) |
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.
Done
cloud/scope/powervs_cluster_test.go
Outdated
ID: nil, | ||
}, | ||
}, | ||
VPCSubnets: nil, |
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 think its not needed as it just increases number of lines of code, Its up to you to keep it or remove..
/retest |
/easycla |
df0e4e0
to
fd724d2
Compare
/easycla |
47f36d6
to
4e59684
Compare
@carmal891: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
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.
One small change, Otherwise LGTM
Spec: infrav1beta2.IBMPowerVSClusterSpec{ | ||
LoadBalancers: []infrav1beta2.VPCLoadBalancerSpec{ | ||
{ | ||
ID: core.StringPtr("test-lb-instanceid"), |
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.
Previously we were using core package for pointer conversion, Lately we are using "k8s.io/utils/ptr"
so lets use ptr.To()
(Wherever applicable in the file)
What this PR does / why we need it: Adds UT for ReconcileLoadBalancers function
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes # #1818
Special notes for your reviewer:
/area provider/ibmcloud
Release note: