Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 5 additions & 46 deletions .github/workflows/healthchecks_eventstore_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,8 @@ on:

jobs:
build:
runs-on: ubuntu-latest
services:
eventstore:
image: eventstore/eventstore:22.10.5-jammy
ports:
- "2113:2113"
- "1113:1113"
env:
EVENTSTORE_INSECURE: true
EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: true
EVENTSTORE_ENABLE_EXTERNAL_TCP: true
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Restore
run: |
dotnet restore ./src/HealthChecks.EventStore/HealthChecks.EventStore.csproj &&
dotnet restore ./test/HealthChecks.EventStore.Tests/HealthChecks.EventStore.Tests.csproj
- name: Check formatting
run: |
dotnet format --no-restore --verify-no-changes --severity warn ./src/HealthChecks.EventStore/HealthChecks.EventStore.csproj || (echo "Run 'dotnet format' to fix issues" && exit 1) &&
dotnet format --no-restore --verify-no-changes --severity warn ./test/HealthChecks.EventStore.Tests/HealthChecks.EventStore.Tests.csproj || (echo "Run 'dotnet format' to fix issues" && exit 1)
- name: Build
run: |
dotnet build --no-restore ./src/HealthChecks.EventStore/HealthChecks.EventStore.csproj &&
dotnet build --no-restore ./test/HealthChecks.EventStore.Tests/HealthChecks.EventStore.Tests.csproj
- name: Test
run: >
dotnet test
./test/HealthChecks.EventStore.Tests/HealthChecks.EventStore.Tests.csproj
--no-restore
--no-build
--collect "XPlat Code Coverage"
--results-directory .coverage
--
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: Upload Coverage
uses: codecov/codecov-action@v5
with:
flags: EventStore
directory: .coverage
uses: ./.github/workflows/reusable_ci_workflow.yml
with:
PROJECT_PATH: ./src/HealthChecks.EventStore/HealthChecks.EventStore.csproj
TEST_PROJECT_PATH: ./test/HealthChecks.EventStore.Tests/HealthChecks.EventStore.Tests.csproj
CODECOV_FLAGS: EventStore
49 changes: 5 additions & 44 deletions .github/workflows/healthchecks_eventstore_grpc_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,8 @@ on:

jobs:
build:
runs-on: ubuntu-latest
services:
eventstore:
image: eventstore/eventstore:22.10.5-jammy
ports:
- "1113:1113"
- "2113:2113"
env:
EVENTSTORE_INSECURE: true
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Restore
run: |
dotnet restore ./src/HealthChecks.EventStore.gRPC/HealthChecks.EventStore.gRPC.csproj &&
dotnet restore ./test/HealthChecks.EventStore.gRPC.Tests/HealthChecks.EventStore.gRPC.Tests.csproj
- name: Check formatting
run: |
dotnet format --no-restore --verify-no-changes --severity warn ./src/HealthChecks.EventStore.gRPC/HealthChecks.EventStore.gRPC.csproj || (echo "Run 'dotnet format' to fix issues" && exit 1) &&
dotnet format --no-restore --verify-no-changes --severity warn ./test/HealthChecks.EventStore.gRPC.Tests/HealthChecks.EventStore.gRPC.Tests.csproj || (echo "Run 'dotnet format' to fix issues" && exit 1)
- name: Build
run: |
dotnet build --no-restore ./src/HealthChecks.EventStore.gRPC/HealthChecks.EventStore.gRPC.csproj &&
dotnet build --no-restore ./test/HealthChecks.EventStore.gRPC.Tests/HealthChecks.EventStore.gRPC.Tests.csproj
- name: Test
run: >
dotnet test
./test/HealthChecks.EventStore.gRPC.Tests/HealthChecks.EventStore.gRPC.Tests.csproj
--no-restore
--no-build
--collect "XPlat Code Coverage"
--results-directory .coverage
--
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: Upload Coverage
uses: codecov/codecov-action@v5
with:
flags: EventStore.gRPC
directory: .coverage
uses: ./.github/workflows/reusable_ci_workflow.yml
with:
PROJECT_PATH: ./src/HealthChecks.EventStore.gRPC/HealthChecks.EventStore.gRPC.csproj
TEST_PROJECT_PATH: ./test/HealthChecks.EventStore.gRPC.Tests/HealthChecks.EventStore.gRPC.Tests.csproj
CODECOV_FLAGS: EventStore.gRPC
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
<PackageVersion Include="Testcontainers" Version="$(TestcontainersVersion)" />
<PackageVersion Include="Testcontainers.ClickHouse" Version="$(TestcontainersVersion)" />
<PackageVersion Include="Testcontainers.EventStoreDb" Version="$(TestcontainersVersion)" />
<PackageVersion Include="Testcontainers.Kafka" Version="$(TestcontainersVersion)" />
<PackageVersion Include="Testcontainers.Milvus" Version="$(TestcontainersVersion)" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="$(TestcontainersVersion)" />
Expand All @@ -119,4 +120,4 @@
<ItemGroup Condition="'$(IsPackable)' == 'true'">
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
</ItemGroup>
</Project>
</Project>
55 changes: 55 additions & 0 deletions test/HealthChecks.EventStore.Tests/EventStoreDbContainerFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Data.Common;
using Testcontainers.EventStoreDb;

