forked from million12/docker-haproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
82 lines (71 loc) · 3.45 KB
/
circle.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
machine:
services:
- docker
hosts:
nginx: 127.0.0.1
haproxy: 127.0.0.1
dependencies:
pre:
- docker pull million12/nginx: # used in Tests/docker-compose.yml
background: true
override:
- docker build -t million12/haproxy .
test:
override:
#
# Test interactive mode
#
- docker run -ti million12/haproxy -vv
- docker run -ti million12/haproxy -vv | grep "HA-Proxy version"
- docker run -ti million12/haproxy -vv | grep "Encrypted password support"
- docker run -ti million12/haproxy -vv | grep "OpenSSL 1.0.2"
#
# Test daemon mode (default settings)
#
- docker run -d -p 8080:80 --name haproxy million12/haproxy && sleep 1
- curl -u admin:admin http://127.0.0.1:8080/admin?stats
- docker rm -f haproxy || true
#
# Test providing custom HAProxy config
# Test restarting after making changes in that config
#
- docker run -d -p 8080:80 -v $(pwd)/container-files/etc/haproxy/haproxy.cfg:/my-haproxy.cfg -e HAPROXY_CONFIG=/my-haproxy.cfg --name haproxy million12/haproxy && sleep 1
- docker logs -f haproxy > ${CIRCLE_ARTIFACTS}/docker-haproxy.log 2>&1:
background: true
# Test if HAProxy uses the provided alternative config
- grep "HAProxy started with /my-haproxy.cfg config" ${CIRCLE_ARTIFACTS}/docker-haproxy.log
# Make a change and check if HAProxy restarts
- echo "" >> container-files/etc/haproxy/haproxy.cfg && sleep 1
- grep "Restarting HAProxy due to config changes" ${CIRCLE_ARTIFACTS}/docker-haproxy.log
# Check HAProxy stats
- curl -sSLi http://haproxy:8080/admin?stats | grep '401 Unauthorized'
- curl -sSLi --user admin:admin http://haproxy:8080/admin?stats
- curl -sSLi --user admin:admin http://haproxy:8080/admin?stats | grep '200 OK'
- curl -sSLi --user admin:admin http://haproxy:8080/admin?stats | grep 'Statistics Report'
# Make invalid entry in config and test restart
# and check if we have warning about errors
- echo "blabla" > container-files/etc/haproxy/haproxy.cfg && sleep 1
# Mount the mounted .cfg file and check its content - we expect there 'blabla'
- docker run --volumes-from haproxy --entrypoint sh million12/haproxy -c 'cat /my-haproxy.cfg' | grep 'blabla'
# Check for HAProxy warnings
- grep "Fatal errors found in configuration" ${CIRCLE_ARTIFACTS}/docker-haproxy.log
- docker rm -f haproxy || true
#
# Test whole stack with Nginx back-end - @see Tests/docker-compose.yml
#
- docker-compose -f Tests/docker-compose.yml up -d
- sleep 5
# Test direct request to Nginx
- curl -sSLi http://nginx:4080 | grep '200 OK'
- curl -sSLi http://nginx:4080 | grep 'default vhost'
- curl -sSLi --insecure https://nginx:4443 | grep '200 OK'
- curl -sSLi --insecure https://nginx:8443 | grep 'default vhost'
# Test requests via HAProxy
- curl -sSLi http://haproxy:8080 | grep '200 OK'
- curl -sSLi http://haproxy:8080 | grep 'default vhost'
- curl -sSLi --insecure https://haproxy:8443 | grep '200 OK'
- curl -sSLi --insecure https://haproxy:8443 | grep 'default vhost'
- openssl s_client -connect haproxy:8443 -nextprotoneg ''
- openssl s_client -connect haproxy:8443 -nextprotoneg '' | grep 'Secure Renegotiation IS supported'
- openssl s_client -connect haproxy:8443 -nextprotoneg '' | grep 'Protocol' | grep TLSv1.2
# - openssl s_client -connect haproxy:8443 -alpn 'h2' # CircleCI doesn't have openssl client with ALPN support...