Azure / Azure/azure-sdk-for-rust

[Event Hubs] Live test parity with the .NET SDK (tracking)

Open
#4,886 0 comments 1 reaction 1 assignee Claimed by @j7nw4r View on GitHub
Client Event Hubs test-enhancement
Dominant language
Rust
Stars
884
Forks
365
Avg merge
2d 19h
Merged PRs (30d)
109

Description

## Summary

The `azure_messaging_eventhubs` crate has 36 live tests (`#[recorded::test(live)]`) plus 14 recorded tests in `azure_messaging_eventhubs_checkpointstore_blob`. The .NET `Azure.Messaging.EventHubs` and `Azure.Messaging.EventHubs.Processor` libraries have about 230 live tests. The Rust SDK implements many behaviors that its live test suite does not exercise. This issue tracks the work to close that gap. Each child issue is one area and one unit of work.

The comparison is not one directional. The Rust suite has 5 management path stress tests in `sdk/eventhubs/azure_messaging_eventhubs/tests/eventhubs_property_stress.rs` that have no .NET live equivalent.

## Motivation

Live tests run against a real Event Hubs namespace. They catch broker behaviors that unit tests and mocks cannot catch, such as owner level arbitration, checkpoint resume, partition key routing, and service error mapping. The .NET live suite encodes this service behavior. The Rust SDK supports most of the same features but does not test them against the service. Untested paths can regress without a signal.

The gaps come from a behavior level comparison. The .NET side covers `sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientLiveTests.cs`, `Consumer/EventHubConsumerClientLiveTests.cs`, `Primitives/PartitionReceiverLiveTests.cs`, `Connection/EventHubConnectionLiveTests.cs`, `Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientLiveTests.cs`, and `Azure.Messaging.EventHubs.Shared/tests/BlobCheckpointStore/BlobsCheckpointStoreInternalLiveTests.cs` in azure-sdk-for-net. The Rust side covers `sdk/eventhubs/azure_messaging_eventhubs/tests/` and `sdk/eventhubs/azure_messaging_eventhubs_checkpointstore_blob/tests/` in this repository.

## Proposal

Complete the child issues below. Each one covers a group of behaviors that the Rust SDK implements today and does not live-test. Each child issue names the .NET tests that define the expected behavior.

- [ ] #4887 Consumer start positions
- [ ] #4888 Owner level (epoch) arbitration
- [ ] #4889 Consumer groups
- [ ] #4890 Producer routing and payload edge cases
- [ ] #4891 Consumer receive options
- [ ] #4892 SAS authentication and connection options
- [ ] #4893 Event processor
- [ ] #4894 Blob checkpoint store

## Defects found while writing the live tests

The live tests ran against a real namespace on 2026-08-20. Every child issue above now passes live, and the run found eight defects in shipped code. Each one is a child issue below, because a live test that asserts the documented behavior cannot pass until the defect is fixed.

- [ ] #5101 `send_event` does not enforce the AMQP link maximum that batches enforce
- [ ] #5094 A receiver attaches on the first stream poll, so `open_receiver_on_partition` cannot report a bad consumer group
- [ ] #5095 A lost ownership claim ends `EventProcessor::run()` under the balanced strategy
- [ ] #5096 `EventProcessor::shutdown()` does not stop event delivery or release ownership
- [x] #5097 `PartitionClient::update_checkpoint` silently succeeds when the event has no annotations
- [ ] #5098 The receive timeout cause is boxed twice, so it cannot be downcast to `std::io::Error`
- [ ] #5099 `BlobCheckpointStore` does not lowercase the blob key, so Rust and .NET processors do not interoperate
- [ ] #5100 Live test `second_processor_displaces_first_with_consumer_disconnected` fails on `main`
- [ ] #5102 `EventProcessor::run()` overwrites a shutdown requested before it started

The .NET live test areas below cover features that the Rust SDK does not implement. Do not write live tests for them. Track each one as its own feature issue if parity is wanted.

- Buffered producer (`EventHubBufferedProducerClientLiveTests`, 21 tests). No Rust equivalent exists.
- Idempotent publishing (`IdempotentPublishingLiveTests`, 17 tests). No Rust equivalent exists.
- WebSocket transport and proxy support (the transport parameterized tests and `ConnectionTransportCannotRetrieveMetadataWhenProxyIsInvalid`). Neither this crate nor `azure_core_amqp` has WebSocket code.
- `partition_key` on a single event send. `SendEventOptions` has only `partition_id`. Batches support both fields.
- Last enqueued event property tracking on the receiver stream. Only the management path (`get_partition_properties`) exposes this data.
- TLS certificate validation callback (the .NET custom certificate validation tests).

The .NET live tests below do not apply to Rust. Do not port them.

- Closed client behavior tests (`ProducerCannotSendWhenClosed` and its siblings). `close(self)` consumes the Rust clients, so the compiler prevents use after close.
- Shared `EventHubConnection` tests. The Rust crate has no public shared connection type.
- Snippet and sample live tests under `tests/Snippets/`. They validate .NET documentation samples.
- All partitions read on the consumer client (`ConsumerCanReadFromAllPartitions` family). The Rust consumer API deliberately follows the Go shape, which is one receiver per partition plus the event processor. The `receive_events_on_all_partitions` test already covers this ground.

A shared enabler for several child issues is per test provisioning of event hubs and consumer groups, similar to the .NET `EventHubScope` helper. This enabler is optional. Distinct consumer groups and distinct partitions on the shared namespace also work.

## Validation

Deploy the test resources with `eng/common/TestResources/New-TestResources.ps1 -ServiceDirectory eventhubs`. Set `EVENTHUBS_HOST`, `EVENTHUB_NAME`, and the storage variables. Then run `AZURE_TEST_MODE=live cargo test --package azure_messaging_eventhubs --test '*'` and `AZURE_TEST_MODE=live cargo test --package azure_messaging_eventhubs_checkpointstore_blob`. Each new test passes in live mode.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.