Skip to content

Commit

Permalink
ci: run integration tests in separate steps
Browse files Browse the repository at this point in the history
  • Loading branch information
tnotheis committed Jul 4, 2024
1 parent 24bdb91 commit 69666b6
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 59 deletions.
17 changes: 17 additions & 0 deletions .ci/compose.test.aui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
admin-ui:
container_name: admin-ui-test
hostname: admin-ui
image: admin-ui:0.0.1
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "5173:8080"
depends_on:
database-migrator:
condition: service_completed_successfully
rabbitmq:
condition: service_started
configs:
- source: Config
target: app/appsettings.override.json
19 changes: 19 additions & 0 deletions .ci/compose.test.capi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
consumer-api:
container_name: consumer-api-test
hostname: consumer-api
image: consumer-api:0.0.1
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "5000:8080"
depends_on:
database-migrator:
condition: service_completed_successfully
rabbitmq:
condition: service_started
azure-storage-emulator:
condition: service_started
configs:
- source: Config
target: app/appsettings.override.json
File renamed without changes.
File renamed without changes.
36 changes: 0 additions & 36 deletions .ci/docker-compose.test.yml → .ci/compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,4 @@
services:
consumer-api:
container_name: consumer-api-test
hostname: consumer-api
image: consumer-api:0.0.1
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "5000:8080"
depends_on:
database-migrator:
condition: service_completed_successfully
rabbitmq:
condition: service_started
azure-storage-emulator:
condition: service_started
configs:
- source: Config
target: app/appsettings.override.json

admin-ui:
container_name: admin-ui-test
hostname: admin-ui
image: admin-ui:0.0.1
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "5173:8080"
depends_on:
database-migrator:
condition: service_completed_successfully
rabbitmq:
condition: service_started
configs:
- source: Config
target: app/appsettings.override.json

event-handler-service:
container_name: event-handler-service-test
image: event-handler-service:0.0.1
Expand Down
162 changes: 139 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,85 @@ jobs:
pattern: docker-*
merge-multiple: true

- name: Load Docker images
run: ./.ci/loadDockerImages.sh
- name: Load Docker images and build test code
run: |
{
./.ci/loadDockerImages.sh
} &
{
dotnet restore Backbone.sln;
dotnet build --no-restore Backbone.sln
}
wait
#### Admin UI integration tests

- name: Restart compose stack
id: restart-compose-stack-1
run: |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml down -v;
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml up -d --no-build
- name: Run integration tests
run: ./.ci/integrationTest.sqlserver.sh
- name: Run Admin UI integration tests
id: run-aui-integration-tests
if: (success() || failure()) && (steps.restart-compose-stack-1.outcome == 'success')
run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration
env:
ADMIN_API_BASE_ADDRESS: "http://localhost:5173"

- name: Save Docker Logs
if: failure()
run: docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.sqlserver.yml logs > docker-log.txt
if: (success() || failure()) && (steps.run-aui-integration-tests.outcome == 'failure')
run: docker compose -f ./.ci/compose.test.aui.yml logs > aui.integration-test.sqlserver.txt

#### Consumer API integration tests

- name: Restart compose stack
id: restart-compose-stack-2
if: success() || failure()
run: |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml down -v;
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml up -d --no-build
- name: Run Consumer API integration tests
id: run-capi-integration-tests
if: (success() || failure()) && (steps.restart-compose-stack-2.outcome == 'success')
run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration
env:
CONSUMER_API_BASE_ADDRESS: "http://localhost:5000"

- name: Save Docker Logs
if: (success() || failure()) && (steps.run-capi-integration-tests.outcome == 'failure')
run: docker compose -f ./.ci/compose.test.capi.yml logs > capi.integration-test.sqlserver.txt

#### Identity Deletion Job integration tests

- name: Restart compose stack
id: restart-compose-stack-3
if: success() || failure()
run: |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml down -v;
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml up -d --no-build
- name: Run Identity Deletion Job integration tests
id: run-idj-integration-tests
if: (success() || failure()) && (steps.restart-compose-stack-3.outcome == 'success')
run: |
mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak
cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json
dotnet build --no-restore Jobs/test/Job.IdentityDeletion.Tests.Integration
dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration
- name: Archive logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: integration-test-sqlserver-docker-logs
path: docker-log.txt
name: aui.integration-test.sqlserver
path: capi.integration-test.sqlserver.txt
env:
DOTNET_CONSOLE_ANSI_COLOR: true

