From e2c8cb553be2f042f02345ffc7234e9244cef61c Mon Sep 17 00:00:00 2001 From: Le Zhou <2428499107@qq.com> Date: Tue, 14 Mar 2023 18:07:32 +0800 Subject: [PATCH] Bugfix: Retry install app if failed (#368) * Retry if install failed * Update TestRunner.java --- .../hydralab/agent/runner/TestRunner.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/TestRunner.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/TestRunner.java index 7185131a6..2f0c3ba5a 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/TestRunner.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/TestRunner.java @@ -12,6 +12,7 @@ import com.microsoft.hydralab.common.management.device.TestDeviceManager; import com.microsoft.hydralab.common.management.device.impl.IOSTestDeviceManager; import com.microsoft.hydralab.common.util.DateUtil; +import com.microsoft.hydralab.common.util.FlowUtil; import com.microsoft.hydralab.common.util.LogUtils; import com.microsoft.hydralab.common.util.ThreadPoolUtil; import com.microsoft.hydralab.common.util.ThreadUtils; @@ -204,8 +205,11 @@ protected void reInstallApp(DeviceInfo deviceInfo, TestTask testTask, Logger rep testDeviceManager.resetPackage(deviceInfo, testTask.getPkgName(), reportLogger); } checkTestTaskCancel(testTask); - - testDeviceManager.installApp(deviceInfo, testTask.getAppFile().getAbsolutePath(), reportLogger); + try { + FlowUtil.retryAndSleepWhenFalse(3, 10, () -> testDeviceManager.installApp(deviceInfo, testTask.getAppFile().getAbsolutePath(), reportLogger)); + } catch (Exception e) { + throw new Exception(e); + } } protected void reInstallTestApp(DeviceInfo deviceInfo, TestTask testTask, Logger reportLogger) @@ -228,7 +232,11 @@ protected void reInstallTestApp(DeviceInfo deviceInfo, TestTask testTask, Logger ThreadUtils.safeSleep(2000); } checkTestTaskCancel(testTask); - testDeviceManager.installApp(deviceInfo, testTask.getTestAppFile().getAbsolutePath(), reportLogger); + try { + FlowUtil.retryAndSleepWhenFalse(3, 10, () -> testDeviceManager.installApp(deviceInfo, testTask.getTestAppFile().getAbsolutePath(), reportLogger)); + } catch (Exception e) { + throw new Exception(e); + } } protected boolean shouldInstallTestPackageAsApp() {