mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
REGTEST: filters: add compression test
This test checks that data transferred with compression is correctly received at different download speeds
This commit is contained in:
parent
4b0e9b2870
commit
4dc3f3b4bb
1
reg-tests/compression/common.pem
Symbolic link
1
reg-tests/compression/common.pem
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../ssl/common.pem
|
19
reg-tests/compression/s00000.lua
Normal file
19
reg-tests/compression/s00000.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
local data = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
local responseblob = ""
|
||||||
|
for i = 1,10000 do
|
||||||
|
responseblob = responseblob .. "\r\n" .. i .. data:sub(1, math.floor(i % 27))
|
||||||
|
end
|
||||||
|
|
||||||
|
http01applet = function(applet)
|
||||||
|
local response = responseblob
|
||||||
|
applet:set_status(200)
|
||||||
|
applet:add_header("Content-Type", "application/javascript")
|
||||||
|
applet:add_header("Content-Length", string.len(response)*10)
|
||||||
|
applet:start_response()
|
||||||
|
for i = 1,10 do
|
||||||
|
applet:send(response)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
core.register_service("fileloader-http01", "http", http01applet)
|
60
reg-tests/compression/s00000.vtc
Normal file
60
reg-tests/compression/s00000.vtc
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# Checks that compression doesnt cause corruption..
|
||||||
|
|
||||||
|
varnishtest "Compression validation"
|
||||||
|
#REQUIRE_VERSION=1.6
|
||||||
|
#REQUIRE_OPTIONS=ZLIB|SLZ,LUA
|
||||||
|
|
||||||
|
feature ignore_unknown_macro
|
||||||
|
|
||||||
|
haproxy h1 -conf {
|
||||||
|
global
|
||||||
|
# log stdout format short daemon
|
||||||
|
lua-load ${testdir}/s00000.lua
|
||||||
|
|
||||||
|
defaults
|
||||||
|
mode http
|
||||||
|
log global
|
||||||
|
${no-htx} option http-use-htx
|
||||||
|
option httplog
|
||||||
|
|
||||||
|
frontend main-https
|
||||||
|
bind "fd@${fe1}" ssl crt ${testdir}/common.pem
|
||||||
|
compression algo gzip
|
||||||
|
compression type text/html text/plain application/json application/javascript
|
||||||
|
compression offload
|
||||||
|
use_backend TestBack if TRUE
|
||||||
|
|
||||||
|
backend TestBack
|
||||||
|
server LocalSrv ${h1_fe2_addr}:${h1_fe2_port}
|
||||||
|
|
||||||
|
listen fileloader
|
||||||
|
mode http
|
||||||
|
bind "fd@${fe2}"
|
||||||
|
http-request use-service lua.fileloader-http01
|
||||||
|
} -start
|
||||||
|
|
||||||
|
shell {
|
||||||
|
HOST=${h1_fe1_addr}
|
||||||
|
if [ "${h1_fe1_addr}" = "::1" ] ; then
|
||||||
|
HOST="\[::1\]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
md5=$(which md5 || which md5sum)
|
||||||
|
|
||||||
|
if [ -z $md5 ] ; then
|
||||||
|
echo "MD5 checksum utility not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
expectchecksum="4d9c62aa5370b8d5f84f17ec2e78f483"
|
||||||
|
|
||||||
|
for opt in "" "--limit-rate 300K" "--limit-rate 500K" ; do
|
||||||
|
checksum=$(curl --max-time 15 --compressed -k "https://$HOST:${h1_fe1_port}" $opt | $md5 | cut -d ' ' -f1)
|
||||||
|
if [ "$checksum" != "$expectchecksum" ] ; then
|
||||||
|
echo "Expecting checksum $expectchecksum"
|
||||||
|
echo "Received checksum: $checksum"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
} -run
|
Loading…
Reference in New Issue
Block a user