-
Notifications
You must be signed in to change notification settings - Fork 5
100 lines (98 loc) · 3.24 KB
/
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
name: E2E Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
image:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v2
- name: Modify Dockerfile
run: |
sed -i -e "s|%VERSION%|latest|g" Dockerfile
- name: Build and push
id: docker_build_master
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/snorwin/haproxy:${{ github.sha }}
platforms: linux/amd64
build-args: |
VERSION=test
HASH=${{ github.sha }}
test:
needs: image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create kind cluster
uses: helm/[email protected]
- name: Install Helm chart for testing
run: |
kubectl cluster-info
helm install test test/helm/ --set image=ghcr.io/snorwin/haproxy:${{ github.sha }}
- name: Verify that client can connect to server using HAProxy
run: |
kubectl apply -f test/pod01.yaml
sleep 90
if [ $(kubectl logs http-client-01 | grep "HTTP/1.0 200" | wc -l) -le 0 ]; then
exit 1
fi
- name: Change HAProxy configuration (change timeout)
run: |
kubectl get cm haproxy-config -o yaml | sed 's/timeout client 10s/timeout client 15s/' | kubectl apply -f -
sleep 90
- name: Verify that configuration was reloaded hitless
run: |
if [ $( kubectl logs haproxy | grep "reload successful" | wc -l) -ne 1 ]; then
exit 1
fi
if [ $(kubectl logs http-client-01 | grep error | wc -l) -gt 0 ]; then
exit 1
fi
- name: Change HAProxy configuration (invalid)
run: |
kubectl apply -f test/configmap-01.yaml
sleep 90
- name: Verify that configuration was NOT reloaded
run: |
if [ $( kubectl logs haproxy | grep "reload failed" | wc -l) -ne 1 ]; then
exit 1
fi
if [ $(kubectl logs http-client-01 | grep error | wc -l) -gt 0 ]; then
exit 1
fi
- name: Change HAProxy configuration (add listen)
run: |
kubectl apply -f test/configmap-02.yaml
sleep 90
- name: Verify that configuration was reloaded hitless
run: |
if [ $( kubectl logs haproxy | grep "reload successful" | wc -l) -ne 2 ]; then
exit 1
fi
if [ $(kubectl logs http-client-01 | grep error | wc -l) -gt 0 ]; then
exit 1
fi
- name: Verify that new client can connect to server using HAProxy
run: |
kubectl apply -f test/pod02.yaml
sleep 90
if [ $(kubectl logs http-client-02 | grep "HTTP/1.0 200" | wc -l) -le 0 ]; then
exit 1
fi