Properly wait for process exit for docker helper and log errors (#1667)

This commit is contained in:
BrennanConroy 2018-03-21 09:21:33 -07:00 committed by GitHub
parent 6583e5fb47
commit e889175c0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -63,8 +63,8 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
// create and run docker container, remove automatically when stopped, map 6379 from the container to 6379 localhost
// use static name 'redisTestContainer' so if the container doesn't get removed we don't keep adding more
// use redis base docker image
// 10 second timeout to allow redis image to be downloaded
RunProcessAndThrowIfFailed(_path, $"run --rm -p 6379:6379 --name {_dockerContainerName} -d redis", logger, TimeSpan.FromSeconds(10));
// 20 second timeout to allow redis image to be downloaded, should be a rare occurance, only happening when a new version is released
RunProcessAndThrowIfFailed(_path, $"run --rm -p 6379:6379 --name {_dockerContainerName} -d redis", logger, TimeSpan.FromSeconds(20));
}
public void Stop(ILogger logger)
@ -125,7 +125,11 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
process.BeginErrorReadLine();
process.BeginOutputReadLine();
process.WaitForExit((int)timeout.TotalMilliseconds);
if (!process.WaitForExit((int)timeout.TotalMilliseconds))
{
process.Close();
logger.LogError("Closing process '{processName}' because it is running longer than the configured timeout.", fileName);
}
output = string.Join(Environment.NewLine, lines);