This is an automated email from the ASF dual-hosted git repository. tabish pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-proton-dotnet.git
The following commit(s) were added to refs/heads/main by this push: new 3a5a665 PROTON-2800 Ensure first transfer frame always carries set message format 3a5a665 is described below commit 3a5a665fd493a9d242d833797b28996cd1993e98 Author: Timothy Bish <tabish...@gmail.com> AuthorDate: Wed Feb 28 16:24:36 2024 -0500 PROTON-2800 Ensure first transfer frame always carries set message format Ensure that first frame carries the set message format and then omit on trailing transfer frames if any. Update test suite to cover and improve test peer scripts to set formats on scripted declare and discharge. --- src/Proton.TestPeer/Driver/ScriptWriter.cs | 16 ++++-- .../Implementation/ProtonSessionOutgoingWindow.cs | 10 +--- .../Client/Implementation/ClientMessageSendTest.cs | 2 +- .../Engine/Implementation/ProtonSenderTest.cs | 62 +++++++++++++++++++++- 4 files changed, 75 insertions(+), 15 deletions(-) diff --git a/src/Proton.TestPeer/Driver/ScriptWriter.cs b/src/Proton.TestPeer/Driver/ScriptWriter.cs index 441041b..db5ec9e 100644 --- a/src/Proton.TestPeer/Driver/ScriptWriter.cs +++ b/src/Proton.TestPeer/Driver/ScriptWriter.cs @@ -142,7 +142,7 @@ namespace Apache.Qpid.Proton.Test.Driver expecting.WithHandle(Is.NotNullValue()); expecting.WithDeliveryId(Is.NotNullValue()); expecting.WithDeliveryTag(Is.NotNullValue()); - expecting.WithMessageFormat(Matches.OneOf(null, 0)); + expecting.WithMessageFormat(0); Driver.AddScriptedElement(expecting); return expecting; @@ -155,7 +155,7 @@ namespace Apache.Qpid.Proton.Test.Driver expecting.WithHandle(Is.NotNullValue()); expecting.WithDeliveryId(Is.NotNullValue()); expecting.WithDeliveryTag(Is.NotNullValue()); - expecting.WithMessageFormat(Matches.OneOf(null, 0)); + expecting.WithMessageFormat(0); Driver.AddScriptedElement(expecting); return expecting; @@ -273,12 +273,20 @@ namespace Apache.Qpid.Proton.Test.Driver public DeclareInjectAction RemoteDeclare() { - return new DeclareInjectAction(Driver); + DeclareInjectAction declare = new DeclareInjectAction(Driver); + + declare.WithMessageFormat(0); + + return declare; } public DischargeInjectAction RemoteDischarge() { - return new DischargeInjectAction(Driver); + DischargeInjectAction discharge = new DischargeInjectAction(Driver); + + discharge.WithMessageFormat(0); + + return discharge; } public EmptyFrameInjectAction RemoteEmptyFrame() diff --git a/src/Proton/Engine/Implementation/ProtonSessionOutgoingWindow.cs b/src/Proton/Engine/Implementation/ProtonSessionOutgoingWindow.cs index afcf50d..2ad654b 100644 --- a/src/Proton/Engine/Implementation/ProtonSessionOutgoingWindow.cs +++ b/src/Proton/Engine/Implementation/ProtonSessionOutgoingWindow.cs @@ -296,14 +296,6 @@ namespace Apache.Qpid.Proton.Engine.Implementation try { cachedTransfer.DeliveryId = delivery.DeliveryId; - if (delivery.MessageFormat != 0) - { - cachedTransfer.MessageFormat = delivery.MessageFormat; - } - else - { - cachedTransfer.ClearMessageFormat(); - } cachedTransfer.Handle = sender.Handle; cachedTransfer.Settled = delivery.IsSettled; cachedTransfer.DeliveryState = delivery.State; @@ -320,10 +312,12 @@ namespace Apache.Qpid.Proton.Engine.Implementation // Only the first transfer requires the delivery tag, afterwards we can omit it for efficiency. if (delivery.TransferCount == 0) { + cachedTransfer.MessageFormat = delivery.MessageFormat; cachedTransfer.DeliveryTag = delivery.DeliveryTag; } else { + cachedTransfer.ClearMessageFormat(); cachedTransfer.DeliveryTag = null; } cachedTransfer.More = !complete; diff --git a/test/Proton.Client.Tests/Client/Implementation/ClientMessageSendTest.cs b/test/Proton.Client.Tests/Client/Implementation/ClientMessageSendTest.cs index 972b238..5ed56e5 100644 --- a/test/Proton.Client.Tests/Client/Implementation/ClientMessageSendTest.cs +++ b/test/Proton.Client.Tests/Client/Implementation/ClientMessageSendTest.cs @@ -77,7 +77,7 @@ namespace Apache.Qpid.Proton.Client.Implementation payloadMatcher.MessageContentMatcher = bodyMatcher; peer.WaitForScriptToComplete(); - peer.ExpectTransfer().WithPayload(payloadMatcher).Accept(); + peer.ExpectTransfer().WithMessageFormat(0).WithPayload(payloadMatcher).Accept(); peer.ExpectDetach().Respond(); peer.ExpectClose().Respond(); diff --git a/test/Proton.Tests/Engine/Implementation/ProtonSenderTest.cs b/test/Proton.Tests/Engine/Implementation/ProtonSenderTest.cs index a513298..65cf9c6 100644 --- a/test/Proton.Tests/Engine/Implementation/ProtonSenderTest.cs +++ b/test/Proton.Tests/Engine/Implementation/ProtonSenderTest.cs @@ -1332,6 +1332,60 @@ namespace Apache.Qpid.Proton.Engine.Implementation Assert.IsNull(failure); } + [Test] + public void TestSendTransferWithDefaultMessageFormat() + { + IEngine engine = IEngineFactory.Proton.CreateNonSaslEngine(); + engine.ErrorHandler((result) => failure = result.FailureCause); + ProtonTestConnector peer = CreateTestPeer(engine); + + byte[] payloadBuffer = new byte[] { 0, 1, 2, 3, 4 }; + + peer.ExpectAMQPHeader().RespondWithAMQPHeader(); + peer.ExpectOpen().Respond().WithContainerId("driver"); + peer.ExpectBegin().Respond(); + peer.ExpectAttach().OfSender().Respond(); + peer.RemoteFlow().WithDeliveryCount(0) + .WithLinkCredit(10) + .WithIncomingWindow(1024) + .WithOutgoingWindow(10) + .WithNextIncomingId(0) + .WithNextOutgoingId(1).Queue(); + peer.ExpectTransfer().WithMessageFormat(0).WithPayload(payloadBuffer); + peer.ExpectDetach().WithHandle(0).Respond(); + + IConnection connection = engine.Start(); + + connection.Open(); + ISession session = connection.Session(); + session.Open(); + + IProtonBuffer payload = ProtonByteBufferAllocator.Instance.Wrap(payloadBuffer); + + ISender sender = session.Sender("sender-1"); + + Assert.IsFalse(sender.IsSendable); + + sender.CreditStateUpdateHandler(handler => + { + if (handler.IsSendable) + { + IOutgoingDelivery delivery = handler.Next(); + + delivery.DeliveryTagBytes = new byte[] { 0 }; + delivery.MessageFormat = 0; + delivery.WriteBytes(payload); + } + }); + + sender.Open(); + sender.Close(); + + peer.WaitForScriptToComplete(); + + Assert.IsNull(failure); + } + [Test] public void TestSenderSignalsDeliveryUpdatedOnSettledThenSettleFromLinkAPI() { @@ -1933,18 +1987,21 @@ namespace Apache.Qpid.Proton.Engine.Implementation .WithSettled(true) .WithState().Accepted() .WithDeliveryId(0) + .WithMessageFormat(0) .WithMore(true) .WithDeliveryTag(new byte[] { 1 }); peer.ExpectTransfer().WithHandle(0) .WithSettled(true) .WithState().Accepted() .WithDeliveryId(0) + .WithMessageFormat(Is.NullValue()) .WithMore(false) .WithDeliveryTag(Is.NullValue()); peer.ExpectTransfer().WithHandle(1) .WithSettled(true) .WithState().Accepted() .WithDeliveryId(1) + .WithMessageFormat(0) .WithMore(bothDeliveriesMultiFrame) .WithDeliveryTag(new byte[] { 2 }); if (bothDeliveriesMultiFrame) @@ -1953,6 +2010,7 @@ namespace Apache.Qpid.Proton.Engine.Implementation .WithSettled(true) .WithState().Accepted() .WithDeliveryId(1) + .WithMessageFormat(Is.NullValue()) .WithMore(false) .WithDeliveryTag(Is.NullValue()); } @@ -3636,7 +3694,7 @@ namespace Apache.Qpid.Proton.Engine.Implementation peer.ExpectTransfer().WithHandle(0) .WithState(Is.NullValue()) .WithDeliveryId(0) - .WithMessageFormat(42) + .WithMessageFormat(Is.NullValue()) .WithAborted(Matches.AnyOf(Is.NullValue(), Matches.Is(false))) .WithSettled(false) .WithMore(Matches.AnyOf(Is.NullValue(), Matches.Is(false))) @@ -3722,7 +3780,7 @@ namespace Apache.Qpid.Proton.Engine.Implementation peer.ExpectTransfer().WithHandle(0) .WithState().Accepted() .WithDeliveryId(0) - .WithMessageFormat(42) + .WithMessageFormat(Is.NullValue()) .WithAborted(Matches.AnyOf(Is.NullValue(), Matches.Is(false))) .WithSettled(settle) .WithMore(Matches.AnyOf(Is.NullValue(), Matches.Is(false))) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org