test(eventhubs): cover consumer start positions - #5077
Draft
Johnathan W (j7nw4r) wants to merge 1 commit into
Draft
test(eventhubs): cover consumer start positions#5077Johnathan W (j7nw4r) wants to merge 1 commit into
Johnathan W (j7nw4r) wants to merge 1 commit into
Conversation
Add two unit tests for the Earliest and Latest start expressions, and five live tests for the consumer start positions on a real Event Hub. The two unit tests are plain unit tests. StartPosition::start_expression is a pure synchronous function, so the tests compute a string and compare it. They need no test proxy, no recording, and no async runtime. Each one carries a mutation proof: it was run against a broken copy of the source and it failed with the expected assertion. The Latest test also pins the no-position fallback, because the same literal is written twice in start_expression and a test on one copy lets the other copy drift. The five live tests are not yet proven live. This environment has no Event Hubs credential, so the tests are proven only by compilation and by the ignore behavior in playback mode. A live run must follow before the tests are trusted. The live tests share two partitions, so they take a file-level mutex. Each test reads the partition tail as its start boundary, and a test that seeds the same partition at the same time moves that boundary past the events of the other test. Every event carries a per-run marker, so each test asserts on its own events and ignores the foreign traffic on the partition. Add the tokio sync feature to the dev-dependency, because the live tests use tokio::sync::Mutex. That feature reached the test target only through a transitive dependency, which can break without warning.
Johnathan W (j7nw4r)
force-pushed
the
j7nw4r/eventhubs-start-position-live-tests
branch
from
August 25, 2026 18:14
7d8991c to
98cdb54
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
The Event Hubs consumer live tests covered two start positions. This change adds live tests for the offset, enqueued time, and
Latestpositions, and for theinclusiveflag. It also adds unit tests for the two filter arms that had no test.Motivation
The start position controls where a receiver begins in a partition, and the service resolves each position type differently, so a defect in one type does not appear in the tests for another type. Today
eventhubs_consumer.rsreads only fromEarliest, andeventhubs_round_trip.rsreads only from a sequence number. TheEarliestandLatestarms ofStartPosition::start_expressionhave no unit test, and theLatestarm is reachable by a live test alone.Changes
tests/eventhubs_start_position.rswith five live tests: offset exclusive, offset inclusive, enqueued time,Latest, and sequence number inclusive.EarliestandLatestfilter strings and for the no-position fallback insrc/consumer/mod.rs.syncfeature to the tokio dev-dependency, which the new test file needs fortokio::sync::Mutex.Test plan
cargo test -p azure_messaging_eventhubs --lib consumer::tests::test_start_positiongives 6 passed.'-1'to'0'atsrc/consumer/mod.rs:594fails theEarliesttest alone. A change from'@latest'to'@Latest'at line 595 fails the first assertion of theLatesttest alone. A change to the no-position fallback at line 598 fails the third assertion of that test alone.#[test]functions and need no test-proxy recording, so they pass against the assets tag that this branch pins.cargo test -p azure_messaging_eventhubs --test eventhubs_start_positionreports 5 ignored whenAZURE_TEST_MODEis unset.cargo fmt -- --check,cargo clippy --all-features --all-targetswith-Dwarnings, andcargo doc --all-features --no-depswith-Dwarningsall pass.Sendrole on the namespace, and the same failure appears on an unchangedmain, so it is the environment and not this change. To prove them, runAZURE_TEST_MODE=live cargo test -p azure_messaging_eventhubs --test eventhubs_start_position -- --test-threads=1against a namespace where the identity can send.Closes #4887.