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

Adjust Test Watcher Timeout for Test Collections #83746

Merged
merged 3 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 5 additions & 2 deletions src/native/watchdog/watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ int main(const int argc, const char *argv[])
return EXIT_FAILURE;
}

const long timeout_ms = strtol(argv[1], nullptr, 10);
int exit_code = run_timed_process(timeout_ms, argc-2, &argv[2]);
// Due to how Helix test environment variables are set, we have to receive
// the raw timeout value in minutes. Then we convert it to milliseconds when
// calling run_timed_process().
const long timeout_mins = strtol(argv[1], nullptr, 10);
int exit_code = run_timed_process(timeout_mins * 60000L, argc-2, &argv[2]);

printf("App Exit Code: %d\n", exit_code);
return exit_code;
Expand Down
15 changes: 11 additions & 4 deletions src/tests/Common/CLRTest.Execute.Bash.targets
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fi
</PropertyGroup>
<PropertyGroup>
<CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='true'">"$CORE_ROOT/corerun" $(CoreRunArgs) ${__DotEnvArg}</CLRTestRunFile>
<WatcherRunFile>"$CORE_ROOT/watchdog" $_WatcherTimeoutMilliseconds</WatcherRunFile>
<WatcherRunFile>"$CORE_ROOT/watchdog" $_WatcherTimeoutMins</WatcherRunFile>

<!-- Note that this overwrites CLRTestBashPreCommands rather than adding to it. -->
<CLRTestBashPreCommands Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(TargetArchitecture)' == 'wasm'"><![CDATA[
Expand Down Expand Up @@ -549,12 +549,19 @@ ReleaseLock()
cd "$%28dirname "${BASH_SOURCE[0]}")"
LockFile="lock"
_RunWithWatcher=0
_WatcherTimeoutMilliseconds=600000
_WatcherTimeoutMins=10

if [[ ! -z "$__TestTimeout" ]]%3B then
_WatcherTimeoutMilliseconds=$__TestTimeout
if [[ ! -z "$__TestCollectionTimeoutMins" ]]%3B then
_WatcherTimeoutMins=$__TestCollectionTimeoutMins
fi

# The watcher needs a bit of time to start up, capture dumps, clean up, and so on.
# Because of this, we pass a smaller timeout than the test collection one.
# For simplicity purposes, we will assume there are no work items with just
# a one-minute max timeout.
if (( $_WatcherTimeoutMins > 1 ))%3B then
_WatcherTimeoutMins="%24((_WatcherTimeoutMins-1))"
fi

# The __TestEnv variable may be used to specify a script to source before the test.
if [ -n "$__TestEnv" ]%3B then
Expand Down
16 changes: 12 additions & 4 deletions src/tests/Common/CLRTest.Execute.Batch.targets
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ if defined DoLink (
</PropertyGroup>
<PropertyGroup>
<CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='true'">"%CORE_ROOT%\corerun.exe" $(CoreRunArgs) %__DotEnvArg%</CLRTestRunFile>
<WatcherRunFile>"%CORE_ROOT%\watchdog.exe" %_WatcherTimeoutMilliseconds%</WatcherRunFile>
<WatcherRunFile>"%CORE_ROOT%\watchdog.exe" %_WatcherTimeoutMins%</WatcherRunFile>

<BatchCopyCoreShimLocalCmds Condition="'$(CLRTestScriptLocalCoreShim)' == 'true'"><![CDATA[
REM Local CoreShim requested - see MSBuild property 'CLRTestScriptLocalCoreShim'
Expand Down Expand Up @@ -439,10 +439,18 @@ set "lockFolder=%~dp0\lock"
pushd %~dp0
set "scriptPath=%~dp0"
set /A _RunWithWatcher=0
set _WatcherTimeoutMilliseconds=600000
set _WatcherTimeoutMins=10

IF NOT "%__TestTimeout%"=="" (
set _WatcherTimeoutMilliseconds=%__TestTimeout%
IF NOT "%__TestCollectionTimeoutMins%"=="" (
set _WatcherTimeoutMins=%__TestCollectionTimeoutMins%
)

REM The watcher needs a bit of time to start up, capture dumps, clean up, and so on.
REM Because of this, we pass a smaller timeout than the test collection one.
REM For simplicity purposes, we will assume there are no work items with just
REM a one-minute max timeout.
IF %_WatcherTimeoutMins% GTR 1 (
_WatcherTimeoutMins-=1
)

$(BatchCLRTestArgPrep)
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Common/helixpublishwitharcade.proj
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@
<HelixPreCommand Include="set CLRCustomTestLauncher=%HELIX_CORRELATION_PAYLOAD%\nativeaottest.cmd" Condition=" '$(NativeAotTest)' == 'true' " />
<HelixPreCommand Include="set __TestEnv=%HELIX_WORKITEM_PAYLOAD%\$(TestEnvFileName)" />
<HelixPreCommand Include="set __TestTimeout=$(TimeoutPerTestInMilliseconds)" Condition=" '$(TimeoutPerTestInMilliseconds)' != '' " />
<HelixPreCommand Include="set __TestCollectionTimeoutMins=$(TimeoutPerTestCollectionInMinutes)" Condition=" '$(TimeoutPerTestCollectionInMinutes)' != '' " />
<HelixPreCommand Include="set __CollectDumps=1" />
<HelixPreCommand Include="set __CrashDumpFolder=%HELIX_DUMP_FOLDER%" />
<HelixPreCommand Include="set __TestArchitecture=$(TargetArchitecture)" />
Expand Down Expand Up @@ -676,6 +677,7 @@
<HelixPreCommand Include="export CLRCustomTestLauncher=$HELIX_CORRELATION_PAYLOAD/nativeaottest.sh" Condition=" '$(NativeAotTest)' == 'true' " />
<HelixPreCommand Include="export __TestEnv=$HELIX_WORKITEM_PAYLOAD/$(TestEnvFileName)" />
<HelixPreCommand Include="export __TestTimeout=$(TimeoutPerTestInMilliseconds)" Condition=" '$(TimeoutPerTestInMilliseconds)' != '' " />
<HelixPreCommand Include="export __TestCollectionTimeoutMins=$(TimeoutPerTestCollectionInMinutes)" Condition=" '$(TimeoutPerTestCollectionInMinutes)' != '' " />
<HelixPreCommand Include="export __CollectDumps=1" />
<HelixPreCommand Include="export __CrashDumpFolder=$HELIX_DUMP_FOLDER" />
<HelixPreCommand Include="set __TestArchitecture=$(TargetArchitecture)" />
Expand Down