etcdctl: add fake client for UT
Part of: #20171
/cc @siyuanfoundation @Elbehery
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: hwdef Once this PR has been reviewed and has the lgtm label, please assign ahrtr for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Hi @hwdef. Thanks for your PR.
I'm waiting for a etcd-io 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-sigs/prow repository.
/ok-to-test
Codecov Report
:x: Patch coverage is 64.04494% with 32 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 69.61%. Comparing base (584c7cc) to head (983a7ad).
Additional details and impacted files
| Files with missing lines | Coverage Δ | |
|---|---|---|
| etcdctl/ctlv3/ctl.go | 0.00% <0.00%> (ø) |
|
| etcdctl/ctlv3/command/test_utils.go | 84.61% <84.61%> (ø) |
|
| etcdctl/ctlv3/command/global.go | 52.17% <81.81%> (+52.17%) |
:arrow_up: |
| etcdctl/ctlv3/command/fakeclient/client.go | 32.25% <32.25%> (ø) |
... and 27 files with indirect coverage changes
@@ Coverage Diff @@
## main #20270 +/- ##
==========================================
+ Coverage 69.16% 69.61% +0.44%
==========================================
Files 422 424 +2
Lines 34841 34907 +66
==========================================
+ Hits 24098 24300 +202
+ Misses 9339 9162 -177
- Partials 1404 1445 +41
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 584c7cc...983a7ad. Read the comment docs.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@siyuanfoundation @Elbehery @serathius PTAL. This PR is ready for review :)
Overall this approach works.
But if the tests run in parallel, there will be race condition on the var newClientFunc. To ensure only 1 test runs at a time, we will need to add a new test suite in test.sh with go test -p 1.
Another option would be refactor all the functions like NewAlarmCommand to take a client argument. Personally I would prefer this.
@ahrtr would really appreciate your input. Thanks!
/retest
PTAL @ahrtr @Elbehery