Mock AMQP server cannot serve a link reattach
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia da sdk/core/azure-core-amqp/test/ut/mock_amqp_server.hpp, in particolare da OnLinkAttached, MessageLoop e OnConnectionStateChanged, quindi esamina reattach_policy_test.cpp e gli entry point di Event Hubs indicati nell’issue. Esegui i test offline esistenti in una build locale ENABLE_UAMQP. Il lavoro è completato quando il mock può forzare il distacco dei link, accettare i reattachments, mantenere isolati gli endpoint e supportare i test di rebuild proposti e la configurazione CI.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The mock AMQP server in sdk/core/azure-core-amqp/test/ut/mock_amqp_server.hpp refuses a second attach on a link name that it holds. The server also leaves its message loop after the last link detaches, and it does not start the loop again. A test therefore cannot make the server detach a link and then accept a new attach from the client. The Event Hubs link rebuild code needs that sequence, so the rebuild code has no offline test today. The link rebuild work belongs to #7254.
Motivation
Four properties of the mock server block the sequence.
MockServiceEndpoint::OnLinkAttachedrefuses a duplicate link name, and the two roles fail in different ways. For an incoming receiver role, the method sends a detach with the conditionEntityAlreadyExistsand returns false (mock_amqp_server.hpp:99-108). For an incoming sender role, the method throws astd::runtime_errorfrom the callback (mock_amqp_server.hpp:138-144).MessageLoopleaves the loop when both link maps become empty (mock_amqp_server.hpp:343-347).OnLinkAttachedstarts the loop thread only whenm_serverThreadis not joinable (mock_amqp_server.hpp:155-161). Astd::threadstays joinable after its function returns, so the loop never starts again. The message dispatch, the link removal, and the call toEnableLinkPollingall run in that loop (mock_amqp_server.hpp:298-351). A new link therefore gets no service after the loop stops.- The server offers no method that detaches a link on demand. The one call to
Session::SendDetachis the duplicate name refusal (mock_amqp_server.hpp:106). AmqpServerMock::OnConnectionStateChangedcancelsm_listenerContextwhen a connection reachesEndorError(mock_amqp_server.hpp:699-704). Both constructors copy that context into every service endpoint (mock_amqp_server.hpp:552andmock_amqp_server.hpp:563). A copy ofAzure::Core::Contextshares the cancellation state (sdk/core/azure-core/inc/azure/core/context.hpp:225), so one closed connection stops the whole server.
The Event Hubs client rebuilds a link after the service detaches it, and only a live namespace exercises that code today. PartitionClient::RebuildReceiver closes the faulted receiver, computes a new start position, and opens a new receiver with the same receiver name (sdk/eventhubs/azure-messaging-eventhubs/src/partition_client.cpp:230-262). PartitionClient::ReceiveEvents holds a per call rebuild counter, and a received message resets that counter (partition_client.cpp:298 and partition_client.cpp:309). The same method stores a pending error when the rebuild budget ends and the call already holds events (partition_client.cpp:326-336). The next call recovers from the pending error before it reads a message (partition_client.cpp:373-378). ProducerClient::EnsureSenderOrInvalidate discards the sender, the session, and the connection when an attach fails (sdk/eventhubs/azure-messaging-eventhubs/src/producer_client.cpp:318-352), and ProducerClient::InvalidateSender does that teardown (producer_client.cpp:362-389).
The offline tests cover only the decision functions. sdk/eventhubs/azure-messaging-eventhubs/test/ut/reattach_policy_test.cpp tests ShouldRebuildReceiver, ShouldInvalidateSender, and ResumeStartPosition. No offline test drives a rebuild sequence, because a rebuild needs a server that detaches a link and then accepts a new attach.
The build configuration makes the gap larger. sdk/core/azure-core-amqp/CMakeLists.txt:36 forces USE_RUST_AMQP on, and only DISABLE_RUST_IN_BUILD turns it off (sdk/core/azure-core-amqp/CMakeLists.txt:38-41). No file under eng/ sets DISABLE_RUST_IN_BUILD, and no pipeline matrix uses the no-rust-amqp presets (CMakePresets.json:333). No pipeline therefore builds uAMQP. The mock server compiles only under ENABLE_UAMQP (mock_amqp_server.hpp:25), so a new mock server test runs in a local uAMQP build until a pipeline builds that transport.
Proposal
Give the mock server the behaviour that a reattach test needs.
- Add a method that detaches a named link on demand, with an AMQP error condition that the caller supplies. A test then makes the server send
amqp:link:detach-forcedto the client. - Remove the link from
m_senderorm_receiverwhen the server detaches it, so a new attach with the same name does not hit the duplicate name refusal inOnLinkAttached. - Keep the message loop alive while the server listens, or start a new loop thread when a link attaches after the loop stopped. The joinable condition at
mock_amqp_server.hpp:155needs a state flag instead, because a finishedstd::threadstays joinable. - Report the duplicate name failure the same way for both roles. A throw from the callback thread ends the test process, so the sender role must send a detach with
EntityAlreadyExistslike the receiver role does. - Add a method that detaches every link and keeps the connection open, so a test can drive the pending error path in
PartitionClient::ReceiveEvents. - Give each service endpoint a child context, so a closed connection stops that endpoint and not the whole server.
- Add a pipeline configuration that builds the uAMQP transport, so the new tests run in CI.
Behaviours that become testable
PartitionClient::RebuildReceiveropens a new receiver with the same receiver name after a forced detach.- The rebuilt receiver starts after the last offset that the client received, through
_detail::ResumeStartPosition. - The rebuild counter in
ReceiveEventsresets after a received message, so a long lived consumer keeps a full budget. ReceiveEventsreturns the events that it holds, and it stores the pending error when the rebuild budget ends.- The next call to
ReceiveEventsrecovers from the pending error before it reads a message. ReceiveEventsthrows when the rebuild budget ends and the call holds no event.ProducerClient::Sendrebuilds the sender after a forced detach and sends the batch.EnsureSenderOrInvalidatediscards the session and the connection after a failed attach.
- Lingua principale
- C++
- Stelle
- 206
- Fork
- 177
- Merge medio
- 2g 10h
- PR unite (30g)
- 34
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Azure/azure-sdk-for-cpp
-
bug EngSys
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
Azure/azure-sdk-for-cpp#7362 ·
I maintainer di solito rispondono entro 1 giorno
-
Client needs-team-attention Service Attention Storage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Azure/azure-sdk-for-cpp#7347 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Client Event Hubs needs-team-attention Service Attention
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
Azure/azure-sdk-for-cpp#7333 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Azure Storage STG105 Feature TestsForse già presa @Jinming-Hu l’ha presa 21 giorni fa. ApertaClient Storage
Azure/azure-sdk-for-cpp#7449 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Azure.Core bug test-enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
Azure/azure-sdk-for-cpp#7401 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Azure/azure-sdk-for-cpp
Issue simili
-
bug intrinsic medium priority rt_lib
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
sumatrapdfreader/sumatrapdf#6417 · 3 commenti ·
-
[BUG] Cython cache evicts most recent instead of oldest entry on cleanupForse già presa @scoder l’ha presa oggi. ApertaBuild System defect
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NVIDIA-Omniverse/PhysX#590 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno