diff options
author | pkarumanchi9 <prudhviraj9@gmail.com> | 2020-07-09 00:59:44 +0000 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-10-30 15:41:54 -0700 |
commit | 4c0d45a95c9ba8fb8ea0630b96f4e006ef1698a1 (patch) | |
tree | b4f7a33e7f7ad7a80bdafedfb5d5bdea901cbb85 /t | |
parent | e5817664738e613155078ddea66c9dde73339ac1 (diff) | |
download | memcached-4c0d45a95c9ba8fb8ea0630b96f4e006ef1698a1.tar.gz |
fix connection limit tests
Also changes the maxconns_fast test to check against the highest fd
Diffstat (limited to 't')
-rw-r--r-- | t/conn-limits.t | 2 | ||||
-rwxr-xr-x | t/maxconns.t | 49 |
2 files changed, 30 insertions, 21 deletions
diff --git a/t/conn-limits.t b/t/conn-limits.t index b5285e9..b354d97 100644 --- a/t/conn-limits.t +++ b/t/conn-limits.t @@ -8,7 +8,7 @@ use FindBin qw($Bin); use lib "$Bin/lib"; use MemcachedTest; -my $server = new_memcached('-o resp_obj_mem_limit=1,read_buf_mem_limit=1 -t 32 -R 500'); +my $server = new_memcached('-o read_buf_mem_limit=1 -t 32 -R 500'); my $sock = $server->sock; # The minimum limit is 1 megabyte. This is then split between each of the diff --git a/t/maxconns.t b/t/maxconns.t index 4da60cd..88bbd65 100755 --- a/t/maxconns.t +++ b/t/maxconns.t @@ -1,32 +1,41 @@ #!/usr/bin/perl -# NOTE: This test never worked. Memcached would ignore maxconns requests lower -# than the current ulimit. Test needs to be updated. use strict; use warnings; use Test::More; - use FindBin qw($Bin); use lib "$Bin/lib"; use MemcachedTest; -plan skip_all => "maxconns test does not work"; -exit 0; - -plan tests => 6; - -# start up a server with 10 maximum connections -my $server = new_memcached('-c 100'); -my $sock = $server->sock; -my @sockets; - -ok(defined($sock), 'Connection 0'); -push (@sockets, $sock); - +my $server = new_memcached(); + +my $stat_sock = $server->sock; +my @sockets = (); +my $num_sockets; +my $rejected_conns = 0; +my $stats; +for (1 .. 1024) { + my $sock = $server->new_sock; + if (defined($sock)) { + push(@sockets, $sock); + $stats = mem_stats($stat_sock); + if ($stats->{rejected_connections} > $rejected_conns) { + $rejected_conns = $stats->{rejected_connections}; + my $buffer = ""; + my $length = 31; + my $res = recv($sock, $buffer, $length, 0); + if (not $buffer eq '') { + is($buffer, "ERROR Too many open connections", "Got expected response from the server"); + } + } + } +} -foreach my $conn (1..10) { - $sock = $server->new_sock; - ok(defined($sock), "Made connection $conn"); - push(@sockets, $sock); +for my $s (@sockets) { + $s->close(); } +cmp_ok($stats->{rejected_connections}, '>', '1', 'rejected connections recorded'); +$server->stop; +$stat_sock->close(); +done_testing(); |