-
Notifications
You must be signed in to change notification settings - Fork 357
[fix] Fix data collection channels to use negotiated protocol version instead of V1 #16096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,7 @@ public void ProcessRequests() | |
| attachmentSets = new Collection<AttachmentSet>(); | ||
| } | ||
|
|
||
| _communicationManager.SendMessage(MessageType.DataCollectionTestEndResult, attachmentSets); | ||
| _communicationManager.SendMessage(MessageType.DataCollectionTestEndResult, attachmentSets, message.Version); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IPC Transport & Protocol Stability]
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IPC Transport & Protocol Stability] In the current negotiated flow this is harmless β the sender's For consistency with the ack and with the main-channel handler ( _communicationManager.SendMessage(MessageType.DataCollectionTestEndResult, attachmentSets, Math.Min(message.Version, ProtocolVersioning.HighestSupportedVersion));
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed.
|
||
|
|
||
| EqtTrace.Info("DataCollectionTestCaseEventHandler: Test case '{0} - {1}' completed", testCaseEndEventArgs?.TestCaseName, testCaseEndEventArgs?.TestCaseId); | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,7 @@ public void Close() | |
| /// <inheritdoc /> | ||
| public void SendTestCaseStart(TestCaseStartEventArgs e) | ||
| { | ||
| _communicationManager.SendMessage(MessageType.DataCollectionTestStart, e); | ||
| _communicationManager.SendMessage(MessageType.DataCollectionTestStart, e, ProtocolVersioning.HighestSupportedVersion); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IPC Transport & Protocol Stability] Unlike the main data collection channel ( The backward-compat table in the PR description covers the main channel only. For this sub-channel, if the This is mitigated today because both the STJ and Jsonite implementations already list
Consider threading the negotiated
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. The sub-channel now has proper
New tests verify: (1)
|
||
|
|
||
| var message = _communicationManager.ReceiveMessage(); | ||
| if (message != null && message.MessageType != MessageType.DataCollectionTestStartAck) | ||
|
|
@@ -95,7 +95,7 @@ public void SendTestCaseStart(TestCaseStartEventArgs e) | |
| public Collection<AttachmentSet>? SendTestCaseEnd(TestCaseEndEventArgs e) | ||
| { | ||
| var attachmentSets = new Collection<AttachmentSet>(); | ||
| _communicationManager.SendMessage(MessageType.DataCollectionTestEnd, e); | ||
| _communicationManager.SendMessage(MessageType.DataCollectionTestEnd, e, ProtocolVersioning.HighestSupportedVersion); | ||
|
|
||
| var message = _communicationManager.ReceiveMessage(); | ||
| if (message != null && message.MessageType == MessageType.DataCollectionTestEndResult) | ||
|
|
@@ -109,6 +109,6 @@ public void SendTestCaseStart(TestCaseStartEventArgs e) | |
| /// <inheritdoc /> | ||
| public void SendTestSessionEnd(SessionEndEventArgs e) | ||
| { | ||
| _communicationManager.SendMessage(MessageType.SessionEnd, e); | ||
| _communicationManager.SendMessage(MessageType.SessionEnd, e, ProtocolVersioning.HighestSupportedVersion); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,13 +127,13 @@ public void SendDataCollectionMessageShouldSendMessageToCommunicationManager() | |
|
|
||
| _requestHandler.SendDataCollectionMessage(message); | ||
|
|
||
| _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionMessage, message), Times.Once); | ||
| _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionMessage, message, It.IsAny<int>()), Times.Once); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void SendDataCollectionMessageShouldThrowExceptionIfThrownByCommunicationManager() | ||
| { | ||
| _mockCommunicationManager.Setup(x => x.SendMessage(MessageType.DataCollectionMessage, It.IsAny<DataCollectionMessageEventArgs>())).Throws<Exception>(); | ||
| _mockCommunicationManager.Setup(x => x.SendMessage(MessageType.DataCollectionMessage, It.IsAny<DataCollectionMessageEventArgs>(), It.IsAny<int>())).Throws<Exception>(); | ||
| var message = new DataCollectionMessageEventArgs(TestMessageLevel.Error, "message"); | ||
|
|
||
| Assert.ThrowsExactly<Exception>(() => _requestHandler.SendDataCollectionMessage(message)); | ||
|
|
@@ -189,14 +189,14 @@ public void ProcessRequestsShouldProcessRequests() | |
|
|
||
| // Verify SessionStarted events | ||
| _mockDataCollectionManager.Verify(x => x.SessionStarted(It.IsAny<SessionStartEventArgs>()), Times.Once); | ||
| _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.BeforeTestRunStartResult, It.IsAny<BeforeTestRunStartResult>()), Times.Once); | ||
| _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.BeforeTestRunStartResult, It.IsAny<BeforeTestRunStartResult>(), It.IsAny<int>()), Times.Once); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Backward Compatibility & Rollback Safety / Test Coverage] The critical invariant is
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. A new test
|
||
|
|
||
| // Verify TestHostLaunched events | ||
| _mockDataCollectionManager.Verify(x => x.TestHostLaunched(1234), Times.Once); | ||
|
|
||
| // Verify AfterTestRun events. | ||
| _mockDataCollectionManager.Verify(x => x.SessionEnded(It.IsAny<bool>()), Times.Once); | ||
| _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.AfterTestRunEndResult, It.IsAny<AfterTestRunEndResult>()), Times.Once); | ||
| _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.AfterTestRunEndResult, It.IsAny<AfterTestRunEndResult>(), It.IsAny<int>()), Times.Once); | ||
| } | ||
|
|
||
| [TestMethod] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IPC Transport & Protocol Stability]
_protocolVersionis adopted directly frommessage.Versionwith noMath.Minguard. The same pattern appears inDataCollectionTestCaseEventSender.SendTestCaseStart(line 101).In practice the handler always responds with
Math.Min(request.Version, HighestSupportedVersion), so the echoed value will never exceedHighestSupportedVersion. But if a rogue or out-of-sync handler ever reported a higher version, the sender would try to serialize subsequent messages at an unsupported version and hitNotSupportedExceptioninGetPayloadOptions.Defense-in-depth suggestion for both sites:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Both
DataCollectionRequestSender(line 147) andDataCollectionTestCaseEventSender(line 101) now use_protocolVersion = Math.Min(message.Version, ProtocolVersioning.HighestSupportedVersion)when adopting the echoed version, guarding against a rogue/out-of-sync handler reporting a version aboveHighestSupportedVersion.