-
Notifications
You must be signed in to change notification settings - Fork 2
109 lines (106 loc) · 3.99 KB
/
unit_tests.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
name: Unit test suite run
env:
# sensu container config
SENSU_IMAGE: quay.io/infrawatch/sensu:1.9.0
TRANSPORT_NAME: rabbitmq
RABBITMQ_HOST: 127.0.0.1
RABBITMQ_PORT: 5672
RABBITMQ_USER: sensu
RABBITMQ_PASSWORD: sensu
RABBITMQ_VHOST: "/sensu"
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
REDIS_DB: 0
REDIS_AUTO_RECONNECT: true
REDIS_RECONNECT_ON_ERROR: false
# redis container config
REDIS_IMAGE: redis:6.2.1
# rabbitmq container config
RABBITMQ_IMAGE: rabbitmq:3.7.24
# qdr container config
QDROUTERD_IMAGE: quay.io/interconnectedcloud/qdrouterd:1.12.0
# loki container config
LOKI_IMAGE: quay.io/infrawatch/loki:2.4.2
# misc. config
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
on:
- push
- pull_request
- workflow_dispatch
jobs:
test-framework:
name: Unit test suite
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Start Redis
run: |
docker run --name redis -p 6379:6379 -d $REDIS_IMAGE
- name: Start RabbitMQ message bus
run: |
docker run --name=rabbitmq -p 5672:5672 -p 4369:4369 -d $RABBITMQ_IMAGE
- name: Start qdrouterd message bus
run: |
docker run --name=qdr --volume=${{ github.workspace }}/ci/qdrouterd.conf:/etc/qpid-dispatch/qdrouterd.conf:ro -p 5666:5666 -d $QDROUTERD_IMAGE
- name: Configure RabbitMQ message bus for sensu-core usage
run: |
docker exec rabbitmq rabbitmqctl start_app
sleep 5
docker exec rabbitmq rabbitmqctl add_user $RABBITMQ_USER $RABBITMQ_PASSWORD
docker exec rabbitmq rabbitmqctl add_vhost $RABBITMQ_VHOST
docker exec rabbitmq rabbitmqctl set_permissions -p $RABBITMQ_VHOST $RABBITMQ_USER ".*" ".*" ".*"
- name: Start Sensu
run: |
cat > ./sensu-env <<EOF
TRANSPORT_NAME=$TRANSPORT_NAME
RABBITMQ_HOST=$ABBITMQ_HOST
RABBITMQ_USER=$RABBITMQ_USER
RABBITMQ_PASSWORD=$RABBITMQ_PASSWORD
RABBITMQ_VHOST=$RABBITMQ_VHOST
REDIS_HOST=$REDIS_HOST
REDIS_PORT=$REDIS_PORT
REDIS_DB=$REDIS_DB
REDIS_AUTO_RECONNECT=$REDIS_AUTO_RECONNECT
REDIS_RECONNECT_ON_ERROR=$REDIS_RECONNECT_ON_ERROR
EOF
docker run --name sensu-api --network host --env-file=./sensu-env -d $SENSU_IMAGE api
docker run --name sensu-server --network host --env-file=./sensu-env --volume=${{ github.workspace }}/ci/sensu/check.d:/etc/sensu/check.d:ro -d $SENSU_IMAGE server
- name: Start Loki
run: |
docker run --name loki --volume=${{ github.workspace }}/ci/loki-config.yaml:/etc/loki/loki-config.yaml:ro -p 3100:3100 -d $LOKI_IMAGE -config.file=/etc/loki/loki-config.yaml
- name: Wait for Loki to become ready
run: |
echo "========================== loki ========================="
while ! curl -sX GET "http://127.0.0.1:3100/ready" | grep -q "^ready$"
do
sleep 1
done
- name: List dependency containers' logs
run: |
docker ps --all
echo "---- rabbitmq ----"
docker logs rabbitmq
echo "---- qdr ----"
docker logs qdr
echo "---- sensu-core ----"
docker logs sensu-server
docker logs sensu-api
echo "---- loki ----"
docker logs loki
- name: Run unit tests
run: |
export PROJECT_ROOT=/root/go/src/github.com/infrawatch/apputils
docker run -uroot --network host --volume=${{ github.workspace }}:$PROJECT_ROOT:z --workdir $PROJECT_ROOT quay.io/centos/centos:stream8 bash ci/run_ci.sh
- name: List dependency containers' logs
run: |
echo "---- rabbitmq ----"
docker logs rabbitmq
echo "---- qdr ----"
docker logs qdr
echo "---- sensu-core ----"
docker logs sensu-server
docker logs sensu-api
echo "---- loki ----"
docker logs loki
if: ${{ failure() }}