Skip to content

test(grpc): expand client.cpp coverage#1069

Merged
kcenon merged 1 commit into
developfrom
test/issue-1063-grpc-client-coverage
Apr 27, 2026
Merged

test(grpc): expand client.cpp coverage#1069
kcenon merged 1 commit into
developfrom
test/issue-1063-grpc-client-coverage

Conversation

@kcenon

@kcenon kcenon commented Apr 27, 2026

Copy link
Copy Markdown
Owner

What

Add 36 focused unit tests to tests/test_grpc_client_server.cpp that exercise reachable code paths in src/protocols/grpc/client.cpp without a connected gRPC peer.

Change Type

  • Test (no production behavior change)

Affected Components

  • tests/test_grpc_client_server.cpp — +373 LOC, +36 test cases (no source/build changes)

Why

Part of #1063 (and the parent epic Part of #953) — narrow test-expansion across worst-coverage protocol files.

Pre-PR baseline (2026-04-26 lcov): client.cpp 22.6% line / 9.5% branch. Existing tests in tests/test_grpc_client_server.cpp (added via #994) cover happy paths only; this PR fills in error-path and boundary cases for the surface that does not require a live gRPC server.

Where

Test category Tests added Targets
call_raw input variations (disconnected) 7 empty, slash-only, large request, expired deadline, future deadline, wait_for_ready, metadata
server_stream_raw / client_stream_raw / bidi_stream_raw guards 9 empty method, missing leading slash, metadata-bearing options
Constructor / target variations 4 empty, IPv4, long string, special characters
connect() boundary inputs 5 non-numeric port, multi-colon, insecure TLS, custom keepalive, zero retry attempts
Multi-instance state isolation 2 independent disconnect, move-assignment
call_options edges 3 zero timeout, very large timeout, metadata insertion order
grpc_message edges 6 parse short/empty buffers, embedded nulls, large payload, full byte range, header-only

How

Implementation Approach

  • Append tests to existing tests/test_grpc_client_server.cpp (no parallel suite)
  • Reuse the existing GrpcClientTest, GrpcCallOptionsTest, and GrpcMessageTest GTest fixtures
  • No new includes (everything already pulled in by the existing header set)
  • No changes to production source, build files, or CMake

Coverage Scope (Honest Assessment)

This PR does not reach the >=80% line / >=70% branch acceptance criteria of #1063. The remaining gap is concentrated in the post-connect code path: the HTTP/2-backed unary and streaming transport, start_stream callbacks, gRPC framing/parsing on real wire bytes, and trailer extraction. Those paths require an in-process gRPC loopback fixture that does not currently exist in the test tree.

Building the loopback fixture is a larger, separate piece of work (HTTP/2 server with grpc-status trailer support, hermetic ALPN negotiation, stream lifecycle handling) and is tracked under #953. This PR therefore uses Part of #1063 rather than Closes #1063 and the issue stays open.

Test Plan

Breaking Changes

None — test-only addition.

Rollback Plan

Revert this single commit; no schema, ABI, or build surface affected.

Part of #1063
Part of #953

Add 36 unit tests to tests/test_grpc_client_server.cpp targeting the
surface of grpc_client reachable without a connected gRPC peer.

Coverage scope (disconnected-state surface):
- call_raw input variations (empty, slash-only, large request, expired
  deadline, future deadline, wait_for_ready, custom metadata)
- server_stream_raw / client_stream_raw / bidi_stream_raw guards
  (empty method, missing leading slash, metadata-bearing options)
- Constructor / target variations (empty, IPv4, long string,
  special characters)
- connect() boundary inputs (non-numeric port, multi-colon target,
  insecure TLS, custom keepalive, zero retry attempts)
- Multi-instance state isolation and move-assignment safety
- call_options edges (zero timeout, very large timeout, ordered
  metadata of size 10)
- grpc_message edges (parse short/empty buffers, embedded nulls,
  large payload, full byte range, header-only serialization)

These tests do not exercise the post-connect frame I/O loop, which
requires an in-process gRPC loopback fixture not present in this tree.
The acceptance criteria of #1063 (>=80% line / >=70% branch) is
therefore not met by this PR; the remaining gap is tracked under #953.

Part of #1063
Part of #953
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Metric Value
Line Coverage 66.7%
Branch Coverage 33.0%
Target 80% lines / 70% branches
Coverage Details

Full HTML report is available as a build artifact.

@kcenon kcenon merged commit 9aab89b into develop Apr 27, 2026
9 checks passed
@kcenon kcenon deleted the test/issue-1063-grpc-client-coverage branch April 27, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant