[nginx-tests] Tests: adjusted limit_rate tests for leaky bucket ...
Maxim Dounin
mdounin at mdounin.ru
Thu Jun 19 02:40:18 UTC 2025
details: http://freenginx.org/hg/nginx-tests/rev/25cf08cb2bf8
branches:
changeset: 2010:25cf08cb2bf8
user: Maxim Dounin <mdounin at mdounin.ru>
date: Thu Jun 12 17:50:38 2025 +0300
description:
Tests: adjusted limit_rate tests for leaky bucket implementation.
Previously, stream limit_rate tests were quite dependant on the particular
limit_rate implementation. Relaxed testing so it would also succeed
with the upcoming leaky bucket implementation, and described high-level
requirements in the comment instead of the behaviour of the old
implementation.
Similarly, comment in proxy_limit_rate.t was replaced with a high-level
description instead of an (incorrect) description of the behaviour of
the old implementation.
diffstat:
proxy_limit_rate.t | 3 ++-
stream_limit_rate.t | 9 ++++-----
stream_limit_rate2.t | 9 ++++-----
3 files changed, 10 insertions(+), 11 deletions(-)
diffs (67 lines):
diff --git a/proxy_limit_rate.t b/proxy_limit_rate.t
--- a/proxy_limit_rate.t
+++ b/proxy_limit_rate.t
@@ -78,7 +78,8 @@ my $r = http_get('/');
my ($t1) = $r =~ /X-Msec: (\d+)/;
my $diff = time() - $t1;
-# four chunks are split with three 1s delays
+# reading 40000 byte response with proxy_limit_rate 20000
+# should take at least 1 second
cmp_ok($diff, '>=', 1, 'proxy_limit_rate');
like($r, qr/^(XXXXXXXXXX){4000}\x0d?\x0a?$/m, 'response body');
diff --git a/stream_limit_rate.t b/stream_limit_rate.t
--- a/stream_limit_rate.t
+++ b/stream_limit_rate.t
@@ -120,19 +120,18 @@ is($r{'data'}, '1', 'upload - one byte')
}
-# Five chunks are split with four 1s delays:
-# the first four chunks are quarters of test string
-# and the fifth one is some extra data from backend.
+# reading 1000+ byte response with proxy_download_rate 250
+# should take at least 3 seconds
%r = response($str, peer => '127.0.0.1:' . port(8085));
my $diff = time() - $r{'time'};
-cmp_ok($diff, '>=', 4, 'download - time');
+cmp_ok($diff, '>=', 3, 'download - time');
is($r{'data'}, $str, 'download - data');
my $time = time();
%r = response($str . 'close', peer => '127.0.0.1:' . port(8086));
$diff = time() - $time;
-cmp_ok($diff, '>=', 4, 'upload - time');
+cmp_ok($diff, '>=', 3, 'upload - time');
is($r{'data'}, $str . 'close', 'upload - data');
###############################################################################
diff --git a/stream_limit_rate2.t b/stream_limit_rate2.t
--- a/stream_limit_rate2.t
+++ b/stream_limit_rate2.t
@@ -134,19 +134,18 @@ is($r{'data'}, '1', 'upload - one byte')
}
-# Five chunks are split with four 1s delays:
-# the first four chunks are quarters of test string
-# and the fifth one is some extra data from backend.
+# reading 1000+ byte response with proxy_download_rate 250
+# should take at least 3 seconds
%r = response($str, peer => '127.0.0.1:' . port(8085));
my $diff = time() - $r{'time'};
-cmp_ok($diff, '>=', 4, 'download - time');
+cmp_ok($diff, '>=', 3, 'download - time');
is($r{'data'}, $str, 'download - data');
my $time = time();
%r = response($str . 'close', peer => '127.0.0.1:' . port(8086));
$diff = time() - $time;
-cmp_ok($diff, '>=', 4, 'upload - time');
+cmp_ok($diff, '>=', 3, 'upload - time');
is($r{'data'}, $str . 'close', 'upload - data');
###############################################################################
More information about the nginx-devel
mailing list