Skip to content

Commit

Permalink
Retry CI Android emulator test (pytorch#96163)
Browse files Browse the repository at this point in the history
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: pytorch#96163
Approved by: https://github.com/ZainRizvi
  • Loading branch information
huydhn authored and pytorchmergebot committed Mar 9, 2023
1 parent df0ff34 commit 44d8e6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions android/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion android/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 44d8e6c

Please sign in to comment.