-
Notifications
You must be signed in to change notification settings - Fork 323
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
Fix: Logger attachments not coming in vsts test run #1431
Fix: Logger attachments not coming in vsts test run #1431
Conversation
var message = this.dataSerializer.DeserializeMessage(rawMessage); | ||
var discoveryCompletePayload = this.LoggerManager.LoggersInitialized || this.requestData.IsTelemetryOptedIn ? | ||
this.dataSerializer.DeserializePayload<DiscoveryCompletePayload>(message) : default(DiscoveryCompletePayload); | ||
rawMessage = UpdateRawMessageWithTelemetryInfo(discoveryCompletePayload, message) ?? rawMessage; |
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.
UpdateRawMessageWithTelemetryInfo [](start = 29, length = 33)
what if telemetry is disabled, do we still want to add telemetry data to message? #Closed
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.
No we are not adding telemetry data when its disabled #Closed
{ | ||
var message = this.dataSerializer.DeserializeMessage(rawMessage); | ||
var discoveryCompletePayload = this.LoggerManager.LoggersInitialized || this.requestData.IsTelemetryOptedIn ? |
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.
this.LoggerManager.LoggersInitialized || this.requestData.IsTel [](start = 47, length = 63)
are these checks needed again? You have already checked above that either Loggers or telemetry is enabled #Closed
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.
removed #Closed
} | ||
if (string.Equals(message?.MessageType, MessageType.ExecutionComplete)) | ||
{ | ||
var testRunCompletePayload = this.LoggerManager.LoggersInitialized || this.requestData.IsTelemetryOptedIn ? |
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.
same comment as in DiscoveryRequest #Closed
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.
removed #Closed
if (!designMode) | ||
{ | ||
AddOrUpdateConsoleLogger(document, runsettingsXml); | ||
settingsUpdated = true; | ||
} | ||
else | ||
{ | ||
settingsUpdated = settingsUpdated || UpdateConsoleLoggerIfExists(document, runsettingsXml); |
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.
Why do we want to enable Console logger in DesignMode?
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.
If user has added in runsettings, we are allowing console logger. #Closed
this.LoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); | ||
this.LoggerManager.Dispose(); |
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.
Where are we disposing now ?
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.
In LoggerManager.HandleDiscoveryCompelte
/// <param name="runsettingsXml">Runsettings xml.</param> | ||
/// <returns>True if updated console logger in runsettings successfully.</returns> | ||
private bool UpdateConsoleLoggerIfExists(XmlDocument document, string runsettingsXml) | ||
{ | ||
var dummyConsoleLogger = new LoggerSettings |
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.
dummyConsoleLogger [](start = 16, length = 18)
nit: default*
@@ -31,7 +31,7 @@ public TestRunCompleteEventArgs(ITestRunStatistics stats, bool isCanceled, bool | |||
this.IsCanceled = isCanceled; | |||
this.IsAborted = isAborted; | |||
this.Error = error; | |||
this.AttachmentSets = attachmentSets; | |||
this.AttachmentSets = attachmentSets ?? new Collection<AttachmentSet>(); // Ensuring attachmentSets are not null, so that new attachmentSets can be combined whenever required. |
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.
Please put a comment why we are now initialization it
discoveryRequest.HandleDiscoveredTests(null); | ||
|
||
loggerManager.Verify(lm => lm.HandleDiscoveredTests(It.IsAny<DiscoveredTestsEventArgs>()), Times.Once); | ||
} | ||
} | ||
} |
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.
Need test to validate that HandleDiscoveryComplete of Logger Manager is invoked only once,if the message comes from both HandleRawMessage, & HandleDiscoveryComplete
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.
UT are there for this scenario.
testRunRequest.HandleLogMessage(TestMessageLevel.Error, "hello"); | ||
loggerManager.Verify(lm => lm.HandleTestRunMessage(It.IsAny<TestRunMessageEventArgs>()), Times.Once); | ||
|
||
} | ||
} |
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.
Same as in discovery tests
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.
UTs are present for this scenario.
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.
Description
In vsts, HandleRawMessage was sending complete event before HandleTestRunComplete can call loggers. Thus attachments created by loggers were not coming
Fix
Similar to data collector, we have moved loggers invokation to HandleRawMessage.