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.");
|
logger.LogInformation("Failed to connect, retry limit exceeded.");
|
||||||
throw new OperationCanceledException("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
|
else
|
||||||
{
|
{
|
||||||
try
|
RetryHelper.RetryOperation(
|
||||||
{
|
() => Directory.Delete(DeploymentParameters.PublishedApplicationRootPath, true),
|
||||||
// We've originally published the application in a temp folder. We need to delete it.
|
e => Logger.LogWarning($"Failed to delete directory : {e.Message}"),
|
||||||
Directory.Delete(DeploymentParameters.PublishedApplicationRootPath, true);
|
retryCount: 3,
|
||||||
}
|
retryDelayMilliseconds: 100);
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
Logger.LogWarning($"Failed to delete directory : {exception.Message}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue