Added LUA requirement into the test..

Op 23-12-2018 om 23:05 schreef PiBa-NL:
Hi Frederic,

As requested hereby the regtest send for inclusion into the git repository. Without randomization and with your .diff applied. Also outputting expected and actual checksum if the test fails so its clear that that is the issue detected.

Is it okay like this? Should the blob be bigger? As you mentioned needing a 10MB output to reproduce the original issue on your machine?

Regards,

PiBa-NL (Pieter)


From 29c3b9d344f360503bcd30f48558ca8a51df92ed Mon Sep 17 00:00:00 2001
From: PiBa-NL <piba.nl....@gmail.com>
Date: Sun, 23 Dec 2018 21:21:51 +0100
Subject: [PATCH] REGTEST: filters: add compression test

This test checks that data transferred with compression is correctly received 
at different download speeds
---
 reg-tests/filters/b00005.lua | 19 ++++++++++++
 reg-tests/filters/b00005.vtc | 59 ++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
 create mode 100644 reg-tests/filters/b00005.lua
 create mode 100644 reg-tests/filters/b00005.vtc

diff --git a/reg-tests/filters/b00005.lua b/reg-tests/filters/b00005.lua
new file mode 100644
index 00000000..6dbe1d33
--- /dev/null
+++ b/reg-tests/filters/b00005.lua
@@ -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)
diff --git a/reg-tests/filters/b00005.vtc b/reg-tests/filters/b00005.vtc
new file mode 100644
index 00000000..2f4982cb
--- /dev/null
+++ b/reg-tests/filters/b00005.vtc
@@ -0,0 +1,59 @@
+# Checks that compression doesnt cause corruption..
+
+varnishtest "Compression validation"
+#REQUIRE_VERSION=1.6
+#REQUIRE_OPTIONS=LUA
+
+feature ignore_unknown_macro
+
+haproxy h1 -conf {
+global
+#      log stdout format short daemon 
+       lua-load                ${testdir}/b00005.lua
+
+defaults
+       mode                    http
+       log                     global
+       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 --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
-- 
2.18.0.windows.1

Reply via email to