test(eventhubs): cover consumer receive options - #5091
Draft
Johnathan W (j7nw4r) wants to merge 2 commits into
Draft
test(eventhubs): cover consumer receive options#5091Johnathan W (j7nw4r) wants to merge 2 commits into
Johnathan W (j7nw4r) wants to merge 2 commits into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 3 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Issue Azure#4891 asks for live coverage of the consumer receive options and of the client identifiers. Add six live tests in one new file. Two tests read a ten event backlog with a prefetch of three and of one, which proves the receiver replenishes its link credit. One test leaves an idle receiver and asserts the receive timeout gives a TimedOut I/O error and then ends the stream. One test sends six events three seconds apart under a ten second receive timeout, which pins the documented rule that the timeout applies to each delivery and not to the whole read. One test opens a consumer with an instance identifier and reads its events back. One test opens a producer with an application identifier and sends. Each test reads the tail of its partition before it sends, and it tags every event with a run marker. The assertions look only at events that carry the marker, so traffic from another run never enters a result. These tests pin behavior the shipped source already has, so they pass against unchanged source. No source file changes.
The receive timeout error could not be downcast to `std::io::Error`. The receiver wraps the cause in `Box::new` at common/recoverable/receiver.rs:129, and `azure_core::Error::new` boxes its argument again, so the stored concrete type is `Box<std::io::Error>`. Try both shapes, so the test states the real contract, that the timeout reports an I/O `TimedOut` cause, and keeps passing once the redundant box goes away. A live run of the six tests now passes.
Johnathan W (j7nw4r)
force-pushed
the
j7nw4r/eventhubs-receive-options-live-tests
branch
from
August 25, 2026 18:13
bc53400 to
d91a5a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change adds
tests/eventhubs_receive_options.rswith six live tests for the consumer receive options. The tests cover a customprefetchvalue, the smallest usableprefetchvalue, thereceive_timeoutsemantics on an idle partition and on a slow partition, the consumerwith_instance_idoption, and the producerwith_application_idoption.Motivation
Prefetch sets the credit that the receiver grants to the AMQP link, so a wrong value can stall a stream or waste memory, and no test sets
OpenReceiverOptions::prefetchtoday. The receive timeout controls what happens when a partition is idle; five tests setreceive_timeoutand none assert it.ConsumerClientBuilder::with_instance_idhas no caller in the repository. Part of #4886.Changes
tests/eventhubs_receive_options.rswith six#[recorded::test(live)]tests.std::io::ErrorKind::TimedOut, that it arrives inside a timing window, and that the stream then ends.ConsumerClientBuilder::with_instance_idandProducerClientBuilder::with_application_id.Test plan
CARGO_BUILD_JOBS=1 RUSTFLAGS=-Dwarnings cargo test --no-run --package azure_messaging_eventhubsexits 0. CI setsRUSTFLAGS: "-Dwarnings", so this gate catches an unused import, an unused constant, or an uncalled helper.cargo test --package azure_messaging_eventhubs --test eventhubs_receive_options -- --test-threads=1reports0 passed; 0 failed; 6 ignored, because the tests are live-gated.cargo test --package azure_messaging_eventhubs -- --test-threads=1reports 196 passed and 0 failed across all targets.cargo fmt --package azure_messaging_eventhubs -- --check,cargo clippy --package azure_messaging_eventhubs --all-features --all-targetswith-Dwarnings, andcargo doc --package azure_messaging_eventhubs --all-features --no-depswith-Dwarningsall exit 0.npx cspell lint --config ./.vscode/cspell.json --no-must-find-files --no-gitignore --root . <the new file>reportsFiles checked: 1, Issues found: 0.Assumptions and divergences from the .NET tests
prefetchmaps toReceiverCreditMode::Auto(n), and a value of 0 gives the link no credit and stalls the reader, so no test pins that path. .NET mapsPrefetchCount = 0toAutoSendFlow = falseand issues credit per read instead, which this crate cannot express throughOpenReceiverOptions. A follow-up issue should decide whetherprefetch: Some(0)ought to selectReceiverCreditMode::Manual.ReadEventOptions.MaximumWaitTimeyields a repeatable empty event and never ends the enumeration, so a direct port ofConsumerRespectsTheWaitTimeWhenReadingcould not pass. A follow-up issue should decide whether the Rust stream ought to surface an idle interval in band instead.with_application_id, becauseProducerClientBuilderhas nowith_instance_id. Adding one is a public API change and is out of scope for a test change. A follow-up issue should decide whether the producer needs identifier parity with the consumer.tests/eventhubs_producer.rson purpose, so the third item in [Event Hubs] Add live tests for consumer receive options #4891 maps to a named test.prefetchand substitutes the default of 300, because the negotiated link credit is not observable through the public API. They do catch a broken credit replenishment and a rejected small credit.Closes #4891.
Live validation
Every test here ran against a live Event Hubs namespace on 2026-08-20: 6 passed, 0 failed.
Command:
AZURE_TEST_MODE=live cargo test --package azure_messaging_eventhubs --test eventhubs_receive_options -- --test-threads=1.One assertion was widened after that run. The receive timeout cause could not be downcast to
std::io::Error, because the receiver wraps it inBox::newatcommon/recoverable/receiver.rs:129andazure_core::Error::newboxes again, so the stored type isBox<std::io::Error>. The test accepts either shape, so it keeps passing once the extra box goes away. The extra box is tracked in #5098.