What happened / motivation
server/etcdserver/api/v3election implements the server-side handlers for
the Election gRPC service (Campaign, Proclaim, Leader, Resign, Observe).
The package itself has no _test.go files, which looked at first like a
coverage gap, but that's true of every package of this shape in the repo
(e.g. server/etcdserver/api/v3lock) — these thin server-side wrappers
around client/v3/concurrency are exercised through a real client/server
connection, and tests (where the integration/e2e harness lives) depends on
server, not the other way around, so a package-local test can't spin up an
embedded cluster without an illegal reverse module dependency. So
package-local unit tests aren't the right target here.
What is missing is a handful of specific request-behavior cases in the
existing integration coverage
(tests/integration/v3election_grpc_test.go), which today covers Campaign
contention/blocking, Resign unblocking a waiting campaigner, and Observe
across a leader handoff, but doesn't cover:
Proclaim rejecting a request from a non-leader (stale/mismatched
LeaderKey revision)
Proclaim rejecting a request after the caller has already Resigned
Resign fully releasing the election so a new Campaign (not one
already blocked/waiting) succeeds promptly afterward
Observe unblocking promptly on client-side context cancellation, rather
than potentially hanging the server-side stream handler
(tests/e2e/v3_curl_election_test.go already covers the missing-leader-key
error paths for Proclaim/Resign and the no-current-leader error path for
Leader, so those are not part of this issue.)
Proposal
Add integration test cases for the four gaps above to
tests/integration/v3election_grpc_test.go, following the existing pattern
in that file (embedded single-member cluster via
tests/framework/integration, talking to the real Election gRPC client).
No behavior change is proposed or expected — this is test-only.
What happened / motivation
server/etcdserver/api/v3electionimplements the server-side handlers forthe Election gRPC service (Campaign, Proclaim, Leader, Resign, Observe).
The package itself has no
_test.gofiles, which looked at first like acoverage gap, but that's true of every package of this shape in the repo
(e.g.
server/etcdserver/api/v3lock) — these thin server-side wrappersaround
client/v3/concurrencyare exercised through a real client/serverconnection, and
tests(where the integration/e2e harness lives) depends onserver, not the other way around, so a package-local test can't spin up anembedded cluster without an illegal reverse module dependency. So
package-local unit tests aren't the right target here.
What is missing is a handful of specific request-behavior cases in the
existing integration coverage
(
tests/integration/v3election_grpc_test.go), which today covers Campaigncontention/blocking, Resign unblocking a waiting campaigner, and Observe
across a leader handoff, but doesn't cover:
Proclaimrejecting a request from a non-leader (stale/mismatchedLeaderKeyrevision)Proclaimrejecting a request after the caller has alreadyResignedResignfully releasing the election so a newCampaign(not onealready blocked/waiting) succeeds promptly afterward
Observeunblocking promptly on client-side context cancellation, ratherthan potentially hanging the server-side stream handler
(
tests/e2e/v3_curl_election_test.goalready covers the missing-leader-keyerror paths for Proclaim/Resign and the no-current-leader error path for
Leader, so those are not part of this issue.)Proposal
Add integration test cases for the four gaps above to
tests/integration/v3election_grpc_test.go, following the existing patternin that file (embedded single-member cluster via
tests/framework/integration, talking to the realElectiongRPC client).No behavior change is proposed or expected — this is test-only.