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

Distinguish between a test host crash or hang. #3984

Closed
wants to merge 5 commits into from
Closed

Conversation

engyebrahim
Copy link
Member

@engyebrahim engyebrahim commented Aug 31, 2022

Description

Distinguish between a test host crash or hang by make the blame message as error and remove the generic reason.

Related issue

Fixes #2593.
blame-enabled

else if (!BlameIsEnabled())
{
EqtTrace.Error("TestRequestSender: Aborting test run");
LogErrorMessage(string.Format(CultureInfo.CurrentCulture, "The active test run was aborted. Use blame for more details."));
Copy link
Member

Choose a reason for hiding this comment

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

You should always add new messages into the resx so that entries gets translated (here and in the else below).

@@ -609,7 +612,19 @@ private void OnDiscoveryMessageReceived(ITestDiscoveryEventsHandler2 discoveryEv
OnDiscoveryAbort(discoveryEventsHandler, ex, false);
}
}

private static bool BlameIsEnabled()
Copy link
Member

Choose a reason for hiding this comment

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

Personal preference but I like to prefix boolean method with Is, Can or "action" prefixes. So I would recommend IsBlameEnabled.


private static bool BlameIsEnabled()
{
string? s = RunSettingsManager.Instance.ActiveRunSettings.SettingsXml;
Copy link
Member

Choose a reason for hiding this comment

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

s isn't really meaningful, please rename into runSettingsXml or runSettingsString. Or you could also remove the variable and pass it directly to GetDataCollectionRunSettings call.

private static bool BlameIsEnabled()
{
string? s = RunSettingsManager.Instance.ActiveRunSettings.SettingsXml;
DataCollectionRunSettings dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(s)!;
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the method can return null, I would recommend to handle it rather than "expecting" result to not be null.

return true;
}
}
return false;
Copy link
Member

Choose a reason for hiding this comment

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

Nit

Suggested change
return false;
return false;

@@ -609,7 +612,19 @@ private void OnDiscoveryMessageReceived(ITestDiscoveryEventsHandler2 discoveryEv
OnDiscoveryAbort(discoveryEventsHandler, ex, false);
}
}

private static bool BlameIsEnabled()
Copy link
Member

Choose a reason for hiding this comment

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

Is the content of this method copy-pasted from somewhere else or is it something you came up with?

if (reason != "Test host process crashed")
{
EqtTrace.Error("TestRequestSender: Aborting test run because {0}", reason);
LogErrorMessage(string.Format(CultureInfo.CurrentCulture, CommonResources.AbortedTestRun, reason));
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should suggest to use blame in this case too.

else if (!BlameIsEnabled())
{
EqtTrace.Error("TestRequestSender: Aborting test run");
LogErrorMessage(string.Format(CultureInfo.CurrentCulture, "The active test run was aborted. Use blame for more details."));
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking about a message (for the 2nd part) that reads like This is likely caused by a crash or hang, use the blame argument to get more details..


foreach (var item in dataCollectionRunSettings.DataCollectorSettingsList)
{
if (item.FriendlyName?.ToLowerInvariant() == "blame" && item.IsEnabled)
Copy link
Member

Choose a reason for hiding this comment

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

Change the order of the && to make it fail early on isEnabled == false, and check the equality by .Equals with OrdinalCaseInsensitive (or do we have an extension method for that already)?

@@ -622,8 +642,24 @@ private void OnTestRunAbort(IInternalTestRunEventsHandler testRunEventsHandler,
SetOperationComplete();

var reason = GetAbortErrorMessage(exception, getClientError);
Copy link
Member

Choose a reason for hiding this comment

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

This could probably return a tuple, or out result with a boolean to indicate if we got default result or not. Rather than checking the literal text.

else
{
EqtTrace.Error("TestRequestSender: Aborting test run");
LogErrorMessage(string.Format(CultureInfo.CurrentCulture, "The active test run was aborted."));
Copy link
Member

Choose a reason for hiding this comment

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

Mention that blame was enabled and that they should look at the blame messages below?

@nohwnd
Copy link
Member

nohwnd commented Sep 1, 2022

One general comment, maybe we could replace the Data collector "<name>" message: with just <name>:?

@Evangelink Evangelink closed this May 16, 2023
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.

Hard to distinguish between a test host crash because of a hang or an actual crash
3 participants