hacky way to download container logs while retries are failing.
This commit is contained in:
parent
c6a757d6fb
commit
6995cbfb23
|
@ -144,6 +144,12 @@ namespace Utils
|
|||
return $"Attempt {index} took {FormatDuration(info.Item2)} and failed with exception {info.Item1}.";
|
||||
}
|
||||
|
||||
private static Action<int> failedCallback = i => { };
|
||||
public static void SetRetryFailedCallback(Action<int> onRetryFailed)
|
||||
{
|
||||
failedCallback = onRetryFailed;
|
||||
}
|
||||
|
||||
public static T Retry<T>(Func<T> action, TimeSpan maxTimeout, TimeSpan retryTime, string description)
|
||||
{
|
||||
var start = DateTime.UtcNow;
|
||||
|
@ -165,6 +171,7 @@ namespace Utils
|
|||
catch (Exception ex)
|
||||
{
|
||||
exceptions.Add(ex);
|
||||
failedCallback(tries);
|
||||
tries++;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace CodexLongTests.BasicTests
|
|||
|
||||
var node = StartCodex(s => s.WithStorageQuota((size + 10).MB()));
|
||||
|
||||
Time.SetRetryFailedCallback(i => OnFailed(i, node));
|
||||
|
||||
var uploadStart = DateTime.UtcNow;
|
||||
var cid = node.UploadFile(expectedFile);
|
||||
var downloadStart = DateTime.UtcNow;
|
||||
|
@ -60,6 +62,17 @@ namespace CodexLongTests.BasicTests
|
|||
AssertTimeConstraint(uploadStart, downloadStart, downloadFinished, size);
|
||||
}
|
||||
|
||||
private void OnFailed(int tries, ICodexNode node)
|
||||
{
|
||||
if (tries < 5) return;
|
||||
|
||||
if (tries % 10 == 0)
|
||||
{
|
||||
Log($"After try {tries}, downloading node log.");
|
||||
Ci.DownloadLog(node);
|
||||
}
|
||||
}
|
||||
|
||||
private void AssertTimeConstraint(DateTime uploadStart, DateTime downloadStart, DateTime downloadFinished, long size)
|
||||
{
|
||||
float sizeInMB = size;
|
||||
|
|
Loading…
Reference in New Issue