Skip to content

Commit 294a284

Browse files
authored
Rerun mobile target jobs when it fails for 4 known scenarios (dotnet#60475)
* Rerun jobs when it fails for 4 known scenarios * Add exitcode to retry files * Add app name to retry files * Fix callsite
1 parent d90c4f5 commit 294a284

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/tests/Common/Coreclr.TestWrapper/MobileAppHandler.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ private static int HandleMobileApp(string action, string platform, string catego
2222
{
2323
//install or uninstall mobile app
2424
int exitCode = -100;
25+
26+
if (action == "install" && (File.Exists($"{testBinaryBase}/.retry") || File.Exists($"{testBinaryBase}/.reboot")))
27+
{
28+
return exitCode;
29+
}
30+
2531
string outputFile = Path.Combine(reportBase, action, $"{category}_{action}.output.txt");
2632
string errorFile = Path.Combine(reportBase, action, $"{category}_{action}.error.txt");
2733
bool platformValueFlag = true;
@@ -81,6 +87,11 @@ private static int HandleMobileApp(string action, string platform, string catego
8187
}
8288
}
8389

90+
if (action == "install")
91+
{
92+
cmdStr += " --timeout 00:05:00";
93+
}
94+
8495
using (Process process = new Process())
8596
{
8697
if (OperatingSystem.IsWindows())
@@ -108,6 +119,19 @@ private static int HandleMobileApp(string action, string platform, string catego
108119
{
109120
// Process completed.
110121
exitCode = process.ExitCode;
122+
123+
// See https://github.com/dotnet/xharness/blob/main/src/Microsoft.DotNet.XHarness.Common/CLI/ExitCode.cs
124+
// 78 - PACKAGE_INSTALLATION_FAILURE
125+
// 81 - DEVICE_NOT_FOUND
126+
// 85 - ADB_DEVICE_ENUMERATION_FAILURE
127+
// 86 - PACKAGE_INSTALLATION_TIMEOUT
128+
if (action == "install" && (exitCode == 78 || exitCode == 81|| exitCode == 85|| exitCode == 86))
129+
{
130+
CreateRetryFile($"{testBinaryBase}/.retry", exitCode, category);
131+
CreateRetryFile($"{testBinaryBase}/.reboot", exitCode, category);
132+
return exitCode;
133+
}
134+
111135
Task.WaitAll(copyOutput, copyError);
112136
}
113137
else
@@ -155,5 +179,13 @@ private static string ConvertCmd2Arg(string cmd)
155179

156180
return $"{cmdPrefix} \"{cmd}\"";
157181
}
182+
183+
private static void CreateRetryFile(string fileName, int exitCode, string appName)
184+
{
185+
using (StreamWriter writer = new StreamWriter(fileName))
186+
{
187+
writer.WriteLine($"appName: {appName}; exitCode: {exitCode}");
188+
}
189+
}
158190
}
159191
}

0 commit comments

Comments
 (0)