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 to enable hang and crash dumps #11666

Merged
merged 7 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
50 changes: 47 additions & 3 deletions src/Cli/dotnet/commands/dotnet-test/LocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,17 @@ RunSettings arguments:
More info here: https://aka.ms/vstest-collect</value>
</data>
<data name="CmdBlameDescription" xml:space="preserve">
<value>Run the tests in blame mode. This option is helpful in isolating a problematic test causing the test host to crash.
Outputs a 'Sequence.xml' file in the current directory that captures the order of execution of test before the crash.</value>
<value>Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash or hang.
When a crash is detected, it creates an sequence file in TestResults/guid/guid_Sequence.xml that captures the order of tests that were run before the crash.
Based on the additional settings, hang dump or crash dump can also be collected.
Example:
Timeout the test run when test takes more than the default timeout of 1 hour, and collect crash dump when the test host exits unexpectedly.
(Crash dumps require additional setup, see below.)
dotnet test --blame-hang --blame-crash
Example:
Timeout the test run when a test takes more than 20 minutes and collect hang dump.
dotnet test --blame-hang-timeout 20min
</value>
</data>
<data name="FrameworkOptionDescription" xml:space="preserve">
<value>The target framework to run tests for. The target framework must also be specified in the project file.</value>
Expand All @@ -217,4 +226,39 @@ Outputs a 'Sequence.xml' file in the current directory that captures the order o
<data name="IgnoredArgumentsMessage" xml:space="preserve">
<value>The following arguments have been ignored : "{0}"</value>
</data>
</root>
<data name="CmdBlameCrashCollectAlwaysDescription" xml:space="preserve">
<value>Enables collecting crash dump on expected as well as unexpected testhost exit.</value>
</data>
<data name="CmdBlameCrashDescription" xml:space="preserve">
<value>Runs the tests in blame mode and enables collecting crash dump when testhost exits unexpectedly.
This option is currently only supported on Windows, and requires procdump.exe and procdump64.exe to be available in PATH.
Or PROCDUMP_PATH environment variable to be set, and point to a directory that contains procdump.exe and procdump64.exe.
The tools can be downloaded here: https://docs.microsoft.com/en-us/sysinternals/downloads/procdump
Implies --blame.</value>
</data>
<data name="CmdBlameCrashDumpTypeDescription" xml:space="preserve">
<value>The type of crash dump to be collected. Implies --blame-crash.</value>
</data>
<data name="CmdBlameHangDescription" xml:space="preserve">
<value>Run the tests in blame mode and enables collecting hang dump when test exceeds the given timeout. Implies --blame-hang.</value>

Choose a reason for hiding this comment

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

This causes dotnet test --help to print:

--blame-hang Run the tests in blame mode and enables collecting hang dump when test exceeds the given timeout. Implies --blame-hang.

This is self-referential and redundant. Should Implies --blame-hang. be part of the documentation for CmdBlameHangTimeoutDescription?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a typo, should have been: Implies --blame

--blame is the option that observes which tests are running but does not create any dumps.

</data>
<data name="CmdBlameHangDumpTypeDescription" xml:space="preserve">
<value>The type of crash dump to be collected. When None, is used then test host is terminated on timeout, but no dump is collected. Implies --blame-hang.</value>
</data>
<data name="CmdBlameHangTimeoutDescription" xml:space="preserve">
<value>Per-test timeout, after which hang dump is triggered and the testhost process is terminated.
The timeout value is specified in the following format: 1.5h / 90m / 5400s / 5400000ms. When no unit is used (e.g. 5400000), the value is assumed to be in milliseconds.
When used together with data driven tests, the timeout behavior depends on the test adapter used. For xUnit and NUnit the timeout is renewed after every test case,
For MSTest, the timeout is used for all testcases.
This option is currently supported only on Windows together with netcoreapp2.1 and newer. And on Linux with netcoreapp3.1 and newer. OSX and UWP are not supported.</value>
</data>
<data name="CrashDumpTypeArgumentName" xml:space="preserve">
<value>DUMP_TYPE</value>
</data>
<data name="HangDumpTypeArgumentName" xml:space="preserve">
<value>DUMP_TYPE</value>
</data>
<data name="HangTimeoutArgumentName" xml:space="preserve">
<value>TIMESPAN</value>
</data>
</root>
53 changes: 51 additions & 2 deletions src/Cli/dotnet/commands/dotnet-test/TestCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public static Command Test() =>
.With(name: LocalizableStrings.CmdLoggerOption)
.ForwardAsSingle(o =>
{
var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));
var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));

return $"-property:VSTestLogger=\"{loggersString}\"";
return $"-property:VSTestLogger=\"{loggersString}\"";
})),
CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription),
CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
Expand Down Expand Up @@ -91,6 +91,55 @@ public static Command Test() =>
LocalizableStrings.CmdBlameDescription,
Accept.NoArguments()
.ForwardAsSingle(o => "-property:VSTestBlame=true")),
Create.Option(
"--blame-crash",
LocalizableStrings.CmdBlameCrashDescription,
Accept.NoArguments()
.ForwardAsSingle(o => "-property:VSTestBlameCrash=true")),
Create.Option(
"--blame-crash-dump-type",
LocalizableStrings.CmdBlameCrashDumpTypeDescription,
Accept.AnyOneOf(
"full",
"mini")
.With(name: LocalizableStrings.CrashDumpTypeArgumentName, defaultValue: () => "full")
.ForwardAsMany(o => new[] {
"-property:VSTestBlameCrash=true",
$"-property:VSTestBlameCrashDumpType={o.Arguments.Single()}" })),
Create.Option(
"--blame-crash-collect-always",
LocalizableStrings.CmdBlameCrashCollectAlwaysDescription,
Accept.NoArguments()
.ForwardAsMany(o => new[] {
"-property:VSTestBlameCrash=true",
"-property:VSTestBlameCrashCollectAlways=true"
})),
Create.Option(
"--blame-hang",
LocalizableStrings.CmdBlameHangDescription,
Accept.NoArguments()
.ForwardAsSingle(o => "-property:VSTestBlameHang=true")),
Create.Option(
"--blame-hang-dump-type",
LocalizableStrings.CmdBlameHangDumpTypeDescription,
Accept.AnyOneOf(
"full",
"mini",
"none")
.With(name: LocalizableStrings.HangDumpTypeArgumentName, defaultValue: () => "full")
.ForwardAsMany(o => new[] {
"-property:VSTestBlameHang=true",
$"-property:VSTestBlameHangDumpType={o.Arguments.Single()}" })),
Create.Option(
"--blame-hang-timeout",
LocalizableStrings.CmdBlameHangTimeoutDescription,
Accept.ExactlyOneArgument()
.With(name: LocalizableStrings.HangTimeoutArgumentName)
.ForwardAsMany(o => new[] {
"-property:VSTestBlameHang=true",
$"-property:VSTestBlameHangTimeout={o.Arguments.Single()}"
})),

