Skip to content

Conversation

@serathius
Copy link
Member

Cleanup of the server test. First iteration on unifying the server_test.go to have a single constructor in tests. Constructing EtcdServer is very complicated and having it done per each test has high risk of test validating fake behavior instead of real one.

cc @fuweid @ahrtr @siyuanfoundation

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: serathius

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

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.15%. Comparing base (a8884c7) to head (c94a88d).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files

see 17 files with indirect coverage changes

@@           Coverage Diff           @@
##             main   #20984   +/-   ##
=======================================
  Coverage   69.14%   69.15%           
=======================================
  Files         422      422           
  Lines       34841    34841           
=======================================
+ Hits        24092    24095    +3     
- Misses       9342     9345    +3     
+ Partials     1407     1401    -6     

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 a8884c7...c94a88d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

uberApply: uberApplierMock{},
}
s := newServer(t, nil, testEtcdServerConfig{
lg: zaptest.NewLogger(t),
Copy link
Contributor

Choose a reason for hiding this comment

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

lg can be ignored and just use the default logger in newServer.


func newServer(t *testing.T, recorder *nodeRecorder, cfgs ...testEtcdServerConfig) *EtcdServer {
var cfg testEtcdServerConfig
if len(cfgs) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add an assertion that len(cfgs)<2 so that the intent is clear the plural is here just to handle 0 and 1 config?

srv := &EtcdServer{
lgMu: new(sync.RWMutex),
srv := newServer(t, n, testEtcdServerConfig{
lg: zaptest.NewLogger(t),
Copy link
Contributor

Choose a reason for hiding this comment

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

lg can be ignored and just use the default logger in newServer.

if lg == nil {
lg = zaptest.NewLogger(t)
}
be := cfg.be
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if cl.Backend is inconsistent with cfg.be?

Copy link
Member

Choose a reason for hiding this comment

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

good point.

I think we should remove cluster *membership.RaftCluster from testEtcdServerConfig, and dynamically create a cluster *membership.RaftCluster based on the cfg in newServer

consistIndex: cindex.NewConsistentIndex(be),
}
srv := newServer(t, nil, testEtcdServerConfig{
lg: zaptest.NewLogger(t),
Copy link
Contributor

Choose a reason for hiding this comment

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

lg can be ignored and just use the default logger in newServer.

cancel: cancel,
}
srv := newServer(t, nil, testEtcdServerConfig{
lg: zaptest.NewLogger(t),
Copy link
Contributor

Choose a reason for hiding this comment

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

lg can be ignored and just use the default logger in newServer.

@serathius serathius force-pushed the refactor-server-test branch from 8e683af to 46678e4 Compare December 2, 2025 09:50
…nstructing EtcdServer by themselves

Signed-off-by: Marek Siarkowicz <[email protected]>
@serathius serathius force-pushed the refactor-server-test branch from 46678e4 to c94a88d Compare December 2, 2025 10:43
@k8s-ci-robot
Copy link

@serathius: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-etcd-unit-test-arm64 c94a88d link true /test pull-etcd-unit-test-arm64
pull-etcd-verify c94a88d link true /test pull-etcd-verify
pull-etcd-unit-test-386 c94a88d link true /test pull-etcd-unit-test-386
pull-etcd-unit-test-amd64 c94a88d link true /test pull-etcd-unit-test-amd64
pull-etcd-coverage-report c94a88d link true /test pull-etcd-coverage-report

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants