Skip to content

Commit 5e0afb7

Browse files
author
Pratik Mohanty
committed
MEDIUM : sticky-counter, tune ocsp: Add e2e tests for sticky-counters to http/tcp and global ocsp
1 parent 97e699e commit 5e0afb7

File tree

25 files changed

+1002
-45
lines changed

25 files changed

+1002
-45
lines changed

.gitlab-ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,9 @@ HAProxy_2_7:
152152
matrix:
153153
- TESTPART: [ "1/2", "2/2" ]
154154
HAPROXY_VERSION: "2.7"
155+
HAProxy_latest_dev:
156+
extends: .e2e
157+
parallel:
158+
matrix:
159+
- TESTPART: [ "1/2", "2/2" ]
160+
HAPROXY_VERSION: "2.8"

e2e/libs/haproxy_config_setup.bash

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ setup() {
3030
fi
3131

3232
# replace the default haproxy config file
33-
if [ -f "${BATS_TEST_DIRNAME}/data/haproxy.cfg" ]; then
33+
if [ $HAPROXY_VERSION = 2.8 ] && [ -f "${BATS_TEST_DIRNAME}/data/haproxy_${HAPROXY_VERSION}.cfg" ]; then
34+
run docker cp "${BATS_TEST_DIRNAME}/data/haproxy_${HAPROXY_VERSION}.cfg" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/haproxy.cfg"
35+
elif [ -f "${BATS_TEST_DIRNAME}/data/haproxy.cfg" ]; then
3436
run docker cp "${BATS_TEST_DIRNAME}/data/haproxy.cfg" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/haproxy.cfg"
3537
else
3638
run docker cp "${E2E_DIR}/fixtures/haproxy.cfg" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/haproxy.cfg"

e2e/run.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -eo pipefail
1818

1919
export BASE_PATH="/v2"
2020

21-
HAPROXY_VERSION=${HAPROXY_VERSION:-2.7}
21+
HAPROXY_VERSION=${HAPROXY_VERSION:-2.8}
2222
DOCKER_BASE_IMAGE="${DOCKER_BASE_IMAGE:-haproxytech/haproxy-alpine}:${HAPROXY_VERSION}"
2323
DOCKER_CONTAINER_NAME="dataplaneapi-e2e"
2424
export DOCKER_CONTAINER_NAME

e2e/tests/global/data/haproxy_2.8.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
global
2+
chroot /var/lib/haproxy
3+
user haproxy
4+
group haproxy
5+
maxconn 4000
6+
pidfile /var/run/haproxy.pid
7+
stats socket /var/lib/haproxy/stats level admin
8+
tune.ssl.ocsp-update.mindelay 10
9+
tune.stick-counters 50

e2e/tests/global/get.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ load 'utils/_helpers'
3333
assert_equal "$(get_json_path "$BODY" '.data.pidfile')" "/var/run/haproxy.pid"
3434
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].address')" "/var/lib/haproxy/stats"
3535
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].level')" "admin"
36+
if [[ "$HAPROXY_VERSION" == "2.8" ]]; then
37+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.ssl_ocsp_update_min_delay')" "10"
38+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.stick_counters')" "50"
39+
fi
3640
}

e2e/tests/http_after_response_rules/data/haproxy.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ backend test_backend
3838
balance roundrobin
3939
option forwardfor
4040
http-after-response add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 }
41-
http-after-response del-header X-Del-Backend if { src 10.1.0.0/16 }
41+
http-after-response del-header X-Del-Backend if { src 10.1.0.0/16 }
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
global
2+
chroot /var/lib/haproxy
3+
user haproxy
4+
group haproxy
5+
maxconn 4000
6+
pidfile /var/run/haproxy.pid
7+
stats socket /var/lib/haproxy/stats level admin
8+
log 127.0.0.1 local2
9+
10+
defaults
11+
mode http
12+
maxconn 3000
13+
log global
14+
option httplog
15+
option redispatch
16+
option dontlognull
17+
option http-server-close
18+
option forwardfor except 127.0.0.0/8
19+
timeout http-request 10s
20+
timeout check 10s
21+
timeout connect 10s
22+
timeout client 1m
23+
timeout queue 1m
24+
timeout server 1m
25+
timeout http-keep-alive 10s
26+
retries 3
27+
28+
frontend test_frontend
29+
mode http
30+
bind :80
31+
maxconn 1000
32+
option httpclose
33+
http-after-response add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 }
34+
http-after-response del-header X-Del-Frontend if { src 10.1.0.0/16 }
35+
http-after-response set-map(map.lst) %[src] %[res.hdr(X-Value)]
36+
http-after-response del-map(map.lst) %[src] if FALSE
37+
http-after-response del-acl(map.lst) %[src] if FALSE
38+
http-after-response sc-inc-gpc(0,1) if FALSE
39+
http-after-response sc-inc-gpc0(0) if FALSE
40+
http-after-response sc-inc-gpc1(0) if FALSE
41+
http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE
42+
http-after-response sc-set-gpt0(1) 20 if FALSE
43+
http-after-response set-log-level silent if FALSE
44+
45+
backend test_backend
46+
mode http
47+
balance roundrobin
48+
option forwardfor
49+
http-after-response add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 }
50+
http-after-response del-header X-Del-Backend if { src 10.1.0.0/16 }

e2e/tests/http_after_response_rules/delete.bats

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,54 @@ load 'utils/_helpers'
3939
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
4040
assert_equal "$SC" 204
4141
#
42-
# No more HTTP after response rules, not found!
42+
if [[ "$HAPROXY_VERSION" == "2.8" ]]; then
43+
# Deleting the third one
44+
#
45+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
46+
assert_equal "$SC" 204
47+
#
48+
# Deleting the fourth one
49+
#
50+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
51+
assert_equal "$SC" 204
52+
#
53+
# Deleting the fifth one
54+
#
55+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
56+
assert_equal "$SC" 204
57+
#
58+
# Deleting the sixth one
59+
#
60+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
61+
assert_equal "$SC" 204
62+
#
63+
# Deleting the seventh one
64+
#
65+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
66+
assert_equal "$SC" 204
67+
#
68+
# Deleting the eighth one
69+
#
70+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
71+
assert_equal "$SC" 204
72+
#
73+
# Deleting the ninth one
74+
#
75+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
76+
assert_equal "$SC" 204
77+
#
78+
# Deleting the tenth one
79+
#
80+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
81+
assert_equal "$SC" 204
82+
#
83+
# Deleting the eleventh one
84+
#
85+
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
86+
assert_equal "$SC" 204
87+
#
88+
fi
89+
# No more HTTP after response rules, not found!
4390
#
4491
resource_delete "$_RES_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
4592
assert_equal "$SC" 404

e2e/tests/http_after_response_rules/list.bats

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ load 'utils/_helpers'
3030

