From 94fd1339e71d699c1c9366500e087e13b3e9bed7 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 12 May 2021 10:51:22 +0200 Subject: [PATCH] REGTESTS: stick-table: add src_conn_rate test Add a simple test which uses src_conn_rate stick table fetch. Limit the connection rate to 3. The 4th connection should return a 403. --- reg-tests/stick-table/src_conn_rate.vtc | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 reg-tests/stick-table/src_conn_rate.vtc diff --git a/reg-tests/stick-table/src_conn_rate.vtc b/reg-tests/stick-table/src_conn_rate.vtc new file mode 100644 index 0000000..7078213 --- /dev/null +++ b/reg-tests/stick-table/src_conn_rate.vtc @@ -0,0 +1,44 @@ +varnishtest "stick table: src_conn_rate" +feature ignore_unknown_macro + +haproxy h0 -conf { + defaults + mode http + timeout connect 5s + timeout client 5s + timeout server 5s + + listen li + ${no-htx} option http-use-htx + bind "fd@${fe1}" + http-request track-sc0 src table conn_rate_table + http-request deny if { src_conn_rate(conn_rate_table) gt 3 } + http-request return status 200 + + backend conn_rate_table + stick-table type ip size 1m expire 1m store conn_rate(1m) +} -start + +client c0 -connect ${h0_fe1_addr}:${h0_fe1_port} { + txreq + rxresp + expect resp.status == 200 +} -run + +client c1 -connect ${h0_fe1_addr}:${h0_fe1_port} { + txreq + rxresp + expect resp.status == 200 +} -run + +client c2 -connect ${h0_fe1_addr}:${h0_fe1_port} { + txreq + rxresp + expect resp.status == 200 +} -run + +client c3 -connect ${h0_fe1_addr}:${h0_fe1_port} { + txreq + rxresp + expect resp.status == 403 +} -run -- 1.7.10.4