-
Notifications
You must be signed in to change notification settings - Fork 48
130 lines (130 loc) · 5.33 KB
/
container-integration-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# See /src/container-integration-test/README.md
on:
workflow_call:
jobs:
container-test:
runs-on: ubuntu-22.04
name: ${{ matrix.name }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- name: rabbit
transport: RabbitMQ.QuorumConventionalRouting
connection-string: 'host=rabbit'
compose-cmd: docker compose -f servicecontrol.yml -f rabbit.yml up -d
expected-healthy-containers: 5
- name: mssql
transport: SQLServer
connection-string: 'Server=mssql;Database=master;User=sa;Password=ServiceControl1!;Encrypt=False;'
compose-cmd: docker compose -f servicecontrol.yml -f mssql.yml up -d
expected-healthy-containers: 5
- name: postgresql
transport: PostgreSQL
connection-string: 'Host=postgres;Port=5432;Database=postgres;User ID=postgres;Password=ServiceControl1!;'
compose-cmd: docker compose -f servicecontrol.yml -f postgres.yml up -d
expected-healthy-containers: 5
- name: asb
transport: NetStandardAzureServiceBus
compose-cmd: docker compose -f servicecontrol.yml up -d
expected-healthy-containers: 4
- name: asq
transport: AzureStorageQueue
compose-cmd: docker compose -f servicecontrol.yml up -d
expected-healthy-containers: 4
- name: sqs
transport: AmazonSQS
# No connection-string - should be able to load AWS info only from environment variables
compose-cmd: docker compose -f servicecontrol.yml -f sqs.yml up -d
expected-healthy-containers: 5
env:
CONNECTIONSTRING: ${{ matrix.connection-string }}
TRANSPORTTYPE: ${{ matrix.transport }}
steps:
- name: Check for secrets
env:
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
shell: pwsh
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 })
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Run MinVer
uses: Particular/[email protected]
- name: Log in to GitHub container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Azure Login
if: ${{ matrix.name == 'asb' || matrix.name == 'asq' }}
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_ACI_CREDENTIALS }}
- name: Setup Azure Service Bus
if: ${{ matrix.name == 'asb' }}
uses: Particular/[email protected]
with:
connection-string-name: CONNECTIONSTRING
azure-credentials: ${{ secrets.AZURE_ACI_CREDENTIALS }}
tag: ServiceControlContainerTest
- name: Setup Azure Storage
if: ${{ matrix.name == 'asq' }}
uses: Particular/[email protected]
with:
connection-string-name: CONNECTIONSTRING
azure-credentials: ${{ secrets.AZURE_ACI_CREDENTIALS }}
tag: ServiceControlContainerTest
- name: Run Docker Compose
shell: pwsh
env:
SERVICECONTROL_TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || env.MinVerVersion }}
run: |
cd src/container-integration-test
echo 'Starting services...'
${{ matrix.compose-cmd }}
echo 'Docker compose complete'
- name: Evaluate container health
id: evaluate
shell: pwsh
run: |
echo "Waiting for containers to become healthy"
$numHealthy = 0
for ($i=0; $i -le 20; $i++) {
$numHealthy = (docker ps -f health=healthy --format json | ConvertFrom-Json).Count
echo "Currently $numHealthy healthy containers out of ${{matrix.expected-healthy-containers}} expected"
if ($numHealthy -eq ${{matrix.expected-healthy-containers}}) {
break;
}
sleep 5
}
Write-Output "healthy-containers=$numHealthy" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf-8 -Append
- name: Dump Docker container list
if: ${{ always() }}
run: docker ps --all
- name: Dump Primary instance logs
if: ${{ always() }}
run: docker logs service-platform-servicecontrol-1
- name: Dump Audit instance logs
if: ${{ always() }}
run: docker logs service-platform-servicecontrol-audit-1
- name: Dump Monitoring instance logs
if: ${{ always() }}
run: docker logs service-platform-servicecontrol-monitoring-1
- name: Dump Database logs
if: ${{ always() }}
run: docker logs service-platform-servicecontrol-db-1
- name: Return status
shell: pwsh
run: |
$numHealthy = ${{ steps.evaluate.outputs.healthy-containers }}
echo "Found $numHealthy healthy containers out of ${{matrix.expected-healthy-containers}} expected"
if ($numHealthy -ne ${{matrix.expected-healthy-containers}}) {
exit 1
}