Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7e6c2ef
each replica has its own cancellation token and records its own state
areller Apr 30, 2020
8b3e89c
added state to v1replica
areller Apr 30, 2020
57dc3f4
license and formatting
areller Apr 30, 2020
616df58
add liveness and readiness to configuration and model
areller May 3, 2020
3912db6
ReplicaMonitor
areller May 3, 2020
24b0459
revamp test helpers
areller May 3, 2020
d4fbdeb
health check tests
areller May 3, 2020
e95a361
formatting
areller May 3, 2020
56b9869
merge with master
areller May 3, 2020
9dcc606
formatting
areller May 3, 2020
3f48f54
don't run docker tests
areller May 3, 2020
3b058b3
add more tests
areller May 4, 2020
4659b51
fix header handling
areller May 4, 2020
ee9b374
start adding timeout to http probe
areller May 4, 2020
8f396c7
add timeout, port, protocol, successThreshold, failureThreshold to pr…
areller May 5, 2020
0276a09
success threshold must be 1 for liveness
areller May 7, 2020
569df2a
proxy and ingress don't forward to non ready replicas
areller May 7, 2020
f22149c
warnings and formatting
areller May 7, 2020
f452feb
Merge remote-tracking branch 'dotnet/master' into health
areller May 8, 2020
aa52cd0
fix mistake done by merge
areller May 8, 2020
22e506e
formatting
areller May 8, 2020
7a72a3e
Merge branch 'master' into health
areller May 10, 2020
440cf1b
Merge remote-tracking branch 'dotnet/master' into health
areller May 12, 2020
e86cda1
run proxy for single replica services if readiness is defined
areller May 12, 2020
b41ccff
license and formatting
areller May 12, 2020
1d3d03e
should start at (false, false)
areller May 12, 2020
f89e630
clean csproj
areller May 13, 2020
726e2a4
rename service names in health-checks folder
areller May 13, 2020
7a29291
change name of service in tests
areller May 13, 2020
65c7ae0
generate liveness and readiness in k8s manifest
areller May 13, 2020
ffef174
fix review comments
areller May 13, 2020
6280485
using docker restart when docker replica is cancelled
areller May 14, 2020
a116b4b
formatting
areller May 14, 2020
eb13a21
Update src/Microsoft.Tye.Core/CoreStrings.resx
areller May 18, 2020
602a2bc
Update src/Microsoft.Tye.Core/KubernetesManifestGenerator.cs
areller May 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
don't run docker tests
  • Loading branch information
areller committed May 3, 2020
commit 3f48f54edae5c34745493ddd6e35438b047e38f0
24 changes: 9 additions & 15 deletions test/E2ETest/HealthCheckTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,16 @@ public HealthCheckTests(ITestOutputHelper output)
_options.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task ServiceWithoutLivenessReadinessShouldDefaultToReadyTests(bool docker)
[Fact]
public async Task ServiceWithoutLivenessReadinessShouldDefaultToReadyTests()
{
using var projectDirectory = CopyTestProjectDirectory("health-checks");

var projectFile = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
var outputContext = new OutputContext(_sink, Verbosity.Debug);
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);