3131
resource_get "$_RES_RULES_BASE_PATH" "parent_type=frontend&parent_name=test_frontend"
3232
assert_equal "$SC" 200
33-
assert_equal 2 "$(get_json_path "$BODY" ".data | length")"
33+
if [[ "$HAPROXY_VERSION" == "2.8" ]]; then
34+
assert_equal "$(get_json_path "$BODY" ".data | length")" 11
35+
else
36+
assert_equal "$(get_json_path "$BODY" ".data | length")" 2
37+
fi
3438
assert_equal "$(get_json_path "$BODY" ".data[0].type")" "add-header"
3539
assert_equal "$(get_json_path "$BODY" ".data[0].hdr_name")" "X-Add-Frontend"
3640
assert_equal "$(get_json_path "$BODY" ".data[0].cond")" "unless"
@@ -39,6 +43,46 @@ load 'utils/_helpers'
3943
assert_equal "$(get_json_path "$BODY" ".data[1].hdr_name")" "X-Del-Frontend"
4044
assert_equal "$(get_json_path "$BODY" ".data[1].cond")" "if"
4145
assert_equal "$(get_json_path "$BODY" ".data[1].cond_test")" "{ src 10.1.0.0/16 }"
46+
if [[ "$HAPROXY_VERSION" == "2.8" ]]; then
47+
assert_equal "$(get_json_path "$BODY" ".data[2].type")" "set-map"
48+
assert_equal "$(get_json_path "$BODY" ".data[2].map_file")" "map.lst"
49+
assert_equal "$(get_json_path "$BODY" ".data[2].map_keyfmt")" "%[src]"
50+
assert_equal "$(get_json_path "$BODY" ".data[2].map_valuefmt")" "%[res.hdr(X-Value)]"
51+
assert_equal "$(get_json_path "$BODY" ".data[3].type")" "del-map"
52+
assert_equal "$(get_json_path "$BODY" ".data[3].map_file")" "map.lst"
53+
assert_equal "$(get_json_path "$BODY" ".data[3].map_keyfmt")" "%[src]"
54+
assert_equal "$(get_json_path "$BODY" ".data[3].cond")" "if"
55+
assert_equal "$(get_json_path "$BODY" ".data[3].cond_test")" "FALSE"
56+
assert_equal "$(get_json_path "$BODY" ".data[4].type")" "del-acl"
57+
assert_equal "$(get_json_path "$BODY" ".data[4].acl_file")" "map.lst"
58+
assert_equal "$(get_json_path "$BODY" ".data[4].acl_keyfmt")" "%[src]"
59+
assert_equal "$(get_json_path "$BODY" ".data[4].cond")" "if"
60+
assert_equal "$(get_json_path "$BODY" ".data[4].cond_test")" "FALSE"
61+
assert_equal "$(get_json_path "$BODY" ".data[5].type")" "sc-inc-gpc"
62+
assert_equal "$(get_json_path "$BODY" ".data[5].sc_id")" "1"
63+
assert_equal "$(get_json_path "$BODY" ".data[5].cond")" "if"
64+
assert_equal "$(get_json_path "$BODY" ".data[5].cond_test")" "FALSE"
65+
assert_equal "$(get_json_path "$BODY" ".data[6].type")" "sc-inc-gpc0"
66+
assert_equal "$(get_json_path "$BODY" ".data[6].cond")" "if"
67+
assert_equal "$(get_json_path "$BODY" ".data[6].cond_test")" "FALSE"
68+
assert_equal "$(get_json_path "$BODY" ".data[7].type")" "sc-inc-gpc1"
69+
assert_equal "$(get_json_path "$BODY" ".data[7].cond")" "if"
70+
assert_equal "$(get_json_path "$BODY" ".data[7].cond_test")" "FALSE"
71+
assert_equal "$(get_json_path "$BODY" ".data[8].type")" "sc-set-gpt0"
72+
assert_equal "$(get_json_path "$BODY" ".data[8].sc_id")" "1"
73+
assert_equal "$(get_json_path "$BODY" ".data[8].sc_expr")" "hdr(Host),lower"
74+
assert_equal "$(get_json_path "$BODY" ".data[8].cond")" "if"
75+
assert_equal "$(get_json_path "$BODY" ".data[8].cond_test")" "FALSE"
76+
assert_equal "$(get_json_path "$BODY" ".data[9].type")" "sc-set-gpt0"
77+
assert_equal "$(get_json_path "$BODY" ".data[9].sc_id")" "1"
78+
assert_equal "$(get_json_path "$BODY" ".data[9].sc_int")" "20"
79+
assert_equal "$(get_json_path "$BODY" ".data[9].cond")" "if"
80+
assert_equal "$(get_json_path "$BODY" ".data[9].cond_test")" "FALSE"
81+
assert_equal "$(get_json_path "$BODY" ".data[10].type")" "set-log-level"
82+
assert_equal "$(get_json_path "$BODY" ".data[10].log_level")" "silent"
83+
assert_equal "$(get_json_path "$BODY" ".data[10].cond")" "if"
84+
assert_equal "$(get_json_path "$BODY" ".data[10].cond_test")" "FALSE"
85+
fi
4286
}
4387

