test(eventhubs): add live tests for consumer groups - #5088
Draft
Johnathan W (j7nw4r) wants to merge 2 commits into
Draft
test(eventhubs): add live tests for consumer groups#5088Johnathan 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. |
Add tests/eventhubs_consumer_groups.rs for issue Azure#4889. The file covers three cases: two consumer groups read the same events from one partition, a receiver on an unknown consumer group fails, and a receiver on an unknown partition fails. The tests are live-gated with #[recorded::test(live)], so a default run reports them as ignored. The red proof is deferred to the first live run. Each error test asserts on the first item of stream_events(), because open_receiver_on_partition does no network I/O. The broker attaches the link on the first poll, so the attach error cannot arrive from the open call. Every event carries a marker for the run in its application properties, so a reader drops the traffic of other runs on the shared namespace. A file-level lock serializes the three tests, because they share partition 0.
`recorded::start` already installs a global tracing subscriber with `try_init`. The shared `common::setup` helper uses `init`, which panics when a subscriber is already set, and the `Once` around it then stays poisoned, so every later test in the binary panics at `call_once`. The existing callers of `common::setup` are plain `#[test]` and `#[tokio::test]` functions, where `recorded::start` never runs, so the conflict only appears in a recorded test. Drop the call and the module import. A live run of the three tests now passes.
Johnathan W (j7nw4r)
force-pushed
the
j7nw4r/eventhubs-consumer-group-live-tests
branch
from
August 25, 2026 18:13
6e91252 to
4908add
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
Add live tests for consumer groups in
azure_messaging_eventhubs. The new file covers three cases: two consumer groups read the same events from one partition, a receiver on an unknown consumer group fails, and a receiver on an unknown partition fails.Closes #4889.
Motivation
Every live test used the
$Defaultconsumer group. Thetest-resources.biceptemplate already provisions a second group nameddefaultGroup, and no test used it. Thewith_consumer_groupbuilder option had no live coverage, so a change that dropped the consumer group from the receiver source URL would not fail any test. Part of #4886.Changes
sdk/eventhubs/azure_messaging_eventhubs/tests/eventhubs_consumer_groups.rswith three#[recorded::test(live)]tests.two_consumer_groups_read_the_same_eventssends five labeled events to one partition, then reads them from$Defaultand fromdefaultGroup, and asserts that both groups report the same labels in the same order and the same sequence numbers.receiver_on_unknown_consumer_group_failsasserts that the broker rejects the attach withamqp:not-found.receiver_on_unknown_partition_failsasserts that the broker rejects the attach withcom.microsoft:argument-out-of-rangeoramqp:not-found.Cargo.toml, and notest-resources.bicep.open_receiver_on_partitiondoes no network I/O and returnsOk, so the error cannot arrive there. The broker attaches the link on the first poll ofstream_events(), so both error tests assert on the first item of the stream. A test that asserted on the result ofopen_receiver_on_partitionwould pass without testing anything.ConsumerCanReadFromMultipleConsumerGroups, declares a custom consumer group and then builds both clients with the default group, so it reads$Defaulttwice. The test here uses two different groups instead.Test plan
Every check below ran on the pinned 1.95 toolchain from
rust-toolchain.toml.cargo fmt --checkexits 0.RUSTFLAGS=-Dwarnings cargo test --no-run --package azure_messaging_eventhubsexits 0 with no warnings. CI setsRUSTFLAGS=-Dwarnings, so an unused import or an unused helper would fail the build there.cargo clippy --package azure_messaging_eventhubs --all-targetsexits 0.RUSTDOCFLAGS=-Dwarnings cargo doc --package azure_messaging_eventhubs --all-features --no-depsexits 0.cargo test --package azure_messaging_eventhubs --test eventhubs_consumer_groups -- --test-threads=1exits 0 and reports all three tests as ignored, which is correct for a live-gated test in a default run.cargo test -p azure_messaging_eventhubs -- --test-threads=1exits 0 with 196 passed and 0 failed, so no existing test regressed.--test-threads=1is required, because the three tests share partition 0.The two expected condition sets come from the .NET mapping in
Azure.Messaging.EventHubs/src/Amqp/AmqpError.cs, and they are not verified against this broker. If the broker answers with another condition, the assertion names the observed condition and its description, so the first live run reports the true value in one line.Live validation
Every test here ran against a live Event Hubs namespace on 2026-08-20: 3 passed, 0 failed.
Command:
AZURE_TEST_MODE=live cargo test --package azure_messaging_eventhubs --test eventhubs_consumer_groups -- --test-threads=1.One defect was found and fixed by that run. The tests called the shared
common::setuphelper, which usestracing_subscriber::fmt().init().recorded::startalready installs a subscriber withtry_init, soinitpanicked and poisoned theOncearound it, and every later test in the binary died atcall_once. The call and the module import are gone.