From 44d8e6c2aa80dbeb2afc1e4471dc1b66bf47779a Mon Sep 17 00:00:00 2001 From: Huy Do Date: Thu, 9 Mar 2023 00:09:10 +0000 Subject: [PATCH] Retry CI Android emulator test (#96163) This is not the first time I spot Android test flakiness such as https://hud.pytorch.org/pytorch/pytorch/commit/893aa5df3f2a475c91ea8eadb1353812e52fb227. From some StackOverflow results, it looks like the failure `Unknown failure: Error: Could not access the Package Manager. Is the system running?` could be fixed by waiting a bit for the emulator to start fully https://stackoverflow.com/questions/15524185/could-not-access-the-package-manager-is-the-system-running-while-installing-and So, I'm adding retry capability here to give the test another chance. Pull Request resolved: https://github.com/pytorch/pytorch/pull/96163 Approved by: https://github.com/ZainRizvi --- android/common.sh | 4 ++++ android/run_tests.sh | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/android/common.sh b/android/common.sh index 1fee30bdc38..c7c508e2c90 100644 --- a/android/common.sh +++ b/android/common.sh @@ -10,6 +10,10 @@ if [ -z "$PYTORCH_DIR" ]; then exit 1 fi +retry () { + "$@" || (sleep 10 && "$@") || (sleep 20 && "$@") || (sleep 40 && "$@") +} + check_android_sdk() { if [ -z "$ANDROID_HOME" ]; then echo "ANDROID_HOME not set; please set it to Android sdk directory" diff --git a/android/run_tests.sh b/android/run_tests.sh index 839ee209c7b..c8c89776149 100755 --- a/android/run_tests.sh +++ b/android/run_tests.sh @@ -49,7 +49,8 @@ echo "Waiting for emulator boot completed" $ADB_PATH wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' { - $GRADLE_PATH -PABI_FILTERS=x86 -p $PYTORCH_ANDROID_DIR connectedAndroidTest + # The test currently takes about 10 minutes + retry $GRADLE_PATH -PABI_FILTERS=x86 -p $PYTORCH_ANDROID_DIR connectedAndroidTest } || { echo "::error::Check https://github.com/pytorch/pytorch/tree/master/test/mobile/model_test to see how to fix the failed mobile test" exit 1