Welcome! Log In Create A New Profile

Advanced

[PATCH] Tests: testing limit_req with "burst=A nodelay=B" configuration

Peter Shchuchkin
October 28, 2018 11:06AM
# HG changeset patch
# User Peter Shchuchkin <peters@yandex.ru>
# Date 1540715681 -10800
# Sun Oct 28 11:34:41 2018 +0300
# Node ID 9c629d98af7d8191f8ec5664b3d6ad33cb870d5c
# Parent 73a9504ae6fd61f75a3983784248b9cc0bd6e6c7
Tests: testing limit_req with "burst=A nodelay=B" configuration

diff -r 73a9504ae6fd -r 9c629d98af7d limit_req.t
--- a/limit_req.t Fri Oct 19 18:49:45 2018 +0300
+++ b/limit_req.t Sun Oct 28 11:34:41 2018 +0300
@@ -21,7 +21,7 @@
select STDERR; $| = 1;
select STDOUT; $| = 1;

-my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(6);
+my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(8);

$t->write_file_expand('nginx.conf', <<'EOF');

@@ -38,6 +38,7 @@
limit_req_zone $binary_remote_addr zone=one:1m rate=2r/s;
limit_req_zone $binary_remote_addr zone=long:1m rate=2r/s;
limit_req_zone $binary_remote_addr zone=fast:1m rate=1000r/s;
+ limit_req_zone $binary_remote_addr zone=mixed:1m rate=10r/s;

server {
listen 127.0.0.1:8080;
@@ -56,6 +57,12 @@
location /fast {
limit_req zone=fast burst=1;
}
+ location /mixed {
+ limit_req zone=mixed burst=2 nodelay=1;
+ }
+ location /mixed-pass {
+ limit_req zone=mixed burst=2 nodelay;
+ }
}
}

@@ -64,6 +71,8 @@
$t->write_file('test1.html', 'XtestX');
$t->write_file('long.html', "1234567890\n" x (1 << 16));
$t->write_file('fast.html', 'XtestX');
+$t->write_file('mixed.html', 'XtestX');
+$t->write_file('mixed-pass.html', 'XtestX');
$t->run();

###############################################################################
@@ -94,4 +103,20 @@
select undef, undef, undef, 0.1;
like(http_get('/fast.html'), qr/^HTTP\/1.. 200 /m, 'negative excess');

+# make sure requests are delayed when 0 < nodelay < burst
+# this test should fail when using nodelay without =number
+
+http_get('/mixed.html');
+http_get('/mixed.html');
+http_get('/mixed.html');
+like(http_get('/mixed.html'), qr/^HTTP\/1.. 200 /m, 'mixed request is not rejected');
+
+# make sure it is possible to partially fill up excess through /mixed.html and get last request rejected
+# this test should fail when using "burst=N" without nodelay
+
+http_get('/mixed.html');
+http_get('/mixed.html');
+http_get('/mixed-pass.html');
+like(http_get('/mixed-pass.html'), qr/^HTTP\/1.. 503 /m, 'mixed request is rejected');
+
###############################################################################
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Allow using nodelay=N semantics in limit_req configuration

Peter Shchuchkin 347 October 28, 2018 11:00AM

[PATCH] Tests: testing limit_req with "burst=A nodelay=B" configuration

Peter Shchuchkin 140 October 28, 2018 11:06AM

Re: [PATCH] Allow using nodelay=N semantics in limit_req configuration

Щучкин Петр 124 October 28, 2018 11:14AM

Re: [PATCH] Allow using nodelay=N semantics in limit_req configuration

Maxim Dounin 120 October 29, 2018 09:00AM

Re: [PATCH] Allow using nodelay=N semantics in limit_req configuration

Щучкин Петр 106 October 29, 2018 10:16AM

Re: [PATCH] Allow using nodelay=N semantics in limit_req configuration

Maxim Dounin 154 October 30, 2018 11:48AM

Re: [PATCH] Allow using nodelay=N semantics in limit_req configuration

Щучкин Петр 113 October 31, 2018 03:46AM

Re: [PATCH] Allow using nodelay=N semantics in limit_req configuration

Maxim Dounin 131 November 21, 2018 12:24PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 117
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready