Skip to content
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

Merged
merged 7 commits into from
Feb 14, 2018

Conversation

abhishkk
Copy link
Contributor

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.

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;
Copy link
Contributor

@mayankbansal018 mayankbansal018 Feb 13, 2018

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

Copy link
Contributor Author

@abhishkk abhishkk Feb 13, 2018

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 ?
Copy link
Contributor

@mayankbansal018 mayankbansal018 Feb 13, 2018

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

Copy link
Contributor Author

@abhishkk abhishkk Feb 14, 2018

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 ?
Copy link
Contributor

@mayankbansal018 mayankbansal018 Feb 13, 2018

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

Copy link
Contributor Author

@abhishkk abhishkk Feb 14, 2018

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);
Copy link
Contributor

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?

Copy link
Contributor Author

@abhishkk abhishkk Feb 13, 2018

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();
Copy link
Contributor

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 ?

Copy link
Contributor Author

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
Copy link
Contributor

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.
Copy link
Contributor

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);
}
}
}
Copy link
Contributor

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

Copy link
Contributor Author

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);

}
}
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

@singhsarab singhsarab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@abhishkk abhishkk merged commit 2cee46f into microsoft:master Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants