Feature/#52 (#283)

* #52 test circle ci

* #52 nicked some lads cake script

* #52 put the mac build script back

* #52 trying another lads circle CI thing doesnt use cake

* #52 added test steps

* #52 ports for linux build

* #52 try travis mac build

* #52 dont use build script

* #52 dont use build script

* #52 acceptance and int tests dont really work on mac...v strange?

* #52 unique port for linux tests

* #52 increase code coverage

* #52 try using cake on linux for travis

* #52 try using cake for mac and linux on travis

* #52 dont run the acceptance and int tests on mac

* #52 build.sh has lf line endings

* #52 turns out crlf is OK for cake file..sigh

* #52 not sure what return does in cake so wrapped in if just to see

* #52 try use travis to work not run on mac

* #52 dont need these references

* #52 wrong property

* #52 remove circle ci for linux and just use travis for all
This commit is contained in:
Tom Pallister 2018-03-17 18:07:27 +00:00 committed by GitHub
parent 8a2f76d0c5
commit 0ab670a143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 144 additions and 6 deletions

17
.circleci/config.yml Normal file
View File

@ -0,0 +1,17 @@
version: 2
jobs:
build:
working_directory: /temp
docker:
- image: microsoft/dotnet:sdk
environment:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
steps:
- checkout
- run: dotnet restore
- run: dotnet build
- run: dotnet test ./test/Ocelot.UnitTests/Ocelot.UnitTests.csproj
- run: dotnet test ./test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj
- run: dotnet test ./test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj

31
.travis.yml Normal file
View File

@ -0,0 +1,31 @@
language: csharp
os:
- osx
- linux
# Ubuntu 14.04
sudo: required
dist: trusty
# OS X 10.12
osx_image: xcode9.2
mono:
- 4.4.2
dotnet: 2.1.4
before_install:
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch origin
script:
- ./build.sh
cache:
directories:
- .packages
- tools/Addins
- tools/gitreleasemanager
- tools/GitVersion.CommandLine

View File

@ -1,6 +1,7 @@
[<img src="http://threemammals.com/images/ocelot_logo.png">](http://threemammals.com/ocelot) [<img src="http://threemammals.com/images/ocelot_logo.png">](http://threemammals.com/ocelot)
[![Build status](https://ci.appveyor.com/api/projects/status/r6sv51qx36sis1je?svg=true)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb) [![Build status](https://ci.appveyor.com/api/projects/status/r6sv51qx36sis1je?branch=develop&svg=true)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb) Windows (AppVeyor)
[![Build Status](https://travis-ci.org/ThreeMammals/Ocelot.svg?branch=develop)](https://travis-ci.org/ThreeMammals/Ocelot) Linux & OSX (Travis)
[![Windows Build history](https://buildstats.info/appveyor/chart/TomPallister/ocelot-fcfpb?branch=develop&includeBuildsFromPullRequest=false)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop) [![Windows Build history](https://buildstats.info/appveyor/chart/TomPallister/ocelot-fcfpb?branch=develop&includeBuildsFromPullRequest=false)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop)

View File

@ -189,6 +189,24 @@ Task("RunAcceptanceTests")
.IsDependentOn("Compile") .IsDependentOn("Compile")
.Does(() => .Does(() =>
{ {
if(TravisCI.IsRunningOnTravisCI)
{
Information(
@"Job:
JobId: {0}
JobNumber: {1}
OSName: {2}",
BuildSystem.TravisCI.Environment.Job.JobId,
BuildSystem.TravisCI.Environment.Job.JobNumber,
BuildSystem.TravisCI.Environment.Job.OSName
);
if(TravisCI.Environment.Job.OSName.ToLower() == "osx")
{
return;
}
}
var settings = new DotNetCoreTestSettings var settings = new DotNetCoreTestSettings
{ {
Configuration = compileConfig, Configuration = compileConfig,
@ -205,6 +223,24 @@ Task("RunIntegrationTests")
.IsDependentOn("Compile") .IsDependentOn("Compile")
.Does(() => .Does(() =>
{ {
if(TravisCI.IsRunningOnTravisCI)
{
Information(
@"Job:
JobId: {0}
JobNumber: {1}
OSName: {2}",
BuildSystem.TravisCI.Environment.Job.JobId,
BuildSystem.TravisCI.Environment.Job.JobNumber,
BuildSystem.TravisCI.Environment.Job.OSName
);
if(TravisCI.Environment.Job.OSName.ToLower() == "osx")
{
return;
}
}
var settings = new DotNetCoreTestSettings var settings = new DotNetCoreTestSettings
{ {
Configuration = compileConfig, Configuration = compileConfig,

View File

@ -31,7 +31,7 @@ namespace Ocelot.AcceptanceTests
public void should_use_service_discovery_and_load_balance_request() public void should_use_service_discovery_and_load_balance_request()
{ {
var downstreamServiceOneUrl = "http://localhost:50881"; var downstreamServiceOneUrl = "http://localhost:50881";
var downstreamServiceTwoUrl = "http://localhost:50882"; var downstreamServiceTwoUrl = "http://localhost:50892";
var configuration = new FileConfiguration var configuration = new FileConfiguration
{ {
@ -54,7 +54,7 @@ namespace Ocelot.AcceptanceTests
new FileHostAndPort new FileHostAndPort
{ {
Host = "localhost", Host = "localhost",
Port = 50882 Port = 50892
} }
} }
} }

View File

@ -41,7 +41,7 @@ namespace Ocelot.AcceptanceTests
new FileHostAndPort new FileHostAndPort
{ {
Host = "localhost", Host = "localhost",
Port = 51872, Port = 51892,
} }
}, },
UpstreamPathTemplate = "/", UpstreamPathTemplate = "/",
@ -56,7 +56,7 @@ namespace Ocelot.AcceptanceTests
} }
}; };
this.Given(x => x.GivenThereIsAPossiblyBrokenServiceRunningOn("http://localhost:51872", "Hello from Laura")) this.Given(x => x.GivenThereIsAPossiblyBrokenServiceRunningOn("http://localhost:51892", "Hello from Laura"))
.Given(x => _steps.GivenThereIsAConfiguration(configuration)) .Given(x => _steps.GivenThereIsAConfiguration(configuration))
.Given(x => _steps.GivenOcelotIsRunning()) .Given(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/")) .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))

View File

@ -0,0 +1,53 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Middleware.Multiplexer;
using Ocelot.Middleware.Pipeline;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Middleware
{
public class OcelotPipelineExtensionsTests
{
private OcelotPipelineBuilder _builder;
private OcelotRequestDelegate _handlers;
[Fact]
public void should_set_up_pipeline()
{
this.Given(_ => GivenTheDepedenciesAreSetUp())
.When(_ => WhenIBuild())
.Then(_ => ThenThePipelineIsBuilt())
.BDDfy();
}
private void ThenThePipelineIsBuilt()
{
_handlers.ShouldNotBeNull();
}
private void WhenIBuild()
{
_handlers = _builder.BuildOcelotPipeline(new OcelotPipelineConfiguration());
}
private void GivenTheDepedenciesAreSetUp()
{
IConfigurationBuilder test = new ConfigurationBuilder();
var root = test.Build();
var services = new ServiceCollection();
services.AddSingleton<IConfiguration>(root);
services.AddOcelot();
var provider = services.BuildServiceProvider();
_builder = new OcelotPipelineBuilder(provider);
}
}
}