Skip to content

test(http2): expand http2_client.cpp coverage#1068

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

test(http2): expand http2_client.cpp coverage#1068
kcenon merged 1 commit into
developfrom
test/issue-1062-http2-client-coverage

Conversation

@kcenon

@kcenon kcenon commented Apr 27, 2026

Copy link
Copy Markdown
Owner

What

Add 30 focused unit tests to tests/test_http2_client.cpp that exercise reachable code paths in src/protocols/http2/http2_client.cpp without an established HTTP/2 connection.

Change Type

  • Test (no production behavior change)

Affected Components

  • tests/test_http2_client.cpp — +319 LOC, +30 test cases (no source/build changes)

Why

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

Pre-PR baseline (2026-04-26 lcov): http2_client.cpp 18.8% line / 9.9% branch. Existing tests (#991) cover happy paths only; this PR fills in error-path and boundary cases for the surface that does not require a live HTTP/2 server.

Where

Test category Tests added Targets
http2_response::get_header case folding + empty-name 4 response struct
http2_response::get_body_string binary/null/large 3 response struct
Constructor variations 3 client_id parameter
connect() boundary inputs 2 whitespace host, port=0
disconnect() lifecycle idempotency 2 triple-disconnect, after failed connect
set_settings boundary values 3 zero, uint32 max, push toggle
Request methods (disconnected state) 5 empty path, empty body
Stream methods (disconnected state) 5 empty path, null callbacks, stream_id=0
Multi-instance isolation 2 settings + many clients
http2_stream::window_size 1 int32 min/max

How

Implementation Approach

  • Append tests to existing tests/test_http2_client.cpp (no parallel suite)
  • Reuse the existing Http2ClientTest GTest fixture for stateful tests
  • Use bare TEST(...) for stateless struct-only and multi-instance tests
  • Add only <cstdint> and <limits> to the test-file includes
  • 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 #1062. The remaining gap is concentrated in the post-handshake code (frame I/O loop, stream-state transitions, HPACK encode/decode against a real peer). Those paths require an in-process HTTP/2 loopback fixture that does not currently exist in the test tree — the DISABLED_ConnectToHttpbin integration test connects to the public internet, which is unsuitable for CI coverage.

Building the loopback fixture is a larger, separate piece of work (TLS context with self-signed cert, ALPN h2 negotiation, server-side frame handling) and is tracked under #953. This PR therefore uses Part of #1062 rather than Closes #1062 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 #1062
Part of #953

Add 30 unit tests covering reachable paths in http2_client without
a connected HTTP/2 server:

- http2_response::get_header case folding and empty-name edges
- http2_response::get_body_string binary, null, large payloads
- Constructor variations (empty / long / special-char client_id)
- connect() boundary inputs (whitespace host, port zero)
- disconnect() lifecycle idempotency (triple, after failed connect)
- set_settings boundary values (zero, uint32 max, push toggle)
- Request and stream methods in disconnected state with empty paths,
  empty bodies, null callbacks, and stream_id 0
- Multi-instance settings isolation
- http2_stream::window_size boundary values

Coverage of post-handshake code paths (frame I/O, stream state
machine, HPACK encode/decode against a peer) requires an in-process
HTTP/2 loopback fixture and is tracked separately under #953.

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

Copy link
Copy Markdown
Contributor

Coverage Report

Metric Value
Line Coverage 66.5%
Branch Coverage 32.8%
Target 80% lines / 70% branches
Coverage Details

Full HTML report is available as a build artifact.

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