mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-10 21:38:16 +00:00
REGTESTS: add a basic reg-test for some "set-var" commands
This reg-test tests "set-var" in the global section, with some overlapping variables and using a few samples and converters, then at the TCP and HTTP levels using proc/sess/req variables.
This commit is contained in:
parent
13d2ba2a82
commit
9fdf342ca9
51
reg-tests/sample_fetches/vars.vtc
Normal file
51
reg-tests/sample_fetches/vars.vtc
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
varnishtest "Test a few set-var() in global, tcp and http rule sets, at different scopes"
|
||||||
|
#REQUIRE_VERSION=2.4
|
||||||
|
|
||||||
|
feature ignore_unknown_macro
|
||||||
|
|
||||||
|
haproxy h1 -conf {
|
||||||
|
global
|
||||||
|
set-var proc.int12 int(12)
|
||||||
|
set-var proc.int5 str(60),div(proc.int12)
|
||||||
|
set-var proc.str str("this is")
|
||||||
|
set-var proc.str str(""),concat("",proc.str," a string")
|
||||||
|
set-var proc.uuid uuid()
|
||||||
|
|
||||||
|
defaults
|
||||||
|
mode http
|
||||||
|
timeout connect 1s
|
||||||
|
timeout client 1s
|
||||||
|
timeout server 1s
|
||||||
|
|
||||||
|
frontend fe1
|
||||||
|
bind "fd@${fe1}"
|
||||||
|
tcp-request session set-var(sess.int5) var(proc.int5)
|
||||||
|
tcp-request session set-var(proc.int5) var(proc.int5),add(sess.int5) ## proc. becomes 10
|
||||||
|
http-request set-var(req.int5) var(sess.int5)
|
||||||
|
http-request set-var(sess.int5) var(sess.int5),add(req.int5) ## sess. becomes 10 first time, then 15...
|
||||||
|
http-request return status 200 hdr x-var "proc=%[var(proc.int5)] sess=%[var(sess.int5)] req=%[var(req.int5)] str=%[var(proc.str)] uuid=%[var(proc.uuid)]"
|
||||||
|
} -start
|
||||||
|
|
||||||
|
client c1 -connect ${h1_fe1_sock} {
|
||||||
|
txreq -req GET -url /req1_1
|
||||||
|
rxresp
|
||||||
|
expect resp.status == 200
|
||||||
|
expect resp.http.x-var ~ "proc=10 sess=10 req=5 str=this is a string uuid=[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*"
|
||||||
|
|
||||||
|
txreq -req GET -url /req1_2
|
||||||
|
rxresp
|
||||||
|
expect resp.status == 200
|
||||||
|
expect resp.http.x-var ~ "proc=10 sess=20 req=10 str=this is a string uuid=[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*"
|
||||||
|
} -run
|
||||||
|
|
||||||
|
client c2 -connect ${h1_fe1_sock} {
|
||||||
|
txreq -req GET -url /req2_1
|
||||||
|
rxresp
|
||||||
|
expect resp.status == 200
|
||||||
|
expect resp.http.x-var ~ "proc=20 sess=20 req=10 str=this is a string uuid=[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*"
|
||||||
|
|
||||||
|
txreq -req GET -url /req2_2
|
||||||
|
rxresp
|
||||||
|
expect resp.status == 200
|
||||||
|
expect resp.http.x-var ~ "proc=20 sess=40 req=20 str=this is a string uuid=[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*"
|
||||||
|
} -run
|
Loading…
Reference in New Issue
Block a user