etcd icon indicating copy to clipboard operation
etcd copied to clipboard

etcdctl: add fake client for UT

Open hwdef opened this issue 6 months ago • 8 comments

Part of: #20171

/cc @siyuanfoundation @Elbehery

hwdef avatar Jul 03 '25 07:07 hwdef

[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.

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 avatar Jul 03 '25 07:07 k8s-ci-robot

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.

k8s-ci-robot avatar Jul 03 '25 07:07 k8s-ci-robot

/ok-to-test

siyuanfoundation avatar Jul 10 '25 16:07 siyuanfoundation

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).

Files with missing lines Patch % Lines
etcdctl/ctlv3/command/fakeclient/client.go 32.25% 21 Missing :warning:
etcdctl/ctlv3/command/global.go 81.81% 5 Missing and 3 partials :warning:
etcdctl/ctlv3/command/test_utils.go 84.61% 1 Missing and 1 partial :warning:
etcdctl/ctlv3/ctl.go 0.00% 1 Missing :warning:
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 data Powered 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.

codecov[bot] avatar Jul 10 '25 16:07 codecov[bot]

@siyuanfoundation @Elbehery @serathius PTAL. This PR is ready for review :)

hwdef avatar Sep 09 '25 03:09 hwdef

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!

siyuanfoundation avatar Sep 16 '25 18:09 siyuanfoundation

/retest

hwdef avatar Oct 14 '25 10:10 hwdef

PTAL @ahrtr @Elbehery

hwdef avatar Oct 21 '25 03:10 hwdef