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

enh: add tests for checkListenerPorts #2405

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

sakshi-1505
Copy link
Contributor

What this PR does / why we need it:
It increase unit test coverage for LB file

Which issue this PR fixes(if applicable):
refers #2400

Special notes for reviewers:

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 8, 2023
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 8, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @sakshi-1505. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 8, 2023
@jichenjc
Copy link
Contributor

jichenjc commented Oct 9, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 9, 2023
@sakshi-1505
Copy link
Contributor Author

/retest

Port: 9090,
}: {
ID: "listenerid",
Tags: []string{"test-lb", "test-lb2"},
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can only have one LB on a listener in our logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 539 to 541
type fields struct {
LoadBalancer LoadBalancer
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't seem you ever use this? Can we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was added to mimic the interface of LoadBalancer, although we didn't use any field for the caller but it is actually needed to invoke the function from LoadBalancer interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

But no test case defines LoadBalancer as anything else than LoadBalancer{}. Can't we just define it in the loop that goes over the test cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that makes sense, I will just define it in the loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}
tests := []struct {
name string
fields fields
Copy link
Contributor

Choose a reason for hiding this comment

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

And this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 616 to 665
{
name: "error is not thrown if lbOwner is present & no tags on service",
args: args{
service: &corev1.Service{
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Name: "service",
Protocol: "https",
Port: 9090,
},
},
},
},
curListenerMapping: map[listenerKey]*listeners.Listener{
{
Protocol: "https",
Port: 9090,
}: {
ID: "listenerid",
},
},
isLBOwner: true,
lbName: "test-lb",
},
wantErr: false,
fields: fields{
LoadBalancer: LoadBalancer{},
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a case when lbOwner=true and there are some tags on the Service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 9, 2023
Comment on lines 539 to 541
type fields struct {
LoadBalancer LoadBalancer
}
Copy link
Contributor

Choose a reason for hiding this comment

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

But no test case defines LoadBalancer as anything else than LoadBalancer{}. Can't we just define it in the loop that goes over the test cases?

@sakshi-1505
Copy link
Contributor Author

@pierreprinetti Please check this I have made all the changes which @dulek had requested

@pierreprinetti
Copy link
Member

Thank you! Please rebase and we're good 🚀

@sakshi-1505
Copy link
Contributor Author

Thank you! Please rebase and we're good 🚀

I think it's already aligned with master branch, can you please check again?

@pierreprinetti
Copy link
Member

pierreprinetti commented Oct 16, 2023

the label said otherwise . Can you please check? This also needs a rebase squash by the way.

@sakshi-1505
Copy link
Contributor Author

sakshi-1505 commented Oct 16, 2023 via email

@pierreprinetti
Copy link
Member

The problem here is that you have meged master into your branch, whereas you should have rebased your branch onto master.

You have several options, the cleanest of which would entail git fetch --all && git rebase -i origin/master. I encourage you to explore that.

If you find yourself stuck, be aware that you can cancel the rebase at any time with git rebase --abort.


If instead you just want the job done and you're not afraid of using any means necessary:

git reset origin/master --hard \
	&& git apply <(curl -sSL https://github.com/kubernetes/cloud-provider-openstack/pull/2405.diff) \
	&& git add --all \
	&& git commit

But please don't tell anyone 🤫


In any case, for the next time, I strongly advise you rebase instead of merging:

git fetch origin
git rebase origin/master

@sakshi-1505
Copy link
Contributor Author

Thanks @pierreprinetti I will remember this from now on, can you please approve this?

@pierreprinetti
Copy link
Member

Unfortunately, another PR merged and you've won a new rebase round

@pierreprinetti
Copy link
Member

Or maybe I am misinterpreting the label?
/lgtm
/assign jichenjc

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 17, 2023
@jichenjc
Copy link
Contributor

/approve
/hold

hold for conflict solve, then let's unhold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 18, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jichenjc

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 18, 2023
@sakshi-1505
Copy link
Contributor Author

@jichenjc @pierreprinetti can you please re-add the lgtm labels & merge this?

@jichenjc
Copy link
Contributor

/lgtm
/hold cancel

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Oct 24, 2023
@k8s-ci-robot k8s-ci-robot merged commit 8da2313 into kubernetes:master Oct 24, 2023
mandre pushed a commit to shiftstack/cloud-provider-openstack that referenced this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants