Skip to content

Commit 279844b

Browse files
committed
Migrate HealthChecks.Solr tests to Testcontainers
1 parent 59c9f73 commit 279844b

File tree

9 files changed

+3137
-58
lines changed

9 files changed

+3137
-58
lines changed

.github/workflows/healthchecks_solr_ci.yml

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -29,58 +29,8 @@ on:
2929

3030
jobs:
3131
build:
32-
runs-on: ubuntu-latest
33-
# container: mcr.microsoft.com/dotnet/sdk:6.0
34-
# services:
35-
# solr:
36-
# image: solr:8.4.1
37-
# ports:
38-
# - 8983:8983
39-
# volumes:
40-
# - ${{ github.workspace }}/build/docker-services/solrcore:/var/solr/data/solrcore
41-
# - ${{ github.workspace }}/build/docker-services/solrcoredown:/var/solr/data/solrcoredown
42-
steps:
43-
# - name: Provide permission for deleting volume files
44-
# run: sudo chown -R $USER:$USER /home/runner/work/${{ github.event.repository.name }}
45-
46-
- uses: actions/checkout@v3
47-
- name: Initialize Solr
48-
run: |
49-
docker run -d -p8983:8983 -v${{ github.workspace }}/build/docker-services/solrcore:/var/solr/data/solrcore -v${{ github.workspace }}/build/docker-services/solrcoredown:/var/solr/data/solrcoredown solr:8.4.1
50-
- name: Test Solr
51-
run: |
52-
wget http://localhost:8983/solr/#
53-
curl http://localhost:8983/solr/# -v
54-
- name: Setup .NET
55-
uses: actions/setup-dotnet@v4
56-
with:
57-
dotnet-version: |
58-
8.0.x
59-
9.0.x
60-
- name: Restore
61-
run: |
62-
dotnet restore ./src/HealthChecks.Solr/HealthChecks.Solr.csproj &&
63-
dotnet restore ./test/HealthChecks.Solr.Tests/HealthChecks.Solr.Tests.csproj
64-
- name: Check formatting
65-
run: |
66-
dotnet format --no-restore --verify-no-changes --severity warn ./src/HealthChecks.Solr/HealthChecks.Solr.csproj || (echo "Run 'dotnet format' to fix issues" && exit 1) &&
67-
dotnet format --no-restore --verify-no-changes --severity warn ./test/HealthChecks.Solr.Tests/HealthChecks.Solr.Tests.csproj || (echo "Run 'dotnet format' to fix issues" && exit 1)
68-
- name: Build
69-
run: |
70-
dotnet build --no-restore ./src/HealthChecks.Solr/HealthChecks.Solr.csproj &&
71-
dotnet build --no-restore ./test/HealthChecks.Solr.Tests/HealthChecks.Solr.Tests.csproj
72-
#- name: Test
73-
# run: >
74-
# dotnet test
75-
# ./test/HealthChecks.Solr.Tests/HealthChecks.Solr.Tests.csproj
76-
# --no-restore
77-
# --no-build
78-
# --collect "XPlat Code Coverage"
79-
# --results-directory .coverage
80-
# --
81-
# DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
82-
#- name: Upload Coverage
83-
# uses: codecov/codecov-action@v3
84-
# with:
85-
# flags: Solr
86-
# directory: .coverage
32+
uses: ./.github/workflows/reusable_ci_workflow.yml
33+
with:
34+
PROJECT_PATH: ./src/HealthChecks.Solr/HealthChecks.Solr.csproj
35+
TEST_PROJECT_PATH: ./test/HealthChecks.Solr.Tests/HealthChecks.Solr.Tests.csproj
36+
CODECOV_FLAGS: Solr

test/HealthChecks.Solr.Tests/Functional/SolrHealthCheckTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace HealthChecks.Solr.Tests.Functional;
55

6-
public class solr_healthcheck_should
6+
public class solr_healthcheck_should(SolrContainerFixture solrFixture) : IClassFixture<SolrContainerFixture>
77
{
88
[Fact]
99
public async Task be_healthy_if_solr_is_available()
@@ -12,7 +12,7 @@ public async Task be_healthy_if_solr_is_available()
1212
.ConfigureServices(services =>
1313
{
1414
services.AddHealthChecks()
15-
.AddSolr("http://localhost:8983/solr", "solrcore", tags: ["solr"]);
15+
.AddSolr(solrFixture.GetConnectionString(), "solrcore", tags: ["solr"]);
1616
})
1717
.Configure(app =>
1818
{
@@ -35,7 +35,7 @@ public async Task be_unhealthy_if_solr_ping_is_disabled()
3535
.ConfigureServices(services =>
3636
{
3737
services.AddHealthChecks()
38-
.AddSolr("http://localhost:8893/solr", "solrcoredown", tags: ["solr"]);
38+
.AddSolr(solrFixture.GetConnectionString(), "solrcoredown", tags: ["solr"]);
3939
})
4040
.Configure(app =>
4141
{

test/HealthChecks.Solr.Tests/HealthChecks.Solr.Tests.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@
44
<ProjectReference Include="..\..\src\HealthChecks.Solr\HealthChecks.Solr.csproj" />
55
</ItemGroup>
66

7+
<ItemGroup>
8+
<PackageReference Include="Testcontainers" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<None Update="Resources/**">
13+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
14+
</None>
15+
</ItemGroup>
16+
717
</Project>

test/HealthChecks.Solr.Tests/Resources/solr/configsets/solrcore/conf/managed-schema

Lines changed: 296 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)