diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml new file mode 100644 index 0000000000..dede2700c7 --- /dev/null +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -0,0 +1,38 @@ +trigger: +- dev +- release/* + +resources: + repositories: + - repository: buildtools + type: git + name: aspnet-BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools + parameters: + agentOs: Windows + beforeBuild: + - task: NodeTool@0 + displayName: Use Node 8.x + inputs: + versionSpec: 8.x + +- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools + parameters: + agentOs: macOS + beforeBuild: + - task: NodeTool@0 + displayName: Use Node 8.x + inputs: + versionSpec: 8.x + +- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools + parameters: + agentOs: Linux + beforeBuild: + - task: NodeTool@0 + displayName: Use Node 8.x + inputs: + versionSpec: 8.x diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml new file mode 100644 index 0000000000..a310fa5b88 --- /dev/null +++ b/.vsts-pipelines/builds/ci-public.yml @@ -0,0 +1,40 @@ +trigger: +- dev +- release/* + +# See https://github.com/aspnet/BuildTools +resources: + repositories: + - repository: buildtools + type: github + endpoint: DotNet-Bot GitHub Connection + name: aspnet/BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools + parameters: + agentOs: Windows + beforeBuild: + - task: NodeTool@0 + displayName: Use Node 8.x + inputs: + versionSpec: 8.x + +- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools + parameters: + agentOs: macOS + beforeBuild: + - task: NodeTool@0 + displayName: Use Node 8.x + inputs: + versionSpec: 8.x + +- template: .vsts-pipelines/templates/phases/default-build.yml@buildtools + parameters: + agentOs: Linux + beforeBuild: + - task: NodeTool@0 + displayName: Use Node 8.x + inputs: + versionSpec: 8.x diff --git a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Docker.cs b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Docker.cs index fcc7ba066d..b2691a5fa1 100644 --- a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Docker.cs +++ b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Docker.cs @@ -29,14 +29,26 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests private static Docker Create() { - // Currently Windows Server 2016 doesn't support linux containers which redis is. - if (string.Equals("True", Environment.GetEnvironmentVariable("APPVEYOR"), StringComparison.OrdinalIgnoreCase)) + var location = GetDockerLocation(); + if (location == null) { return null; } - var location = GetDockerLocation(); - return location == null ? null : new Docker(location); + var docker = new Docker(location); + + // Windows docker must have Linux containers turned on, if they don't skip the docker tests + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + docker.RunCommand("info --format '{{.OSType}}'", out var output); + + if (!string.Equals(output, "linux")) + { + return null; + } + } + + return docker; } private static string GetDockerLocation() @@ -65,6 +77,14 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests // use redis base docker image // 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)); + + // inspect the redis docker image and extract the IPAddress. Necessary when running tests from inside a docker container, spinning up a new docker container for redis + // outside the current container requires linking the networks (difficult to automate) or using the IP:Port combo + RunProcess(_path, "inspect --format=\"{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}\" " + _dockerContainerName, logger, TimeSpan.FromSeconds(5), out output); + output = output.Trim().Replace(Environment.NewLine, ""); + + // variable used by Startup.cs + Environment.SetEnvironmentVariable("REDIS_CONNECTION", $"{output}:6379"); } public void Stop(ILogger logger) @@ -131,6 +151,9 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests logger.LogError("Closing process '{processName}' because it is running longer than the configured timeout.", fileName); } + // Need to WaitForExit without a timeout to guarantee the output stream has written everything + process.WaitForExit(); + output = string.Join(Environment.NewLine, lines); return exitCode; diff --git a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisServerFixture.cs b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisServerFixture.cs index a125e6e648..e3f3b7f9d7 100644 --- a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisServerFixture.cs +++ b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisServerFixture.cs @@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests { try { - return new ServerFixture(); + return new ServerFixture(_loggerFactory); } catch (Exception ex) { diff --git a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Startup.cs b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Startup.cs index 3c6b19c53d..f760a4e869 100644 --- a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Startup.cs +++ b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Startup.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; @@ -21,6 +22,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests { // We start the servers before starting redis so we want to time them out ASAP options.Configuration.ConnectTimeout = 1; + options.Configuration.EndPoints.Add(Environment.GetEnvironmentVariable("REDIS_CONNECTION")); }); services.AddSingleton();