Skip to content

Commit 0e96b95

Browse files
committed
Add E2E test cases
1 parent 41d40ca commit 0e96b95

File tree

8 files changed

+132
-29
lines changed

8 files changed

+132
-29
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,4 @@ jobs:
3333
platforms: linux/amd64
3434
build-args: |
3535
VERSION=main
36-
HASH=${{ github.sha }}
37-
- name: Prune ghcr images
38-
uses: vlaurin/action-ghcr-prune@main
39-
with:
40-
token: ${{ secrets.PRUNE_IMAGE_TOKEN }}
41-
container: ${{github.event.repository.name}}
42-
dry-run: false
43-
older-than: 7
44-
keep-last: 2
45-
untagged: true
46-
keep-tags-regexes: (latest|alpine|2.5|2.5-alpine|2.5.5|2.5.5-alpine)
36+
HASH=${{ github.sha }}

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Release
1+
name: Publish (Release)
22

33
on:
44
release:

.github/workflows/test.yml

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: E2E Tests
22

33
on:
44
push:
@@ -47,4 +47,54 @@ jobs:
4747
- name: Install Helm chart for testing
4848
run: |
4949
kubectl cluster-info
50-
helm install test test/helm/ --set image=ghcr.io/snorwin/haproxy:${{ github.sha }}
50+
helm install test test/helm/ --set image=ghcr.io/snorwin/haproxy:${{ github.sha }}
51+
- name: Verify that client can connect to server using HAProxy
52+
run: |
53+
kubectl apply -f test/pod01.yaml
54+
sleep 90
55+
if [ $(kubectl logs http-client-01 | grep "HTTP/1.0 200" | wc -l) -le 0 ]; then
56+
exit 1
57+
fi
58+
- name: Change HAProxy configuration (change timeout)
59+
run: |
60+
kubectl get cm haproxy-config -o yaml | sed 's/timeout client 10s/timeout client 15s/' | kubectl apply -f -
61+
sleep 90
62+
- name: Verify that configuration was reloaded hitless
63+
run: |
64+
if [ $( kubectl logs haproxy | grep "reload successful" | wc -l) -ne 1 ]; then
65+
exit 1
66+
fi
67+
if [ $(kubectl logs http-client-01 | grep error | wc -l) -gt 0 ]; then
68+
exit 1
69+
fi
70+
- name: Change HAProxy configuration (invalid)
71+
run: |
72+
kubectl apply -f test/configmap-01.yaml
73+
sleep 90
74+
- name: Verify that configuration was NOT reloaded
75+
run: |
76+
if [ $( kubectl logs haproxy | grep "reload failed" | wc -l) -ne 1 ]; then
77+
exit 1
78+
fi
79+
if [ $(kubectl logs http-client-01 | grep error | wc -l) -gt 0 ]; then
80+
exit 1
81+
fi
82+
- name: Change HAProxy configuration (add listen)
83+
run: |
84+
kubectl apply -f test/configmap-02.yaml
85+
sleep 90
86+
- name: Verify that configuration was reloaded hitless
87+
run: |
88+
if [ $( kubectl logs haproxy | grep "reload successful" | wc -l) -ne 2 ]; then
89+
exit 1
90+
fi
91+
if [ $(kubectl logs http-client-01 | grep error | wc -l) -gt 0 ]; then
92+
exit 1
93+
fi
94+
- name: Verify that new client can connect to server using HAProxy
95+
run: |
96+
kubectl apply -f test/pod02.yaml
97+
sleep 90
98+
if [ $(kubectl logs http-client-02 | grep "HTTP/1.0 200" | wc -l) -le 0 ]; then
99+
exit 1
100+
fi

test/configmap-01.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: haproxy-config
5+
data:
6+
haproxy.cfg: |
7+
global
8+
maxconn 1000
9+
stats socket /var/run/haproxy.sock mode 600 level admin expose-fd listeners
10+
stats timeout 2m
11+
12+
default
13+
mode http
14+
timeout client 10s
15+
timeout connect 5s
16+
timeout server 10s
17+
timeout http-request 10s
18+
19+
listen foo
20+
bind :8080
21+
server server1 http-server-service:8080
22+
---

test/configmap-02.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: haproxy-config
5+
data:
6+
haproxy.cfg: |
7+
global
8+
maxconn 1000
9+
stats socket /var/run/haproxy.sock mode 600 level admin expose-fd listeners
10+
stats timeout 2m
11+
12+
defaults
13+
mode http
14+
timeout client 10s
15+
timeout connect 5s
16+
timeout server 10s
17+
timeout http-request 10s
18+
19+
listen foo
20+
bind :8080
21+
server server1 http-server-service:8080
22+
23+
listen bar
24+
bind :6000
25+
server server1 http-server-service:8080
26+
---

test/helm/templates/pods.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,4 @@ spec:
3939
- /bin/bash
4040
- -c
4141
- python3 -m http.server 8080 --bind 0.0.0.0
42-
---
43-
apiVersion: v1
44-
kind: Pod
45-
metadata:
46-
name: http-client
47-
labels:
48-
app.kubernetes.io/name: http-client
49-
spec:
50-
containers:
51-
- name: siege
52-
image: ghcr.io/snorwin/siege:4.1.2
53-
command:
54-
- /bin/bash
55-
- -c
56-
- siege -c10 http://haproxy-service:8080
5742
---

test/pod01.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: http-client-01
5+
labels:
6+
app.kubernetes.io/name: http-client-01
7+
spec:
8+
containers:
9+
- name: siege
10+
image: ghcr.io/snorwin/siege:4.1.2
11+
command:
12+
- /bin/bash
13+
- -c
14+
- siege -c10 http://haproxy-service:8080
15+
---

test/pod02.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: http-client-02
5+
labels:
6+
app.kubernetes.io/name: http-client-02
7+
spec:
8+
containers:
9+
- name: siege
10+
image: ghcr.io/snorwin/siege:4.1.2
11+
command:
12+
- /bin/bash
13+
- -c
14+
- siege -c10 http://haproxy-service:6000
15+
---

0 commit comments

Comments
 (0)