await using var host = new TyeHost(application.ToHostingApplication(), new HostOptions() { Docker = docker })
await using var host = new TyeHost(application.ToHostingApplication(), new HostOptions())
{
Sink = _sink,
};
Expand All @@ -73,18 +71,16 @@ public async Task ServiceWithoutLivenessReadinessShouldDefaultToReadyTests(bool
await DoOperationAndWaitForReplicasToChangeState(host, ReplicaState.Ready, replicasToBeReady.Count, replicasToBeReady, null, TimeSpan.Zero, h => h.StartAsync());
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task ServiceWithoutLivenessShouldDefaultToHealthyTests(bool docker)
[Fact]
public async Task ServiceWithoutLivenessShouldDefaultToHealthyTests()
{
using var projectDirectory = CopyTestProjectDirectory("health-checks");

var projectFile = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
var outputContext = new OutputContext(_sink, Verbosity.Debug);
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);

await using var host = new TyeHost(application.ToHostingApplication(), new HostOptions() { Docker = docker })
await using var host = new TyeHost(application.ToHostingApplication(), new HostOptions())
{
Sink = _sink,
};
Expand All @@ -93,18 +89,16 @@ public async Task ServiceWithoutLivenessShouldDefaultToHealthyTests(bool docker)
await DoOperationAndWaitForReplicasToChangeState(host, ReplicaState.Healthy, replicasToBeHealthy.Count, replicasToBeHealthy, null, TimeSpan.Zero, h => h.StartAsync());
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task ServiceWithoutReadinessShouldDefaultToReadyWhenHealthyTests(bool docker)
[Fact]
public async Task ServiceWithoutReadinessShouldDefaultToReadyWhenHealthyTests()
{
using var projectDirectory = CopyTestProjectDirectory("health-checks");

var projectFile = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
var outputContext = new OutputContext(_sink, Verbosity.Debug);
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);

await using var host = new TyeHost(application.ToHostingApplication(), new HostOptions() { Docker = docker })
await using var host = new TyeHost(application.ToHostingApplication(), new HostOptions())
{
Sink = _sink,
};
Expand Down
63 changes: 45 additions & 18 deletions test/E2ETest/ReplicaStoppingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,61 @@ public ReplicaStoppingTests(ITestOutputHelper output)
_options.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task MultiProjectStoppingTests(bool docker)
[Fact]
public async Task MultiProjectStoppingTests()
{
using var projectDirectory = CopyTestProjectDirectory("multi-project");

var projectFile = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
var outputContext = new OutputContext(_sink, Verbosity.Debug);
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);

await RunHostingApplication(application, new HostOptions() { Docker = docker }, async (host, uri) =>
{
var replicaToStop = host.Application.Services["frontend"].Replicas.First();
Assert.Contains(replicaToStop.Value.State, startedOrHigher);
await RunHostingApplication(application, new HostOptions(), async (host, uri) =>
{
var replicaToStop = host.Application.Services["frontend"].Replicas.First();
Assert.Contains(replicaToStop.Value.State, startedOrHigher);

var replicasToRestart = new[] { replicaToStop.Key };
var restOfReplicas = host.Application.Services.SelectMany(s => s.Value.Replicas).Select(r => r.Value.Name).Where(r => r != replicaToStop.Key).ToArray();

Assert.True(await DoOperationAndWaitForReplicasToRestart(host, replicasToRestart.ToHashSet(), restOfReplicas.ToHashSet(), TimeSpan.FromSeconds(1), _ =>
{
replicaToStop.Value.StoppingTokenSource.Cancel();
return Task.CompletedTask;
}));

Assert.Contains(replicaToStop.Value.State, stoppedOrLower);
Assert.True(host.Application.Services.SelectMany(s => s.Value.Replicas).All(r => startedOrHigher.Contains(r.Value.State)));
});
}

[ConditionalFact]
[SkipIfDockerNotRunning]
public async Task MultiProjectDockerStoppingTests()
{
using var projectDirectory = CopyTestProjectDirectory("multi-project");

var projectFile = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
var outputContext = new OutputContext(_sink, Verbosity.Debug);
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);

await RunHostingApplication(application, new HostOptions() { Docker = true }, async (host, uri) =>
{
var replicaToStop = host.Application.Services["frontend"].Replicas.First();
Assert.Contains(replicaToStop.Value.State, startedOrHigher);

var replicasToRestart = new[] { replicaToStop.Key };
var restOfReplicas = host.Application.Services.SelectMany(s => s.Value.Replicas).Select(r => r.Value.Name).Where(r => r != replicaToStop.Key).ToArray();
var replicasToRestart = new[] { replicaToStop.Key };
var restOfReplicas = host.Application.Services.SelectMany(s => s.Value.Replicas).Select(r => r.Value.Name).Where(r => r != replicaToStop.Key).ToArray();

Assert.True(await DoOperationAndWaitForReplicasToRestart(host, replicasToRestart.ToHashSet(), restOfReplicas.ToHashSet(), TimeSpan.FromSeconds(1), _ =>
{
replicaToStop.Value.StoppingTokenSource.Cancel();
return Task.CompletedTask;
}));
Assert.True(await DoOperationAndWaitForReplicasToRestart(host, replicasToRestart.ToHashSet(), restOfReplicas.ToHashSet(), TimeSpan.FromSeconds(1), _ =>
{
replicaToStop.Value.StoppingTokenSource.Cancel();
return Task.CompletedTask;
}));

Assert.Contains(replicaToStop.Value.State, stoppedOrLower);
Assert.True(host.Application.Services.SelectMany(s => s.Value.Replicas).All(r => startedOrHigher.Contains(r.Value.State)));
});
Assert.Contains(replicaToStop.Value.State, stoppedOrLower);
Assert.True(host.Application.Services.SelectMany(s => s.Value.Replicas).All(r => startedOrHigher.Contains(r.Value.State)));
});
}

private async Task RunHostingApplication(ApplicationBuilder application, HostOptions options, Func<TyeHost, Uri, Task> execute)
Expand Down