Skip to content

[C++] Expand test coverage: unit, concurrency, and integration tests#499

Open
zlata-stefanovic-db wants to merge 3 commits into
mainfrom
cpp-comprehensive-tests
Open

[C++] Expand test coverage: unit, concurrency, and integration tests#499
zlata-stefanovic-db wants to merge 3 commits into
mainfrom
cpp-comprehensive-tests

Conversation

@zlata-stefanovic-db

@zlata-stefanovic-db zlata-stefanovic-db commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Expands the C++ SDK test suite to cover the API surface the current tests left uncovered, matching the parity set the other SDKs test (cf. Java's unit tests) and the suite intended in the closed #421. Also adds concurrency and live-integration coverage, plus a ThreadSanitizer CI job. All hermetic tests are plain, dependency-free, network-free executables registered with CTest, in the same style as the existing tests.

Unit tests (API surface)

  • error_testZerobusException: message, is_retryable(), catchable as std::exception
  • record_testUnackedRecord: byte/flag preservation, embedded NUL, empty payload
  • version_testversion() pinned to ZEROBUS_CPP_VERSION
  • proto_schema_testProtoSchema: UC-JSON round trip, invalid JSON, missing required column, move semantics (moved-from null-handle contract)
  • headers_callback_test — headers-provider FFI trampoline: marshalling, empty / embedded-NUL / throwing / null-user_data guards; results freed via zerobus_free_headers
  • sdk_testSdk / SdkBuilder: offline build (no network I/O), move, and create_stream / create_arrow_stream argument validation

Concurrency

  • concurrency_test — exercises the documented "concurrent readers on a shared ProtoSchema" contract (descriptor_bytes / encode_json are const) across many threads. Hermetic, so it runs in CI. Aimed at ThreadSanitizer to catch data races the AddressSanitizer job cannot. No concurrent-Stream case (a Stream is not safe for concurrent use, so that would test misuse).
  • Adds a ThreadSanitizer CI job (make test SANITIZE=thread) to ci-cpp.yml.

Live integration

  • integration_test — env-var-gated create_stream -> ingest -> flush -> close path against a real endpoint, mirroring the Java/TypeScript integration suites. Uses the loop-then-flush() pattern (never waits per record). Skips (exits 0) when credentials are unset, so make test and CI stay hermetic. Requires ZEROBUS_SERVER_ENDPOINT, DATABRICKS_WORKSPACE_URL, ZEROBUS_TABLE_NAME, DATABRICKS_CLIENT_ID, DATABRICKS_CLIENT_SECRET; optional ZEROBUS_TEST_RECORD_JSON.

Testing

  • make test — full suite passes (13 tests; integration_test skips without credentials)
  • make test SANITIZE=address — passes under AddressSanitizer (validates the FFI alloc/free pairing in the headers/proto-schema tests)
  • make test SANITIZE=thread — passes under ThreadSanitizer (validates the shared-ProtoSchema concurrency contract)
  • make fmt-check — clean

Merge order

Stacked on #484 (cpp-ack-callback). Base is cpp-ack-callback; retarget to main once #484 merges. Draft until then.

@zlata-stefanovic-db zlata-stefanovic-db self-assigned this Jul 13, 2026
@zlata-stefanovic-db zlata-stefanovic-db changed the title [C++] Add unit tests for the untested SDK surface [C++] Expand test coverage: unit, concurrency, and integration tests Jul 14, 2026
Base automatically changed from cpp-ack-callback to main July 14, 2026 10:15
Cover the API surface the current suite left untested, in the same
dependency-free, network-free style as the existing tests (each a plain
executable registered with CTest):

- error_test: ZerobusException message + is_retryable + std::exception catch
- record_test: UnackedRecord byte/flag preservation (incl. embedded NUL)
- version_test: version() pinned to ZEROBUS_CPP_VERSION
- proto_schema_test: UC-JSON round trip, error paths, move semantics
- headers_callback_test: headers trampoline marshalling, empty / embedded-NUL
  / throwing / null-user_data guards, freed via zerobus_free_headers
- sdk_test: offline build, move, create_stream / create_arrow_stream
  argument validation

Mirrors the parity set the other SDKs test (cf. Java's unit tests) and the
suite intended in #421. Full suite passes, including under AddressSanitizer.

Signed-off-by: Zlata Stefanovic <zlata.stefanovic@databricks.com>
Add concurrency_test.cpp and integration_test.cpp, refine existing test
suites, wire new tests into CMake, extend the C++ CI workflow, and update
NEXT_CHANGELOG.md.

Signed-off-by: Zlata Stefanovic <zlata.stefanovic@databricks.com>
Add a 'Running the tests' section to the C++ README (sanitizer runs and
the env-var-gated integration_test), note it in NEXT_CHANGELOG, and make
integration_test explain its flush()/close() sequence and warn when the
default record is used.

Signed-off-by: Zlata Stefanovic <zlata.stefanovic@databricks.com>
@zlata-stefanovic-db zlata-stefanovic-db marked this pull request as ready for review July 14, 2026 12:22
@zlata-stefanovic-db zlata-stefanovic-db requested a review from a team July 14, 2026 12:22
@zlata-stefanovic-db zlata-stefanovic-db added the testing Test coverage & CI label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Test coverage & CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant