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

Improve test coverage for /pkg/controllers/certificate, with a minor optimization #5381

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

xovoxy
Copy link
Contributor

@xovoxy xovoxy commented Aug 15, 2024

What type of PR is this?
/kind cleanup
/kind failing-test

What this PR does / why we need it:
Add the test for /pkg/controllers/certificate, improve test coverage to 55%;
found some places in CertRotationController did not use a unified context, changed it together.
Which issue(s) this PR fixes:
Part of ##5235

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Aug 15, 2024
@karmada-bot karmada-bot added the kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. label Aug 15, 2024
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 15, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 30.32%. Comparing base (bcf68fa) to head (5e66106).

Files Patch % Lines
...ontrollers/certificate/cert_rotation_controller.go 87.50% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5381      +/-   ##
==========================================
+ Coverage   30.12%   30.32%   +0.19%     
==========================================
  Files         632      632              
  Lines       43936    43936              
==========================================
+ Hits        13236    13322      +86     
+ Misses      29742    29638     -104     
- Partials      958      976      +18     
Flag Coverage Δ
unittests 30.32% <87.50%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xovoxy
Copy link
Contributor Author

xovoxy commented Aug 16, 2024

/retest

@karmada-bot
Copy link
Collaborator

@xovoxy: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@XiShanYongYe-Chang
Copy link
Member

Hi @xovoxy thanks for your contribution.
There are some e2e fixes that have been incorporated recently. Can you rebase the recent code in the master branch so that CI should pass?

@xovoxy
Copy link
Contributor Author

xovoxy commented Aug 16, 2024

Hi @xovoxy thanks for your contribution. There are some e2e fixes that have been incorporated recently. Can you rebase the recent code in the master branch so that CI should pass?

Thanks for your tips ~

@XiShanYongYe-Chang
Copy link
Member

/assign

@XiShanYongYe-Chang
Copy link
Member

Hi @xovoxy would you like to review the ut tests submitted by others? It's not mandatory, you can do it as you wish, and it's an important contribution to the community. Thank you very much! (I highly encourage you to review each other. My perspective may be subjective, but you can discuss it fully and provide more valuable review comments.)

@xovoxy
Copy link
Contributor Author

xovoxy commented Aug 18, 2024

Hi @xovoxy would you like to review the ut tests submitted by others? It's not mandatory, you can do it as you wish, and it's an important contribution to the community. Thank you very much! (I highly encourage you to review each other. My perspective may be subjective, but you can discuss it fully and provide more valuable review comments.)

Of course, this is also a good experience for me. Thank you for your invitation~

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Ask @zhzhuang-zju help take a review.
/cc @zhzhuang-zju

Comment on lines 78 to 135
{
name: "secret not found",
cluster: &clusterv1alpha1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
},
wantErr: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

This case is not actually tested.

users:
- name: kind-member1
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJWWR6SWRFMFphbEF3RFF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Za2Y3TzNqempCSmh6a2U1UzRzbHMKWUpZU290cWd1VW5YakpCTVJNZzl0YUpSY1RiSU9oVmNHdDByd2t2NDB6V3JpdEplTTFEYmV0Q3FORm9xcms0bQo1WWszWHVwT01VejRtb0dnUzVDbmdIS0xXckVMRjI5VWFsM1BXRUdRbnZoVEc0N2dtUmk2dVVTUGNreGJnVm4wCithVU5Rei9Yc0tpOXgwUEtQU2xJTzMrMFVaMTdIa3Zlb1ZHOGdXRkR5bU94ckMzcEZHUkNNWTFJM3RVdUtvMTYKVUI5NW1XSFFUNjlBZllyanh3R3J4QzdkNTRKL1Y1NERnSUF6cVhFT2FFK1pKTHVYTFE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
Copy link
Contributor

Choose a reason for hiding this comment

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

The certificate will expire on August 15 next year, which may cause this use case to fail. Can you provide a certificate with a longer validity period, and add comments to indicate the expiration time?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this test case necessary, considering it is effectively covered by func Test_getKubeconfigFromSecret and func TestCertRotationController_shouldRotateCert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yes, thinks for you suggestion~ let me handle it

@xovoxy
Copy link
Contributor Author

xovoxy commented Aug 23, 2024

hi @XiShanYongYe-Chang @zhzhuang-zju, I’ve updated the issue mentioned above. Could you please review it again? Thanks~

@XiShanYongYe-Chang
Copy link
Member

/assign @zhzhuang-zju

@XiShanYongYe-Chang
Copy link
Member

Kindly ping @zhzhuang-zju, can you help take a review again?

@zhzhuang-zju
Copy link
Contributor

Kindly ping @zhzhuang-zju, can you help take a review again?

sure

@zhzhuang-zju
Copy link
Contributor

/lgtm cc @XiShanYongYe-Chang

@zhzhuang-zju
Copy link
Contributor

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 28, 2024
@XiShanYongYe-Chang
Copy link
Member

Thanks
/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: XiShanYongYe-Chang

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 28, 2024
@karmada-bot karmada-bot merged commit 295dee8 into karmada-io:master Aug 28, 2024
12 checks passed
@RainbowMango RainbowMango added this to the v1.11 milestone Aug 31, 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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. lgtm Indicates that a PR is ready to be merged. 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.

6 participants