Create.Option(
"--nologo|/nologo",
LocalizableStrings.CmdNoLogo,
Expand Down
76 changes: 73 additions & 3 deletions src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,52 @@
<target state="translated">Testovací ovladač pro platformu .NET</target>
<note />
</trans-unit>
<trans-unit id="CmdBlameCrashCollectAlwaysDescription">
<source>Enables collecting crash dump on expected as well as unexpected testhost exit.</source>
<target state="new">Enables collecting crash dump on expected as well as unexpected testhost exit.</target>
<note />
</trans-unit>
<trans-unit id="CmdBlameCrashDescription">
<source>Runs the tests in blame mode and enables collecting crash dump when testhost exits unexpectedly.
This option is currently only supported on Windows, and requires procdump.exe and procdump64.exe to be available in PATH.
Or PROCDUMP_PATH environment variable to be set, and point to a directory that contains procdump.exe and procdump64.exe.
The tools can be downloaded here: https://docs.microsoft.com/en-us/sysinternals/downloads/procdump
Implies --blame.</source>
<target state="new">Runs the tests in blame mode and enables collecting crash dump when testhost exits unexpectedly.
This option is currently only supported on Windows, and requires procdump.exe and procdump64.exe to be available in PATH.
Or PROCDUMP_PATH environment variable to be set, and point to a directory that contains procdump.exe and procdump64.exe.
The tools can be downloaded here: https://docs.microsoft.com/en-us/sysinternals/downloads/procdump
Implies --blame.</target>
<note />
</trans-unit>
<trans-unit id="CmdBlameCrashDumpTypeDescription">
<source>The type of crash dump to be collected. Implies --blame-crash.</source>
<target state="new">The type of crash dump to be collected. Implies --blame-crash.</target>
<note />
</trans-unit>
<trans-unit id="CmdBlameHangDescription">
<source>Run the tests in blame mode and enables collecting hang dump when test exceeds the given timeout. Implies --blame-hang.</source>
<target state="new">Run the tests in blame mode and enables collecting hang dump when test exceeds the given timeout. Implies --blame-hang.</target>
<note />
</trans-unit>
<trans-unit id="CmdBlameHangDumpTypeDescription">
<source>The type of crash dump to be collected. When None, is used then test host is terminated on timeout, but no dump is collected. Implies --blame-hang.</source>
<target state="new">The type of crash dump to be collected. When None, is used then test host is terminated on timeout, but no dump is collected. Implies --blame-hang.</target>
<note />
</trans-unit>
<trans-unit id="CmdBlameHangTimeoutDescription">
<source>Per-test timeout, after which hang dump is triggered and the testhost process is terminated.
The timeout value is specified in the following format: 1.5h / 90m / 5400s / 5400000ms. When no unit is used (e.g. 5400000), the value is assumed to be in milliseconds.
When used together with data driven tests, the timeout behavior depends on the test adapter used. For xUnit and NUnit the timeout is renewed after every test case,
For MSTest, the timeout is used for all testcases.
This option is currently supported only on Windows together with netcoreapp2.1 and newer. And on Linux with netcoreapp3.1 and newer. OSX and UWP are not supported.</source>
<target state="new">Per-test timeout, after which hang dump is triggered and the testhost process is terminated.
The timeout value is specified in the following format: 1.5h / 90m / 5400s / 5400000ms. When no unit is used (e.g. 5400000), the value is assumed to be in milliseconds.
When used together with data driven tests, the timeout behavior depends on the test adapter used. For xUnit and NUnit the timeout is renewed after every test case,
For MSTest, the timeout is used for all testcases.
This option is currently supported only on Windows together with netcoreapp2.1 and newer. And on Linux with netcoreapp3.1 and newer. OSX and UWP are not supported.</target>
<note />
</trans-unit>
<trans-unit id="CmdNoLogo">
<source>Run test(s), without displaying Microsoft Testplatform banner</source>
<target state="translated">Spustit testy bez zobrazení nápisu Microsoft Testplatform</target>
Expand Down Expand Up @@ -119,6 +165,21 @@ Pokud zadaný adresář neexistuje, bude vytvořen.</target>
<target state="translated">RESULTS_DIR</target>
<note />
</trans-unit>
<trans-unit id="CrashDumpTypeArgumentName">
<source>DUMP_TYPE</source>
<target state="new">DUMP_TYPE</target>
<note />
</trans-unit>
<trans-unit id="HangDumpTypeArgumentName">
<source>DUMP_TYPE</source>
<target state="new">DUMP_TYPE</target>
<note />
</trans-unit>
<trans-unit id="HangTimeoutArgumentName">
<source>TIMESPAN</source>
<target state="new">TIMESPAN</target>
<note />
</trans-unit>
<trans-unit id="IgnoredArgumentsMessage">
<source>The following arguments have been ignored : "{0}"</source>
<target state="translated">Následující argumenty se ignorovaly: {0}</target>
Expand Down Expand Up @@ -154,9 +215,18 @@ Argumenty RunSettings:
<note />
</trans-unit>
<trans-unit id="CmdBlameDescription">
<source>Run the tests in blame mode. This option is helpful in isolating a problematic test causing the test host to crash.
Outputs a 'Sequence.xml' file in the current directory that captures the order of execution of test before the crash.</source>
<target state="translated">Spustí testy v režimu blame. Tato možnost je užitečná pro izolování problematického testu, který způsobuje chybové ukončení hostitele testů.
<source>Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash or hang.
When a crash is detected, it creates an sequence file in TestResults/guid/guid_Sequence.xml that captures the order of tests that were run before the crash.
Based on the additional settings, hang dump or crash dump can also be collected.
Example:
Timeout the test run when test takes more than the default timeout of 1 hour, and collect crash dump when the test host exits unexpectedly.
(Crash dumps require additional setup, see below.)
dotnet test --blame-hang --blame-crash
Example:
Timeout the test run when a test takes more than 20 minutes and collect hang dump.
dotnet test --blame-hang-timeout 20min
</source>
<target state="needs-review-translation">Spustí testy v režimu blame. Tato možnost je užitečná pro izolování problematického testu, který způsobuje chybové ukončení hostitele testů.
Výstupem je soubor Sequence.xml v aktuálním adresáři, do kterého se zaznamená pořadí provádění testů před chybovým ukončením.</target>
<note />
</trans-unit>
Expand Down
Loading