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 test cases to the LoadClientConfig function #101959

Merged
merged 1 commit into from
Jun 2, 2021

Conversation

lunhuijie
Copy link
Contributor

@lunhuijie lunhuijie commented May 13, 2021

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Increase the test case of this function, there are three situations

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 13, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @lunhuijie. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubelet sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 13, 2021
@k8s-ci-robot k8s-ci-robot requested review from dims and sttts May 13, 2021 03:45
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 13, 2021
@yangjunmyfm192085
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 May 13, 2021
@lunhuijie
Copy link
Contributor Author

/retest

@heqg
Copy link
Contributor

heqg commented May 13, 2021

/test pull-kubernetes-verify

@heqg
Copy link
Contributor

heqg commented May 13, 2021

/test pull-kubernetes-typecheck

@lunhuijie
Copy link
Contributor Author

/test pull-kubernetes-typecheck

@yangjunmyfm192085
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 15, 2021
@k8s-ci-robot k8s-ci-robot removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 19, 2021
@ehashman ehashman moved this from Triage to Needs Reviewer in SIG Node PR Triage May 19, 2021
@ehashman ehashman moved this from Needs Reviewer to Needs Approver in SIG Node PR Triage May 21, 2021
@lunhuijie
Copy link
Contributor Author

/assign @dims @sttts

@dims
Copy link
Member

dims commented May 27, 2021

@lunhuijie when does this hard coded cert expire? we just had a firedrill last weekend ( #102224 )

@lunhuijie
Copy link
Contributor Author

lunhuijie commented May 27, 2021

@lunhuijie when does this hard coded cert expire? we just had a firedrill last weekend ( #102224 )
In this pr all validcerts:
Validity
Not Before: Apr 26 23:26:52 2017 GMT
Not After : Apr 2 23:26:52 2117 GMT

invalidcert:
Validity
Not Before: Dec 16 06:46:25 2014 GMT
Not After : Dec 16 06:46:25 2015 GMT

thanks for your reminder @dims

@lunhuijie
Copy link
Contributor Author

What do I need to do more to merge PR? @dims

@dims
Copy link
Member

dims commented May 31, 2021

@lunhuijie need /approve from sig-auth folks,see the OWNERS file (in the bot message above)

@lunhuijie
Copy link
Contributor Author

/assign @liggitt

"k8s.io/client-go/util/keyutil"
)

//create storeCertData of the store which used by bootstrap process. used for TestLoadClientConfig
var storeCertData = newCertificateData(`-----BEGIN CERTIFICATE-----
Copy link
Member

Choose a reason for hiding this comment

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

please put the fixture data in a standalone file in testdata, so it can be regenerated as needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK! thanks, and after re-understanding, I found that this test case only needs the catalog to be available, and does not need to have specific content, which has been changed. Other test data has been placed in the designated directory. Please review again.

@@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE-----
Copy link
Member

Choose a reason for hiding this comment

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

what are the expiration dates on these test certs? once they expire, will this unit test start failing?

please include readme indicating the private keys in this folder are for test only and and not considered secure and a generation script to reproduce the test certificates that are expected to remain valid (see #102224 as an example)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, and had done. Thanks for your reminder.
About the validity period of these certificates, I put them in the readme.md.

@k8s-ci-robot k8s-ci-robot added sig/auth Categorizes an issue or PR as relevant to SIG Auth. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jun 2, 2021
Comment on lines 63 to 68
//Create a temporary folder under tmp to store the required certificate files and configuration files.
fileDir, err := ioutil.TempDir("", "dir-")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(fileDir)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it! Learned it!

t.Fatalf("Unable to create the test directory %q: %v", dir, err)
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

no need to delete dir, the parent dir is already getting cleaned up on exit, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your guidance.

Signed-off-by: 刁浩 10284789 <diao.hao@zte.com.cn>
@liggitt
Copy link
Member

liggitt commented Jun 2, 2021

/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 Jun 2, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, lunhuijie

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 Jun 2, 2021
@k8s-ci-robot k8s-ci-robot merged commit 4eda493 into kubernetes:master Jun 2, 2021
SIG Node PR Triage automation moved this from Needs Approver to Done Jun 2, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone Jun 2, 2021
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. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note-none Denotes a PR that doesn't merit a release note. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

10 participants