integration-test-postgres:
name: Run Integration Tests (on Postgres)
name: Run Integration Tests (on SQL Server)
runs-on: ubuntu-latest
needs: image-test-builds
steps:
Expand All @@ -254,22 +312,80 @@ jobs:
pattern: docker-*
merge-multiple: true

- name: Load Docker images
run: ./.ci/loadDockerImages.sh
- name: Load Docker images and build test code
run: |
{
./.ci/loadDockerImages.sh
} &
{
dotnet restore Backbone.sln;
dotnet build --no-restore Backbone.sln
}
wait
#### Admin UI integration tests

- name: Restart compose stack
id: restart-compose-stack-1
run: |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml down -v;
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml up -d --no-build
- name: Run integration tests
run: ./.ci/integrationTest.postgres.sh
- name: Run Admin UI integration tests
id: run-aui-integration-tests
if: (success() || failure()) && (steps.restart-compose-stack-1.outcome == 'success')
run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration
env:
ADMIN_API_BASE_ADDRESS: "http://localhost:5173"

- name: Save Docker Logs
if: failure()
run: docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.postgres.yml logs > docker-log.txt
if: (success() || failure()) && (steps.run-aui-integration-tests.outcome == 'failure')
run: docker compose -f ./.ci/compose.test.aui.yml logs > aui.integration-test.postgres.txt

#### Consumer API integration tests

- name: Restart compose stack
id: restart-compose-stack-2
if: success() || failure()
run: |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml down -v;
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml up -d --no-build
- name: Run Consumer API integration tests
id: run-capi-integration-tests
if: (success() || failure()) && (steps.restart-compose-stack-2.outcome == 'success')
run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration
env:
CONSUMER_API_BASE_ADDRESS: "http://localhost:5000"

- name: Save Docker Logs
if: (success() || failure()) && (steps.run-capi-integration-tests.outcome == 'failure')
run: docker compose -f ./.ci/compose.test.capi.yml logs > capi.integration-test.postgres.txt

#### Identity Deletion Job integration tests

- name: Restart compose stack
id: restart-compose-stack-3
if: success() || failure()
run: |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml down -v;
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml up -d --no-build
- name: Run Identity Deletion Job integration tests
id: run-idj-integration-tests
if: (success() || failure()) && (steps.restart-compose-stack-3.outcome == 'success')
run: |
mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak
cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json
dotnet build --no-restore Jobs/test/Job.IdentityDeletion.Tests.Integration
dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration
- name: Archive logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: integration-test-postgres-docker-logs
path: docker-log.txt
name: aui.integration-test.postgres
path: capi.integration-test.postgres.txt
env:
DOTNET_CONSOLE_ANSI_COLOR: true

Expand Down Expand Up @@ -307,7 +423,7 @@ jobs:
run: ./backbone/.ci/loadDockerImages.sh

- name: Run Consumer API & Admin API
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml up -d --no-build
run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml up -d --no-build

- name: Install runtime dependencies
working-directory: ./runtime
Expand All @@ -325,7 +441,7 @@ jobs:

- name: Save Docker Logs
if: failure()
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml logs > docker-log.txt
run: docker compose -f ./.ci/compose.test.capi.yml logs > docker-log.txt

- name: Archive logs
if: failure()
Expand All @@ -335,7 +451,7 @@ jobs:
path: docker-log.txt

- name: Stop Consumer API
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml down
run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml down

transport-test-postgres:
name: Run transport Tests (on Postgres)
Expand Down Expand Up @@ -371,7 +487,7 @@ jobs:
run: ./backbone/.ci/loadDockerImages.sh

- name: Run Consumer API & Admin API
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml up -d --no-build
run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml up -d --no-build

- name: Install runtime dependencies
working-directory: ./runtime
Expand All @@ -389,7 +505,7 @@ jobs:

- name: Save Docker Logs
if: failure()
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml logs > docker-log.txt
run: docker compose -f ./.ci/compose.test.capi.yml logs > docker-log.txt

- name: Archive logs
if: failure()
Expand All @@ -399,7 +515,7 @@ jobs:
path: docker-log.txt

- name: Stop Consumer API
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml down
run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml down

build-helm-chart:
name: Build Helm Chart
Expand Down

0 comments on commit 69666b6

Please sign in to comment.