Repository navigation
Add SSE parser coverage, StreamHandle lifecycle tests, and production streaming_client example - #149
Conversation
|
@codex review this pr |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90e2f85a00
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
### Motivation - Close remaining SSE streaming test gaps by adding subscribe and cancellation scenarios for HTTP+JSON and JSON-RPC using production default transports. - Add deterministic low-level libcurl streaming tests to validate metadata/chunk ordering, fragmentation, cancellation, timeout, and handler-failure propagation. - Harden StreamHandle lifecycle semantics so cancellation from observer callbacks cannot deadlock the worker thread. ### Description - Extend the C++ SUT functional script to run send, subscribe, and cancel flows for both HTTP+JSON and JSON-RPC against the TCK SUT using `HttpJsonTransport::CreateDefault(...)` and `JsonRpcTransport::CreateDefault(...)` (modified `scripts/run_cpp_sut_streaming_functional.sh`). - Fix a self-join defect in `StreamHandle::Cancel()` by skipping `join()` when `Cancel()` is invoked on the worker thread itself (change in `src/client/client.cpp`). - Add/extend interop and unit tests: JSON-RPC streaming-envelope negative cases and incomplete final SSE behavior (`tests/interop/http_streaming_gap_test.cpp`), low-level libcurl `StreamRequest` coverage including fragmentation, metadata-before-chunk, handler failures, timeout and connection failure (`tests/unit/http_client_test.cpp`), and StreamHandle lifecycle edge cases including cancellation-from-OnEvent and no-callbacks-after-cancel (`tests/unit/stream_handle_lifecycle_test.cpp`). - Improve the interop client to support seeding a non-terminal task, subscribing, driving a terminal update, and verifying cancellation behavior in a deterministic way (`tests/interop/http_sse_interop_client.cpp`). ### Testing - Ran formatter and full build: `clang-format --dry-run --Werror ...` and `cmake` / `cmake --build`; build succeeded. - Ran targeted unit and integration checks: `./build/tests/http_client_test --gtest_filter='*Stream*'`, `./build/tests/stream_handle_lifecycle_test`, and the new `http_streaming_gap_test`; all added/modified tests passed locally. - Exercised HTTP SSE interop scenarios and C++ SUT matrix end-to-end: `./scripts/run_http_sse_interop.sh` and `./scripts/run_cpp_sut_streaming_functional.sh`, which started `tck_sut` and validated send, subscribe, and cancellation for both transports. - Executed repository validation: `./scripts/verify_changes.sh` (format, build, tests, targeted `clang-tidy` fixes applied to touched test files); the verification run completed with tests passing after fixing readability issues in the touched tests.
…-RPC fixture validation (#152) ### Motivation - Align `streaming_client` example docs and commands with the repository example runner and actual binary layout so users can build and run the example exactly as written. - Ensure `SendMessage` requests created by the example always include a unique non-empty `message_id` and only include a `task_id` when explicitly provided by the user. - Centralize CLI flag names to avoid magic strings and reduce maintenance surface. - Harden the JSON-RPC SSE fixture used by interop tests to reject unexpected methods and malformed parameters and add deterministic negative checks. ### Description - Update `examples/apps/streaming_client/README.md` to use the example runner build command and the generated binary path as `./scripts/run_examples.sh build-example streaming_client` and `./build-example-streaming_client/a2a_example --help`, and update all usage examples to call the actual binary path. - Replace literal CLI flag strings with namespace-scope `constexpr` constants (for `--help`, `--transport`, `--endpoint`, `--operation`, `--task-id`, `--timeout-ms`, `--cancel-after-first-event`) and reuse them in `PrintUsage()` and `ParseOptions()` in `examples/apps/streaming_client/main.cpp`. - Remove the example's default `task_id` for sends and add deterministic, in-process `message_id` generation using a prefix + timestamp + atomic sequence in `MakeMessageId()`, and set `task_id` in the `SendMessageRequest` only when the user supplied `--task-id`. - Update `scripts/interop/python_http_sse_fixture.py` to accept only `a2a.sendStreamingMessage` and `a2a.subscribeToTask`, validate `params.message.messageId` (non-empty string) for send and `params.id` (non-empty string) for subscribe, and return HTTP 400 on unexpected method or invalid parameters. - Add deterministic negative interop checks to `scripts/run_http_sse_interop.sh` that POST malformed/incorrect JSON-RPC payloads and assert HTTP 400 responses. - Mark `scripts/run_http_sse_interop.sh` and `scripts/run_cpp_sut_streaming_functional.sh` executable so they can be invoked directly.
|
@codex review this PR again |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
5ce4d9c
into
dev-add-sse-streaming-support-to-clients
… streaming_client example (#149) ### Motivation - Close remaining coverage and example gaps for streaming (SSE parsing, StreamHandle lifecycle, and production default-client usage) so the HTTP+JSON and JSON-RPC streaming implementations have deterministic tests and a runnable example. - Provide a production-quality example that demonstrates `HttpJsonTransport::CreateDefault(...)` and `JsonRpcTransport::CreateDefault(...)` usage with bounded waits and explicit cancellation semantics. ### Description - Added extensive SSE parser unit tests in `tests/unit/sse_parser_test.cpp` covering complete events, every-byte splits, multi-event chunks, CRLF framing, `data:` spacing variants, multiline `data:`, comments/heartbeats, ignored `id:`/`retry:`, empty chunks, finalization, malformed fields, missing separators, callback failure propagation, and empty-stream finalization. - Added transport-neutral `StreamHandle` lifecycle regression tests in `tests/unit/stream_handle_lifecycle_test.cpp` covering `IsActive()`, idempotent `Cancel()`, double-cancel safety, destruction cancellation/join behavior, at-most-once completion, and mutual exclusion of error/completion. - Reworked the public example `examples/apps/streaming_client/main.cpp` to use production default HTTP+JSON and JSON-RPC transports, add a CLI (`--transport`, `--endpoint`, `--operation`, `--task-id`, `--timeout-ms`, `--cancel-after-first-event`), bounded observer waits, and deterministic cancellation behavior. - Updated example documentation `examples/apps/streaming_client/README.md` and `docs/streaming-usage.md` with build/run instructions and example commands, and updated the example runner `scripts/run_examples.sh` to smoke-test `streaming_client` via `--help` to avoid requiring a live server in smoke runs. - Registered the new test target in `tests/CMakeLists.txt`. --------- Co-authored-by: Vladimir Pavlov <[email protected]>
Motivation
HttpJsonTransport::CreateDefault(...)andJsonRpcTransport::CreateDefault(...)usage with bounded waits and explicit cancellation semantics.Description
tests/unit/sse_parser_test.cppcovering complete events, every-byte splits, multi-event chunks, CRLF framing,data:spacing variants, multilinedata:, comments/heartbeats, ignoredid:/retry:, empty chunks, finalization, malformed fields, missing separators, callback failure propagation, and empty-stream finalization.StreamHandlelifecycle regression tests intests/unit/stream_handle_lifecycle_test.cppcoveringIsActive(), idempotentCancel(), double-cancel safety, destruction cancellation/join behavior, at-most-once completion, and mutual exclusion of error/completion.examples/apps/streaming_client/main.cppto use production default HTTP+JSON and JSON-RPC transports, add a CLI (--transport,--endpoint,--operation,--task-id,--timeout-ms,--cancel-after-first-event), bounded observer waits, and deterministic cancellation behavior.examples/apps/streaming_client/README.mdanddocs/streaming-usage.mdwith build/run instructions and example commands, and updated the example runnerscripts/run_examples.shto smoke-teststreaming_clientvia--helpto avoid requiring a live server in smoke runs.tests/CMakeLists.txt.