diff --git a/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.ps1 b/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.ps1 index 9736ebf140c..f67b706f538 100644 --- a/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.ps1 +++ b/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.ps1 @@ -42,6 +42,7 @@ $reboot=$false switch ($exit_code) { + # ADB_DEVICE_ENUMERATION_FAILURE 85 { $ErrorActionPreference="Continue" Write-Error "Encountered ADB_DEVICE_ENUMERATION_FAILURE. This is typically not a failure of the work item. We will run it again and reboot this computer to help its devices" @@ -51,6 +52,7 @@ switch ($exit_code) Break } + # PACKAGE_INSTALLATION_FAILURE 78 { $ErrorActionPreference="Continue" Write-Error "Encountered PACKAGE_INSTALLATION_FAILURE. This is typically not a failure of the work item. We will try it again on another Helix agent" @@ -60,15 +62,11 @@ switch ($exit_code) } } -# ADB_DEVICE_ENUMERATION_FAILURE if ($retry) { - & "$Env:HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('Retrying because we could not enumerate all Android devices')" } -# PACKAGE_INSTALLATION_FAILURE if ($reboot) { - & "$Env:HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('Rebooting to allow Android emulator or device to restart')" } diff --git a/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.sh b/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.sh index 3f958fb5c1a..d6501bc00c3 100644 --- a/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.sh +++ b/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.sh @@ -81,9 +81,11 @@ reboot=false # Too see where these values come from, check out https://github.com/dotnet/xharness/blob/master/src/Microsoft.DotNet.XHarness.Common/CLI/ExitCode.cs # Avoid any helix-ism in the Xharness! +ADB_DEVICE_ENUMERATION_FAILURE=85 +PACKAGE_INSTALLATION_FAILURE=78 case "$exit_code" in - 85) + $ADB_DEVICE_ENUMERATION_FAILURE) # This handles issues where devices or emulators fail to start. # The only solution is to reboot the machine, so we request a work item retry + agent reboot when this happens echo 'Encountered ADB_DEVICE_ENUMERATION_FAILURE. This is typically not a failure of the work item. We will run it again and reboot this computer to help its devices' @@ -91,7 +93,7 @@ case "$exit_code" in retry=true reboot=true ;; - 78) + $PACKAGE_INSTALLATION_FAILURE) # This handles issues where APKs fail to install. # We already reboot a device inside XHarness and now request a work item retry when this happens echo 'Encountered PACKAGE_INSTALLATION_FAILURE. This is typically not a failure of the work item. We will try it again on another Helix agent' @@ -100,16 +102,12 @@ case "$exit_code" in ;; esac - - -ADB_DEVICE_ENUMERATION_FAILURE=85 -if [ "$retry"]; then +if [ "$retry" == true ]; then "$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('Retrying because we could not enumerate all Android devices')" fi -PACKAGE_INSTALLATION_FAILURE=78 -if [ $exit_code -eq PACKAGE_INSTALLATION_FAILURE ]; then - "$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('Rebooting to allow Android emulator or device to restart.')" +if [ "$reboot" == true ]; then + "$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('Rebooting to allow Android emulator to restart')" fi exit $exit_code