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

Add option for timeout and custom procdump #2976

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,20 @@ public virtual bool SetupChannel(IEnumerable<string> sources, string runSettings
/// </summary>
public virtual void Close()
{
bool? testHostExitedWithinTimeout = null;
try
{
// Do not send message if the host did not launch.
if (this.testHostLaunched)
{
testHostExitedWithinTimeout = false;
this.RequestSender.EndSession();

// We want to give test host a chance to safely close.
// The upper bound for wait should be 100ms.
var timeout = 100;
var timeout = int.TryParse(Environment.GetEnvironmentVariable("VSTEST_TESTHOST_TIMEOUT"), out var t) ? t : 100;
Copy link
Member

Choose a reason for hiding this comment

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

Variable was already created before but could we rename it into shutdownTimeoutInMs?

EqtTrace.Verbose("ProxyOperationManager.Close: waiting for test host to exit for {0} ms", timeout);
this.testHostExited.Wait(timeout);
testHostExitedWithinTimeout = this.testHostExited.Wait(timeout);
}
}
catch (Exception ex)
Expand All @@ -320,8 +322,10 @@ public virtual void Close()
finally
{
this.initialized = false;

EqtTrace.Warning("ProxyOperationManager: Timed out waiting for test host to exit. Will terminate process.");
if (testHostExitedWithinTimeout == false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (testHostExitedWithinTimeout == false)
if (!testHostExitedWithinTimeout)

but I like it if it's done on purpose so feel free to keep as-is

Copy link
Member

Choose a reason for hiding this comment

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

The variable is nullable so you cannot simply use not.

{
EqtTrace.Warning("ProxyOperationManager: Timed out waiting for test host to exit. Will terminate process.");
}

// Please clean up test host.
this.TestHostManager.CleanTestHostAsync(CancellationToken.None).Wait();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Microsoft.TestPlatform.Extensions.BlameDataCollector
{
using System;
using System.Collections.Generic;
using System.Text;

Expand All @@ -17,15 +18,25 @@ public string BuildTriggerBasedProcDumpArgs(int processId, string filename, IEnu
// -t: Write a dump when the process terminates.
// -ma: Full dump argument.
// -f: Filter the exceptions.
StringBuilder procDumpArgument = new StringBuilder($"-accepteula -e 1 -g {(collectAlways ? "-t " : string.Empty)}");
if (isFullDump)
var procdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_PROCDUMPARGS")?.Trim();
StringBuilder procDumpArgument;
if (!string.IsNullOrWhiteSpace(procdumpOverride))
{
procDumpArgument.Append("-ma ");
procDumpArgument = new StringBuilder(procdumpOverride).Append(" ");
}

foreach (var exceptionFilter in procDumpExceptionsList)
else
{
procDumpArgument.Append($"-f {exceptionFilter} ");
procDumpArgument = new StringBuilder($"-accepteula -e 1 -g {(collectAlways ? "-t " : string.Empty)}");

if (isFullDump)
{
procDumpArgument.Append("-ma ");
}

foreach (var exceptionFilter in procDumpExceptionsList)
{
procDumpArgument.Append($"-f {exceptionFilter} ");
}
}

procDumpArgument.Append($"{processId} {filename}.dmp");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ This test may, or may not be the source of the crash.</value>
<data name="Seconds" xml:space="preserve">
<value>seconds</value>
</data>
<data name="Terminatin" xml:space="preserve">
Copy link
Member Author

Choose a reason for hiding this comment

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

Terminating

Copy link
Member

Choose a reason for hiding this comment

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

Seems unused so far. Also, the resource key is using ing but the description is using ed we may want to synchronize that.

<value>Terminated process {0} - {1}, because of timeout. </value>
<comment>{0} process id, {1} process name</comment>
</data>
<data name="UnexpectedValueForInactivityTimespanValue" xml:space="preserve">
<value>Unexpected value '{0}' provided as timeout. Please provide a value in this format: 1.5h / 90m / 5400s / 5400000ms / 5400000</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Tento test může a nemusí být příčinou chybového ukončení.</target>
<target state="translated">sekundy</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Dieser Test kann, muss aber nicht unbedingt die Absturzursache sein.</target>
<target state="translated">Sekunden</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Esta prueba puede ser el origen del bloqueo o no serlo.</target>
<target state="translated">segundos</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Ce test est éventuellement à l'origine du plantage.</target>
<target state="translated">secondes</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Il test potrebbe essere l'origine dell'arresto anomalo.</target>
<target state="translated">secondi</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ This test may, or may not be the source of the crash.</source>
<target state="translated">秒</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ This test may, or may not be the source of the crash.</source>
<target state="translated">초</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Ten test może, ale nie musi być źródłem awarii.</target>
<target state="translated">s</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Esse teste pode ser a origem da falha ou não.</target>
<target state="translated">segundos</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ This test may, or may not be the source of the crash.</source>
<target state="translated">с</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Bu test, kilitlenmenin kaynağı olmayabilir veya olmayabilir.</target>
<target state="translated">saniye</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ This test may, or may not be the source of the crash.</source>
<target state="new">seconds</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ This test may, or may not be the source of the crash.</source>
<target state="translated">秒</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ This test may, or may not be the source of the crash.</source>
<target state="translated">秒</target>
<note></note>
</trans-unit>
<trans-unit id="Terminatin">
<source>Terminated process {0} - {1}, because of timeout. </source>
<target state="new">Terminated process {0} - {1}, because of timeout. </target>
<note>{0} process id, {1} process name</note>
</trans-unit>
</body>
</file>
</xliff>