namespace HealthChecks.EventStore.Tests;

public class EventStoreDbContainerFixture : IAsyncLifetime
{
private const string Registry = "docker.io";

private const string Image = "eventstore/eventstore";

private const string Tag = "22.10.5-bookworm-slim";

public const int TcpPort = 1113;

public EventStoreDbContainer? Container { get; private set; }

public string GetConnectionString()
{
if (Container is null)
{
throw new InvalidOperationException("The test container was not initialized.");
}

var uriBuilder = new UriBuilder(
"tcp",
Container.Hostname,
Container.GetMappedPublicPort(TcpPort));

var dbConnectionStringBuilder = new DbConnectionStringBuilder
{
{ "ConnectTo", uriBuilder.ToString() },
{ "UseSslConnection", false }
};

return dbConnectionStringBuilder.ConnectionString;
}

public async Task InitializeAsync() => Container = await CreateContainerAsync();

public Task DisposeAsync() => Container?.DisposeAsync().AsTask() ?? Task.CompletedTask;

private static async Task<EventStoreDbContainer> CreateContainerAsync()
{
var container = new EventStoreDbBuilder()
.WithImage($"{Registry}/{Image}:{Tag}")
.WithEnvironment("EVENTSTORE_ENABLE_EXTERNAL_TCP", "true")
.WithPortBinding(TcpPort, true)
.Build();

await container.StartAsync();

return container;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@

namespace HealthChecks.EventStore.Tests.Functional;

public class eventstore_healthcheck_should
public class eventstore_healthcheck_should(EventStoreDbContainerFixture eventStoreDbFixture) : IClassFixture<EventStoreDbContainerFixture>
{
[Fact]
public async Task be_healthy_if_eventstore_is_available_with_uri_format()
{
string connectionString = eventStoreDbFixture.GetConnectionString();

var webHostBuilder = new WebHostBuilder()
.ConfigureServices(services =>
{
services.AddHealthChecks()
.AddEventStore("ConnectTo=tcp://localhost:1113; UseSslConnection=false", tags: ["eventstore"]);
.AddEventStore(connectionString, tags: ["eventstore"]);
})
.Configure(app =>
{
Expand All @@ -33,11 +35,13 @@ public async Task be_healthy_if_eventstore_is_available_with_uri_format()
[Fact]
public async Task be_healthy_if_eventstore_is_available()
{
string connectionString = eventStoreDbFixture.GetConnectionString();

var webHostBuilder = new WebHostBuilder()
.ConfigureServices(services =>
{
services.AddHealthChecks()
.AddEventStore("ConnectTo=tcp://localhost:1113; UseSslConnection=false; HeartBeatTimeout=500", tags: ["eventstore"]);
.AddEventStore(connectionString, tags: ["eventstore"]);
})
.Configure(app =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<ProjectReference Include="..\..\src\HealthChecks.EventStore\HealthChecks.EventStore.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Testcontainers.EventStoreDb" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Testcontainers.EventStoreDb;

namespace HealthChecks.EventStore.gRPC.Tests;

public class EventStoreDbContainerFixture : IAsyncLifetime
{
private const string Registry = "docker.io";

private const string Image = "eventstore/eventstore";

private const string Tag = "24.10.6";

public EventStoreDbContainer? Container { get; private set; }

public string GetConnectionString()
{
if (Container is null)
{
throw new InvalidOperationException("The test container was not initialized.");
}

return Container.GetConnectionString();
}

public async Task InitializeAsync() => Container = await CreateContainerAsync();

public Task DisposeAsync() => Container?.DisposeAsync().AsTask() ?? Task.CompletedTask;

private static async Task<EventStoreDbContainer> CreateContainerAsync()
{
var container = new EventStoreDbBuilder()
.WithImage($"{Registry}/{Image}:{Tag}")
.Build();

await container.StartAsync();

return container;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace HealthChecks.EventStore.gRPC.Tests.Functional;

public class eventstore_healthcheck_should
public class eventstore_healthcheck_should(EventStoreDbContainerFixture eventStoreDbFixture) : IClassFixture<EventStoreDbContainerFixture>
{
[Fact]
public async Task be_healthy_if_eventstore_is_available()
{
string connectionString = eventStoreDbFixture.GetConnectionString();

var webHostBuilder = new WebHostBuilder()
.ConfigureServices(services =>
{
services.AddHealthChecks()
.AddEventStore("esdb://localhost:2113?tls=false", tags: ["eventstore"]);
.AddEventStore(connectionString, tags: ["eventstore"]);
})
.Configure(app =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<ProjectReference Include="..\..\src\HealthChecks.EventStore.gRPC\HealthChecks.EventStore.gRPC.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Testcontainers.EventStoreDb" />
</ItemGroup>

</Project>