-
Notifications
You must be signed in to change notification settings - Fork 39k
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
Conversation
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 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/test-infra repository. |
/ok-to-test |
/retest |
/test pull-kubernetes-verify |
/test pull-kubernetes-typecheck |
/test pull-kubernetes-typecheck |
/lgtm |
@lunhuijie when does this hard coded cert expire? we just had a firedrill last weekend ( #102224 ) |
invalidcert: thanks for your reminder @dims |
What do I need to do more to merge PR? @dims |
@lunhuijie need |
/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----- |
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.
please put the fixture data in a standalone file in testdata, so it can be regenerated as needed
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.
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----- |
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.
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)
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.
Got it, and had done. Thanks for your reminder.
About the validity period of these certificates, I put them in the readme.md.
//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) |
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.
use t.TempDir instead? (https://golang.org/pkg/testing/#T.TempDir)
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.
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 { |
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.
no need to delete dir, the parent dir is already getting cleaned up on exit, 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.
Thanks for your guidance.
Signed-off-by: 刁浩 10284789 <diao.hao@zte.com.cn>
/lgtm |
[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 |
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?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: