mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
Fixed flaky test.
(cherry picked from commit f846e0c031d74914d3a02626597df583422164e0)
This commit is contained in:
parent
ef230d1636
commit
3bcb6ef2ef
1 changed files with 26 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test.Client
|
||||
|
@ -12,13 +13,32 @@ namespace NzbDrone.Integration.Test.Client
|
|||
|
||||
public string[] GetLogFileLines(string filename)
|
||||
{
|
||||
var request = BuildRequest(filename);
|
||||
var content = Execute(request, System.Net.HttpStatusCode.OK);
|
||||
var attempts = 10;
|
||||
var attempt = 1;
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = BuildRequest(filename);
|
||||
var content = Execute(request, System.Net.HttpStatusCode.OK);
|
||||
|
||||
var lines = content.Split('\n');
|
||||
lines = Array.ConvertAll(lines, s => s.TrimEnd('\r'));
|
||||
Array.Resize(ref lines, lines.Length - 1);
|
||||
return lines;
|
||||
var lines = content.Split('\n');
|
||||
lines = Array.ConvertAll(lines, s => s.TrimEnd('\r'));
|
||||
Array.Resize(ref lines, lines.Length - 1);
|
||||
return lines;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (attempt == attempts)
|
||||
{
|
||||
_logger.Error(ex, "Failed to get log lines");
|
||||
throw;
|
||||
}
|
||||
_logger.Info(ex, "Failed to get log lines, attempt {0}/{1}", attempt, attempts);
|
||||
Thread.Sleep(10);
|
||||
attempt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue