aboutsummaryrefslogtreecommitdiff
path: root/tests/ratef.at
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ratef.at')
-rw-r--r--tests/ratef.at61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/ratef.at b/tests/ratef.at
new file mode 100644
index 0000000..d0dc7ea
--- /dev/null
+++ b/tests/ratef.at
@@ -0,0 +1,61 @@
+# This file is part of vmod-tbf
+# Copyright (C) 2013-2017 Sergey Poznyakoff
+#
+# Vmod-tbf is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Vmod-tbf is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([rate flow])
+AT_KEYWORDS([ratef flow])
+AT_VARNISHTEST([tbf],[
+ sub vcl_deliver {
+ set resp.http.result = tbf.rate("url:"+req.url, 1, 1s, 5);
+ }
+],
+[ txreq -url "/"
+ rxresp
+ expect resp.http.result == true
+
+ txreq -url "/"
+ rxresp
+ expect resp.http.result == true
+
+ txreq -url "/"
+ rxresp
+ expect resp.http.result == true
+
+ txreq -url "/"
+ rxresp
+ expect resp.http.result == true
+
+ txreq -url "/"
+ rxresp
+ expect resp.http.result == true
+
+ txreq -url "/"
+ rxresp
+ expect resp.http.result == false
+
+ delay 1.0
+
+ txreq -url "/"
+ rxresp
+ expect resp.http.result == true
+
+ txreq -url "/"
+ rxresp
+ expect resp.http.result == false
+],
+[ rxreq
+ txresp
+])
+AT_CLEANUP

Return to:

Send suggestions and report system problems to the System administrator.