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

add unit tests for createHeadlessSvcIfNecessary #526

Conversation

dejanzele
Copy link
Contributor

Add unit tests for createHeadlessSvcIfNecessary

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 16, 2024
@k8s-ci-robot k8s-ci-robot requested review from ahg-g and kannon92 April 16, 2024 23:19
@k8s-ci-robot
Copy link
Contributor

Hi @dejanzele. 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 /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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 16, 2024
Copy link

netlify bot commented Apr 16, 2024

Deploy Preview for kubernetes-sigs-jobset canceled.

Name Link
🔨 Latest commit 8526b6a
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-jobset/deploys/6628d12e81b0900008c7b0ed

@dejanzele
Copy link
Contributor Author

dejanzele commented Apr 16, 2024

/cc @danielvegamyhre

@dejanzele dejanzele force-pushed the feat/createHeadlessSvcIfNecessary-unit-test branch from 6d92e4e to b53124e Compare April 16, 2024 23:29
@danielvegamyhre
Copy link
Contributor

/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 Apr 16, 2024
@dejanzele dejanzele force-pushed the feat/createHeadlessSvcIfNecessary-unit-test branch from b53124e to d53c8cc Compare April 17, 2024 18:33
Copy link
Contributor

@kannon92 kannon92 left a comment

Choose a reason for hiding this comment

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

/lgtm
/assign @danielvegamyhre @ahg-g

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 17, 2024
pkg/controllers/jobset_controller_test.go Outdated Show resolved Hide resolved
}
fakeClientBuilder.WithObjects(svc)
}
fakeClient := fakeClientBuilder.Build()
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 should use an interceptorFunc in the fake client (as described here) in order to validate the actual r.Create(svc) calls done in the function.

@dejanzele dejanzele force-pushed the feat/createHeadlessSvcIfNecessary-unit-test branch from d53c8cc to bbc5bb1 Compare April 23, 2024 22:16
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 23, 2024
@dejanzele
Copy link
Contributor Author

thanks for the review @danielvegamyhre, I have addressed your comments

@dejanzele dejanzele force-pushed the feat/createHeadlessSvcIfNecessary-unit-test branch from bbc5bb1 to 7e6e6f5 Compare April 23, 2024 22:28
Copy link
Contributor

@danielvegamyhre danielvegamyhre left a comment

Choose a reason for hiding this comment

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

LGTM after 2 minor comments.

return errors.New("unexpected error")
}
if !tc.expectServiceCreate {
t.Fatal("unexpected service creation")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not t.Error() here? Don't we want to continue running the rest of the tests?

Copy link
Contributor Author

@dejanzele dejanzele Apr 24, 2024

Choose a reason for hiding this comment

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

I am not sure, it is an error if an unexpected service creation happens, but does it make sense to do further assertion on that service, if we didn't expect service creation in the first place?
At the end we also have assertions how many services we expected to be created (1 if we expect, 0 if we don't) which would also get skipped.

I don't have a strong opinion, you can make the decision.

pkg/controllers/jobset_controller_test.go Outdated Show resolved Hide resolved
@dejanzele dejanzele force-pushed the feat/createHeadlessSvcIfNecessary-unit-test branch from 7e6e6f5 to 8526b6a Compare April 24, 2024 09:30
@danielvegamyhre
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 24, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielvegamyhre, dejanzele, kannon92

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 24, 2024
@k8s-ci-robot k8s-ci-robot merged commit 9993c99 into kubernetes-sigs:main Apr 24, 2024
12 checks passed
@danielvegamyhre danielvegamyhre mentioned this pull request Aug 19, 2024
20 tasks
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. 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