4488
@test "http_after_response_rules: Return one HTTP After Response Rule from backend" {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
global
2+
chroot /var/lib/haproxy
3+
user haproxy
4+
group haproxy
5+
maxconn 4000
6+
pidfile /var/run/haproxy.pid
7+
stats socket /var/lib/haproxy/stats level admin
8+
log 127.0.0.1 local2
9+
10+
defaults
11+
mode http
12+
maxconn 3000
13+
log global
14+
option httplog
15+
option redispatch
16+
option dontlognull
17+
option http-server-close
18+
option forwardfor except 127.0.0.0/8
19+
timeout http-request 10s
20+
timeout check 10s
21+
timeout connect 10s
22+
timeout client 1m
23+
timeout queue 1m
24+
timeout server 1m
25+
timeout http-keep-alive 10s
26+
retries 3
27+
28+
frontend test_frontend
29+
mode http
30+
bind :80
31+
maxconn 1000
32+
option httpclose
33+
http-request add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 }
34+
http-request del-header X-Del-Frontend if { src 10.1.0.0/16 }
35+
http-request sc-add-gpc(0,1) 1 if FALSE
36+
37+
backend test_backend
38+
mode http
39+
balance roundrobin
40+
option forwardfor
41+
http-request add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 }
42+
http-request del-header X-Del-Backend if { src 10.1.0.0/16 }

e2e/tests/http_request_rules/delete.bats

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,21 @@ load 'utils/_helpers'
2727
#
2828
# Deleting first
2929
#
30-
resource_delete "$_REQ_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
30+
resource_delete "$_REQ_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
3131
assert_equal "$SC" 204
32-
#
32+
#
3333
# Deleting second
3434
#
3535
resource_delete "$_REQ_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
3636
assert_equal "$SC" 204
37-
#
37+
#
38+
if [[ "$HAPROXY_VERSION" == "2.8" ]]; then
39+
# Deleting third
40+
#
41+
resource_delete "$_REQ_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"
42+
assert_equal "$SC" 204
43+
#
44+
fi
3845
# Not found
3946
#
4047
resource_delete "$_REQ_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true"

e2e/tests/http_request_rules/list.bats

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,40 @@ load '../../libs/version'
2424
load 'utils/_helpers'
2525

2626
@test "http_request_rules: Return an array of all HTTP Request Rules from frontend" {
27-
resource_get "$_REQ_RULES_BASE_PATH" "parent_type=frontend&parent_name=test_frontend"
28-
assert_equal "$SC" 200
29-
assert_equal 2 "$(get_json_path "$BODY" ".data | length")"
30-
assert_equal "$(get_json_path "$BODY" ".data[0].type")" "add-header"
27+
resource_get "$_REQ_RULES_BASE_PATH" "parent_type=frontend&parent_name=test_frontend"
28+
assert_equal "$SC" 200
29+
if [[ "$HAPROXY_VERSION" == "2.8" ]]; then
30+
assert_equal "$(get_json_path "$BODY" ".data | length")" 3
31+
else
32+
assert_equal "$(get_json_path "$BODY" ".data | length")" 2
33+
fi
34+
assert_equal "$(get_json_path "$BODY" ".data[0].type")" "add-header"
3135
assert_equal "$(get_json_path "$BODY" ".data[0].hdr_name")" "X-Add-Frontend"
3236
assert_equal "$(get_json_path "$BODY" ".data[0].cond")" "unless"
3337
assert_equal "$(get_json_path "$BODY" ".data[0].cond_test")" "{ src 192.168.0.0/16 }"
34-
assert_equal "$(get_json_path "$BODY" ".data[1].type")" "del-header"
38+
assert_equal "$(get_json_path "$BODY" ".data[1].type")" "del-header"
3539
assert_equal "$(get_json_path "$BODY" ".data[1].hdr_name")" "X-Del-Frontend"
3640
assert_equal "$(get_json_path "$BODY" ".data[1].cond")" "if"
3741
assert_equal "$(get_json_path "$BODY" ".data[1].cond_test")" "{ src 10.1.0.0/16 }"
42+
if [[ "$HAPROXY_VERSION" == "2.8" ]]; then
43+
assert_equal "$(get_json_path "$BODY" ".data[2].type")" "sc-add-gpc"
44+
assert_equal "$(get_json_path "$BODY" ".data[2].index")" "2"
45+
assert_equal "$(get_json_path "$BODY" ".data[2].sc_id")" "1"
46+
assert_equal "$(get_json_path "$BODY" ".data[2].sc_int")" "1"
47+
assert_equal "$(get_json_path "$BODY" ".data[2].cond")" "if"
48+
assert_equal "$(get_json_path "$BODY" ".data[2].cond_test")" "FALSE"
49+
fi
3850
}
3951

