-
Notifications
You must be signed in to change notification settings - Fork 89
Adds UT for ReconcileLoadBalancers function #1979
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
Conversation
|
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
47f36d6
to
4e59684
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.
One small change, Otherwise LGTM
cloud/scope/powervs_cluster_test.go
Outdated
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)
4e59684
to
29511df
Compare
Just a quick update, @dharaneeshvrd is submitting a fix for #2026, So which might require slight change in this UT, so lets keep an eye on this and update it accordingly. |
34e722a
to
e43c107
Compare
@Karthik-K-N Adjusted as per fix for #2026. Additionally added UT for individual sub functions as discussed |
cloud/scope/powervs_cluster_test.go
Outdated
|
||
mockVpc.EXPECT().GetLoadBalancer(gomock.Any()).Return(nil, nil, errors.New("failed to fetch VPC load balancer details")) | ||
|
||
requeue, err := clusterScope.ReconcileLoadBalancers() |
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.
requeue, err := clusterScope.ReconcileLoadBalancers() | |
loadBalancerReady, err := clusterScope.ReconcileLoadBalancers() |
Please change variable and test case name wherever applicable.
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
cloud/scope/powervs_cluster_test.go
Outdated
g.Expect(err).ToNot(BeNil()) | ||
}) | ||
|
||
t.Run("When createLoadBalancer returns error as resource group id is empty", func(*testing.T) { |
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 see a couple of redundant test cases here and in TestCreateLoadbalancer
, can we remove from one function?
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.
Removed redundant cases
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
4446e21
to
f652f65
Compare
38621ea
to
2232256
Compare
/assign @Prajyot-Parab |
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
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Amulyam24, carmal891, Prajyot-Parab The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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: