Give redis docker image time to download (#1131)

This commit is contained in:
BrennanConroy 2017-11-17 10:32:15 -08:00 committed by GitHub
parent 2fcf3ea9b7
commit 75274c76d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -58,16 +58,17 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
// create and run docker container, remove automatically when stopped, map 6379 from the container to 6379 localhost // 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 static name 'redisTestContainer' so if the container doesn't get removed we don't keep adding more
// use redis base docker image // use redis base docker image
return RunProcess(_path, $"run --rm -p 6379:6379 --name {_dockerContainerName} -d redis", logger); // 10 second timeout to allow redis image to be downloaded
return RunProcess(_path, $"run --rm -p 6379:6379 --name {_dockerContainerName} -d redis", logger, TimeSpan.FromSeconds(10));
} }
public int Stop(ILogger logger) public int Stop(ILogger logger)
{ {
logger.LogInformation("Stopping docker container"); logger.LogInformation("Stopping docker container");
return RunProcess(_path, $"stop {_dockerContainerName}", logger); return RunProcess(_path, $"stop {_dockerContainerName}", logger, TimeSpan.FromSeconds(5));
} }
private static int RunProcess(string fileName, string arugments, ILogger logger) private static int RunProcess(string fileName, string arugments, ILogger logger, TimeSpan timeout)
{ {
var process = new Process var process = new Process
{ {
@ -92,7 +93,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
process.BeginErrorReadLine(); process.BeginErrorReadLine();
process.BeginOutputReadLine(); process.BeginOutputReadLine();
process.WaitForExit(5000); process.WaitForExit((int)timeout.TotalMilliseconds);
return exitCode; return exitCode;
} }

View File

@ -12,7 +12,11 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddSignalR() services.AddSignalR()
.AddRedis(); .AddRedis(options =>
{
// We start the servers before starting redis so we want to time them out ASAP
options.Options.ConnectTimeout = 1;
});
} }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IHostingEnvironment env)