-
Notifications
You must be signed in to change notification settings - Fork 6
167 lines (139 loc) · 5.29 KB
/
bie-kafka-end2end-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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: 'CI: BIE Kafka End-2-End Test'
on:
# Allow manual triggering
workflow_dispatch:
# Allow being called by another GitHub Action
workflow_call:
env:
COMPOSE_PROFILES: 'kafka'
VRO_DEV_SECRETS_FOLDER: "${{ github.workspace }}/.cache/abd-vro-dev-secrets"
jobs:
integration-test:
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
- name: "Checkout abd-vro-dev-secrets repo"
uses: actions/checkout@v3
with:
# Checkout using a PAT so that we can access the internal repo
token: ${{ secrets.ACCESS_TOKEN_CHECKOUT_INTERNAL_REPO }}
repository: 'department-of-veterans-affairs/abd-vro-dev-secrets'
path: "${{ env.VRO_DEV_SECRETS_FOLDER }}"
- name: 'Set RABBITMQ_BASIC_AUTH'
run: |
source scripts/setenv.sh
# create basic auth token for RabbitMQ and export to github environment
BASIC_AUTH=$(echo "${RABBITMQ_PLACEHOLDERS_USERNAME}:${RABBITMQ_PLACEHOLDERS_USERPASSWORD}" | base64)
echo "RABBITMQ_BASIC_AUTH=${BASIC_AUTH}" >> "$GITHUB_ENV"
export -p | sed 's/declare -x //'
- name: 'Build the images'
uses: ./.github/actions/build-images
- name: 'Start the containers'
run: |
source scripts/setenv.sh
export -p | sed 's/declare -x //'
./gradlew :dockerComposeUp
./gradlew -p mocks :mock-bie-kafka:docker
./gradlew -p mocks :dockerComposeUp
./gradlew :domain-xample:dockerComposeUp
./gradlew :app:dockerComposeUp
- name: 'Wait for RabbitMQ to be ready'
uses: indiesdev/curl@v1.1
with:
url: 'http://localhost:15672/api/vhosts'
method: 'GET'
basic-auth-token: '${{env.RABBITMQ_BASIC_AUTH}}'
accept: 200
# Retry every 2 seconds
timeout: 2000
# Quit after 60 seconds
retries: 30
- name: 'Install kafkacat and postgresql'
run: |
sudo apt-get update
sudo apt-get install kafkacat
which kafkacat
sudo apt-get install postgresql
which psql
- name: 'Wait for Kafka to be ready'
run: |
# Verify broker is up with 30 second timeout
BROKER_QUERY=$(kafkacat -m 30 -b localhost:9092 -L)
if echo "$BROKER_QUERY" | grep -q '1 brokers'
then
echo "Found Broker: $BROKER_QUERY"
else
echo "Count not find Kafka broker"
exit 5
fi
- name: 'Wait for xample-workflow to be ready'
uses: nev7n/wait_for_response@v1
with:
url: 'http://localhost:10021/actuator/health'
responseCode: 200
# Retry every 2 seconds
interval: 2000
# Quit after 60 seconds
timeout: 60000
- name: 'Wait for svc-bie-kafka to be ready'
uses: nev7n/wait_for_response@v1
with:
url: 'http://localhost:10301/actuator/health'
responseCode: 200
# Retry every 2 seconds
interval: 2000
# Quit after 60 seconds
timeout: 60000
- name: 'Create Kafka topic and send message'
run: |
source scripts/setenv.sh
pushd svc-bie-kafka && { source ./docker-entryprep.sh; popd; }
if ! ./gradlew :svc-bie-kafka:integrationTest; then
echo "First run could fail due to some mock Kafka initialization"
# Subsequent runs should pass
./gradlew :svc-bie-kafka:integrationTest
fi
- name: 'Check for saved DB entry in Postgres'
run: |
source scripts/setenv.sh
# Retry to 5 times to allow time for message to travel from kafka to database
for i in {1..5}; do
sleep 10
echo "Attempt $i"
# For debugging
echo "::group::Table bie_contention_event contents"
psql "postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/vro" -c \
"SELECT * FROM claims.bie_contention_event"
echo "::endgroup::"
RESULT=$(psql postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/vro -x -c \
"SELECT COUNT(*) FROM claims.bie_contention_event
-- This is the contention id used in BieKafkaApplicationTest
WHERE contention_id=1234567890
")
echo "$RESULT"
if echo "$RESULT" | grep -q 'count | 1'; then
break
fi
done
# This will cause a failure if expected result is not found
echo "$RESULT" | grep -q 'count | 1'
- name: "Collect docker logs"
if: always()
uses: jwalton/gh-docker-logs@v2
with:
dest: './bie-kafka-end2end-test-with-mock-container-logs'
- name: "Upload artifact"
if: always()
uses: actions/upload-artifact@v3
with:
name: bie-kafka-end2end-test-with-mock-container-logs
path: ./bie-kafka-end2end-test-with-mock-container-logs/**
retention-days: 14
- name: 'Clean shutdown of all containers'
if: always()
shell: bash
run: |
docker ps
COMPOSE_PROFILES="all" ./gradlew dockerComposeDown
./gradlew -p mocks :dockerComposeDown