Skip to content

tests: close gRPC-level test gaps for server/etcdserver/api/v3election #22136

Description

@Hakai-Shin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions