tests: close gRPC-level test gaps for server/etcdserver/api/v3election
- Dominant language
- Go
- Stars
- 52.3k
- Forks
- 10.5k
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 44
Description
## 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 `Resign`ed
- `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.
Contributor guide
Research direction
Start with tests/integration/v3election_grpc_test.go and its existing Campaign, Resign, and Observe cases. Use the embedded single-member cluster through tests/framework/integration and the real Election gRPC client. Add cases for the four listed Proclaim, Resign, and Observe behaviors; done means the integration tests pass and no server behavior changes are introduced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- distributed-systems, testing
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100