TESTS: move tests/*.cfg to tests/config

These are a collection of test files for a variety of features (old or
more recent). 2 or 3 files were found lying there non-committed and
were moved at the same time. A few deprecated or obsolete keywords were
updated to their recent equivalent. Many of these configurations are
made to trigger different parsing errors so it is normal that plenty
of them fail.

Now the tests directory is cleaner and easier to navigate through.
This commit is contained in:
Willy Tarreau 2021-04-02 10:49:34 +02:00
parent 38ceb554fd
commit d4359fd98b
40 changed files with 5266 additions and 75 deletions

View File

@ -0,0 +1,34 @@
global
maxconn 500
external-check
stats socket /tmp/sock1 mode 666 level admin
defaults
timeout client 5s
timeout server 5s
timeout connect 5s
mode http
listen stats
bind :8888
stats uri /
backend tcp9000
option httpchk
server srv 127.0.0.1:9000 check inter 1s
backend tcp9001
option httpchk
server srv 127.0.0.1:9001 check inter 1s ssl verify none
backend tcp9006
option httpchk
server srv 10.0.0.0:9006 check inter 1s verify none
backend ssh
server blah 127.0.0.1:22 check inter 1s
frontend dummy
#mode http
bind :9000-9004

26
tests/conf/setstatus.lua Normal file
View File

@ -0,0 +1,26 @@
-- http-response actions
core.register_action("set-status-418-defaultreason", {"http-res"}, function(txn)
txn.http:res_set_status(418)
end)
core.register_action("set-status-418-customreason", {"http-res"}, function(txn)
txn.http:res_set_status(418, "I'm a coffeepot")
end)
-- http services
core.register_service("http418-default", "http", function(applet)
local response = "Hello World !"
applet:set_status(418)
applet:add_header("content-length", string.len(response))
applet:add_header("content-type", "text/plain")
applet:start_response()
applet:send(response)
end)
core.register_service("http418-coffeepot", "http", function(applet)
local response = "Hello World !"
applet:set_status(418, "I'm a coffeepot")
applet:add_header("content-length", string.len(response))
applet:add_header("content-type", "text/plain")
applet:start_response()
applet:send(response)
end)

View File

@ -12,25 +12,25 @@ frontend 1
bind :10000 bind :10000
# missing fetch method in ACL expression '(arg)'. # missing fetch method in ACL expression '(arg)'.
block if { (arg) } http-request deny if { (arg) }
# unknown fetch method 'blah' in ACL expression 'blah(arg)'. # unknown fetch method 'blah' in ACL expression 'blah(arg)'.
block if { blah(arg) } http-request deny if { blah(arg) }
# missing closing ')' after arguments to fetch keyword 'req.hdr' in ACL expression 'req.hdr('. # missing closing ')' after arguments to fetch keyword 'req.hdr' in ACL expression 'req.hdr('.
block if { req.hdr( } http-request deny if { req.hdr( }
# cannot be triggered : "returns type of fetch method '%s' is unknown" # cannot be triggered : "returns type of fetch method '%s' is unknown"
# fetch method 'always_true' : no argument supported, but got 'arg' in ACL expression 'always_true(arg)'. # fetch method 'always_true' : no argument supported, but got 'arg' in ACL expression 'always_true(arg)'.
block if { always_true(arg) } http-request deny if { always_true(arg) }
# fetch method 'req.hdr' : failed to parse 'a' as type 'signed integer' at position 2 in ACL expression 'req.hdr(a,a)'. # fetch method 'req.hdr' : failed to parse 'a' as type 'signed integer' at position 2 in ACL expression 'req.hdr(a,a)'.
block if { req.hdr(a,a) } http-request deny if { req.hdr(a,a) }
# in argument to 'payload_lv', payload length must be > 0. # in argument to 'payload_lv', payload length must be > 0.
block if { payload_lv(0,0) } http-request deny if { payload_lv(0,0) }
# ACL keyword 'payload_lv' : expected type 'unsigned integer' at position 1, but got nothing. # ACL keyword 'payload_lv' : expected type 'unsigned integer' at position 1, but got nothing.
block if { payload_lv } http-request deny if { payload_lv }

View File

@ -5,9 +5,9 @@ global
defaults defaults
mode http mode http
contimeout 50s timeout connect 50s
clitimeout 50s timeout client 50s
srvtimeout 50s timeout server 50s
frontend b11 :11000,:11001 frontend b11 :11000,:11001

View File

@ -15,28 +15,28 @@ listen httpclose
option httpclose option httpclose
bind :8001 bind :8001
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd X-request:\ mode=httpclose http-request add-header X-request mode=httpclose
rspadd X-response:\ mode=httpclose http-response add-header X-response mode=httpclose
listen server-close listen server-close
option http-server-close option http-server-close
bind :8002 bind :8002
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd X-request:\ mode=server-close http-request add-header X-request mode=server-close
rspadd X-response:\ mode=server-close http-response add-header X-response mode=server-close
listen httpclose_server-close listen httpclose_server-close
option httpclose option httpclose
option http-server-close option http-server-close
bind :8003 bind :8003
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd X-request:\ mode=httpclose+server-close http-request add-header X-request mode=httpclose+server-close
rspadd X-response:\ mode=httpclose+server-close http-response add-header X-response mode=httpclose+server-close
listen forceclose listen forceclose
option forceclose option forceclose
bind :8004 bind :8004
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd X-request:\ mode=forceclose http-request add-header X-request mode=forceclose
rspadd X-response:\ mode=forceclose http-response add-header X-response mode=forceclose

View File

@ -38,10 +38,10 @@ listen test
listen s1 listen s1
bind 127.0.0.1:8001 bind 127.0.0.1:8001
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s1 http-request add-header x-haproxy-used s1
listen s2 listen s2
bind 127.0.0.1:8002 bind 127.0.0.1:8002
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s2 http-request add-header x-haproxy-used s2

View File

@ -26,10 +26,10 @@ listen test
listen s1 listen s1
bind 127.0.0.1:8001 bind 127.0.0.1:8001
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s1 http-request add-header x-haproxy-used s1
listen s2 listen s2
bind 127.0.0.1:8002 bind 127.0.0.1:8002
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s2 http-request add-header x-haproxy-used s2

View File

@ -26,10 +26,10 @@ listen test
listen s1 listen s1
bind 127.0.0.1:8001 bind 127.0.0.1:8001
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s1 http-request add-header x-haproxy-used s1
listen s2 listen s2
bind 127.0.0.1:8002 bind 127.0.0.1:8002
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s2 http-request add-header x-haproxy-used s2

View File

@ -26,10 +26,10 @@ listen test
listen s1 listen s1
bind 127.0.0.1:8001 bind 127.0.0.1:8001
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s1 http-request add-header x-haproxy-used s1
listen s2 listen s2
bind 127.0.0.1:8002 bind 127.0.0.1:8002
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s2 http-request add-header x-haproxy-used s2

View File

@ -26,10 +26,10 @@ listen test
listen s1 listen s1
bind 127.0.0.1:8001 bind 127.0.0.1:8001
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s1 http-request add-header x-haproxy-used s1
listen s2 listen s2
bind 127.0.0.1:8002 bind 127.0.0.1:8002
server srv 127.0.0.1:8080 server srv 127.0.0.1:8080
reqadd x-haproxy-used:\ s2 http-request add-header x-haproxy-used s2

View File

@ -36,10 +36,10 @@ global
listen sample1 listen sample1
mode http mode http
retries 1 retries 1
redispatch option redispatch
contimeout 1000 timeout connect 1000
clitimeout 5000 timeout client 5000
srvtimeout 5000 timeout server 5000
maxconn 40000 maxconn 40000
bind :8080 bind :8080
cookie SRV insert indirect nocache cookie SRV insert indirect nocache

View File

@ -30,10 +30,10 @@ global
listen sample1 listen sample1
mode tcp mode tcp
retries 1 retries 1
redispatch option redispatch
contimeout 1000 timeout connect 1000
clitimeout 120000 timeout client 120000
srvtimeout 120000 timeout server 120000
maxconn 40000 maxconn 40000
bind :8080 bind :8080
balance leastconn balance leastconn
@ -48,11 +48,11 @@ listen sample1
server bck4 127.0.0.8:80 weight 40 check inter 1000 fall 1 backup server bck4 127.0.0.8:80 weight 40 check inter 1000 fall 1 backup
option httpclose option httpclose
listen sample1 listen sample2
mode http mode http
contimeout 1000 timeout connect 1000
clitimeout 50000 timeout client 50000
srvtimeout 50000 timeout server 50000
maxconn 40000 maxconn 40000
bind :8081 bind :8081
balance leastconn balance leastconn

View File

@ -30,10 +30,10 @@ global
listen sample1 listen sample1
mode http mode http
retries 1 retries 1
redispatch option redispatch
contimeout 1000 timeout connect 1000
clitimeout 5000 timeout client 5000
srvtimeout 5000 timeout server 5000
maxconn 40000 maxconn 40000
bind :8080 bind :8080
balance roundrobin balance roundrobin

View File

@ -17,8 +17,8 @@ listen send-name-silo-id
server srv-silo1 127.0.0.1:8080 server srv-silo1 127.0.0.1:8080
# Add headers containing the correct values for test verification # Add headers containing the correct values for test verification
reqadd X-test-server-name-header:\ X-Silo-Id http-request add-header X-test-server-name-header X-Silo-Id
reqadd X-test-server-name-value:\ srv-silo1 http-request add-header X-test-server-name-value srv-silo1
listen send-name-host listen send-name-host
bind :8002 bind :8002
@ -28,6 +28,6 @@ listen send-name-host
server srv-host 127.0.0.1:8080 server srv-host 127.0.0.1:8080
# Add headers containing the correct values for test verification # Add headers containing the correct values for test verification
reqadd X-test-server-name-header:\ Host http-request add-header X-test-server-name-header Host
reqadd X-test-server-name-value:\ srv-host http-request add-header X-test-server-name-value srv-host

View File

@ -0,0 +1,31 @@
global
maxconn 100
lua-load setstatus.lua
defaults
mode http
timeout client 10000
timeout server 10000
timeout connect 10000
# Expect HTTP/1.1 418 I'm a teapot
listen lua-service-set-status-defaultreason
bind :8003
http-request use-service lua.http418-default
# Expect HTTP/1.1 418 I'm a coffeepot
listen lua-service-set-status-customreason
bind :8004
http-request use-service lua.http418-coffeepot
# Expect HTTP/1.1 418 I'm a teapot
listen lua-action-set-status-defaultreason
bind :8005
http-response lua.set-status-418-defaultreason
server host 127.0.0.1:8080
# Expect HTTP/1.1 418 I'm a coffeepot
listen lua-action-set-status-customreason
bind :8006
http-response lua.set-status-418-customreason
server host 127.0.0.1:8080

View File

@ -0,0 +1,32 @@
global
maxconn 100
defaults
mode http
timeout client 10000
timeout server 10000
timeout connect 10000
# Expect HTTP/1.1 418 I'm a teapot
listen http-response-set-status-defaultreason
bind :8001
server host 127.0.0.1:8080
http-response set-status 418
# Expect HTTP/1.1 418 I'm a coffeepot
listen http-response-set-status-customreason
bind :8002
server host 127.0.0.1:8080
http-response set-status 418 reason "I'm a coffeepot"
# Expect config parse fail
#listen parse-fail-string
# bind :8002
# server host 127.0.0.1:8080
# http-response set-status 418 reason
# Expect config parse fail
#listen parse-fail-keyword
# bind :8002
# server host 127.0.0.1:8080
# http-response set-status 418 "Missing reason keyword"

View File

@ -8,9 +8,9 @@ global
defaults defaults
mode tcp mode tcp
clitimeout 15000 timeout client 15000
srvtimeout 15000 timeout server 15000
contimeout 15000 timeout connect 15000
balance roundrobin balance roundrobin
listen fixed listen fixed

View File

@ -0,0 +1,23 @@
# This is a test configuration.
# It exercises the "url_param" balance algorithm. It looks for
# an URL parameter named "foo".
global
maxconn 100
log 127.0.0.1 local0
listen vip1
log global
bind :8000
mode http
maxconn 100
timeout client 5000
timeout connect 5000
timeout server 5000
balance url_param foo
server srv1 127.0.0.1:80
server srv2 127.0.0.1:80
# control activity this way
stats uri /stat

View File

@ -5,9 +5,9 @@ global
maxconn 500 maxconn 500
defaults defaults
contimeout 1000 timeout connect 1000
clitimeout 5000 timeout client 5000
srvtimeout 5000 timeout server 5000
retries 1 retries 1
option redispatch option redispatch

5045
tests/conf/test-stats.cfg Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,10 +8,10 @@ global
listen sample1 listen sample1
mode http mode http
retries 1 retries 1
redispatch option redispatch
contimeout 5s timeout connect 5s
clitimeout 15m timeout client 15m
srvtimeout 15m timeout server 15m
maxconn 40000 maxconn 40000
bind :8080 bind :8080
balance roundrobin balance roundrobin

View File

@ -8,7 +8,7 @@ global
listen sample1 listen sample1
mode http mode http
retries 1 retries 1
redispatch option redispatch
timeout client 15m timeout client 15m
timeout http-request 6s timeout http-request 6s
timeout tarpit 20s timeout tarpit 20s

View File

@ -12,9 +12,9 @@ listen vip1
bind :8000 bind :8000
mode http mode http
maxconn 100 maxconn 100
clitimeout 5000 timeout client 5000
contimeout 5000 timeout connect 5000
srvtimeout 5000 timeout server 5000
balance url_param foo balance url_param foo
server srv1 127.0.0.1:80 server srv1 127.0.0.1:80
server srv2 127.0.0.1:80 server srv2 127.0.0.1:80
@ -28,9 +28,9 @@ listen vip2
bind :8001 bind :8001
mode http mode http
maxconn 100 maxconn 100
clitimeout 5000 timeout client 5000
contimeout 5000 timeout connect 5000
srvtimeout 5000 timeout server 5000
balance url_param foo check_post balance url_param foo check_post
server srv1 127.0.0.1:80 server srv1 127.0.0.1:80
server srv2 127.0.0.1:80 server srv2 127.0.0.1:80

View File

@ -3,35 +3,35 @@
listen valid_listen1 listen valid_listen1
bind :8000 bind :8000
clitimeout 5000 timeout client 5000
contimeout 5000 timeout connect 5000
srvtimeout 5000 timeout server 5000
balance roundrobin balance roundrobin
server srv1 127.0.0.1:80 server srv1 127.0.0.1:80
frontend www.valid-frontend.net:80 frontend www.valid-frontend.net:80
bind :8001 bind :8001
clitimeout 5000 timeout client 5000
acl host_www.valid-frontend.net:80 hdr(host) www.valid-frontend.net acl host_www.valid-frontend.net:80 hdr(host) www.valid-frontend.net
backend Valid_BK-1 backend Valid_BK-1
contimeout 5000 timeout connect 5000
srvtimeout 5000 timeout server 5000
balance roundrobin balance roundrobin
server bk1_srv-1:80 127.0.0.1:80 server bk1_srv-1:80 127.0.0.1:80
frontend www.test-frontend.net:8002/invalid frontend www.test-frontend.net:8002/invalid
bind :8002 bind :8002
clitimeout 5000 timeout client 5000
frontend ft1_acl frontend ft1_acl
bind :8003 bind :8003
clitimeout 5000 timeout client 5000
acl invalid!name url / acl invalid!name url /
backend bk2_srv backend bk2_srv
contimeout 5000 timeout connect 5000
srvtimeout 5000 timeout server 5000
balance roundrobin balance roundrobin
server bk2/srv-1 127.0.0.1:80 server bk2/srv-1 127.0.0.1:80