4052
@test "http_request_rules: Return one HTTP Request Rule from backend" {
41-
resource_get "$_REQ_RULES_BASE_PATH" "parent_type=backend&parent_name=test_backend"
53+
resource_get "$_REQ_RULES_BASE_PATH" "parent_type=backend&parent_name=test_backend"
4254
assert_equal "$SC" 200
4355
assert_equal 2 "$(get_json_path "$BODY" ".data | length")"
44-
assert_equal "$(get_json_path "$BODY" ".data[0].type")" "add-header"
56+
assert_equal "$(get_json_path "$BODY" ".data[0].type")" "add-header"
4557
assert_equal "$(get_json_path "$BODY" ".data[0].hdr_name")" "X-Add-Backend"
4658
assert_equal "$(get_json_path "$BODY" ".data[0].cond")" "unless"
4759
assert_equal "$(get_json_path "$BODY" ".data[0].cond_test")" "{ src 192.168.0.0/16 }"
48-
assert_equal "$(get_json_path "$BODY" ".data[1].type")" "del-header"
60+
assert_equal "$(get_json_path "$BODY" ".data[1].type")" "del-header"
4961
assert_equal "$(get_json_path "$BODY" ".data[1].hdr_name")" "X-Del-Backend"
5062
assert_equal "$(get_json_path "$BODY" ".data[1].cond")" "if"
5163
assert_equal "$(get_json_path "$BODY" ".data[1].cond_test")" "{ src 10.1.0.0/16 }"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
global
2+
chroot /var/lib/haproxy
3+
user haproxy
4+
group haproxy
5+
maxconn 4000
6+
pidfile /var/run/haproxy.pid
7+
stats socket /var/lib/haproxy/stats level admin
8+
log 127.0.0.1 local2
9+
10+
defaults
11+
mode http
12+
maxconn 3000
13+
log global
14+
option httplog
15+
option redispatch
16+
option dontlognull
17+
option http-server-close
18+
option forwardfor except 127.0.0.0/8
19+
timeout http-request 10s
20+
timeout check 10s
21+
timeout connect 10s
22+
timeout client 1m
23+
timeout queue 1m
24+
timeout server 1m
25+
timeout http-keep-alive 10s
26+
retries 3
27+
28+
frontend test_frontend
29+
mode http
30+
bind :80
31+
maxconn 1000
32+
option httpclose
33+
http-response add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 }
34+
http-response del-header X-Del-Frontend if { src 10.1.0.0/16 }
35+
http-response sc-add-gpc(0,1) 1 if FALSE
36+
37+
backend test_backend
38+
mode http
39+
balance roundrobin
40+
option forwardfor
41+
http-response add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 }
42+
http-response del-header X-Del-Backend if { src 10.1.0.0/16 }

0 commit comments

Comments
 (0)