Add retry to ApplicationDeployer delete
This commit is contained in:
parent
2fe8c27f30
commit
98e35cc6da
|
|
@ -72,5 +72,27 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
logger.LogInformation("Failed to connect, retry limit exceeded.");
|
||||
throw new OperationCanceledException("Failed to connect, retry limit exceeded.");
|
||||
}
|
||||
|
||||
public static void RetryOperation(
|
||||
Action retryBlock,
|
||||
Action<Exception> exceptionBlock,
|
||||
int retryCount = 3,
|
||||
int retryDelayMilliseconds = 0)
|
||||
{
|
||||
for (var retry = 0; retry < retryCount; ++retry)
|
||||
{
|
||||
try
|
||||
{
|
||||
retryBlock();
|
||||
break;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exceptionBlock(exception);
|
||||
}
|
||||
|
||||
Thread.Sleep(retryDelayMilliseconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,15 +90,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
// We've originally published the application in a temp folder. We need to delete it.
|
||||
Directory.Delete(DeploymentParameters.PublishedApplicationRootPath, true);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.LogWarning($"Failed to delete directory : {exception.Message}");
|
||||
}
|
||||
RetryHelper.RetryOperation(
|
||||
() => Directory.Delete(DeploymentParameters.PublishedApplicationRootPath, true),
|
||||
e => Logger.LogWarning($"Failed to delete directory : {e.Message}"),
|
||||
retryCount: 3,
|
||||
retryDelayMilliseconds: 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue