"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/refhang.t" (16 Jul 2020, 1846 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 
    6 use Test::More;
    7 
    8 use FindBin qw($Bin);
    9 use lib "$Bin/lib";
   10 use MemcachedTest;
   11 
   12 plan skip_all => 'Test is flaky. Needs special hooks.';
   13 
   14 plan tests => 127;
   15 
   16 # start up a server with 10 maximum connections
   17 my $server = new_memcached("-m 6");
   18 my $sock = $server->sock;
   19 my $hangsock = $server->new_sock;
   20 my $hangsock2 = $server->new_sock;
   21 my $value = "B"x66560;
   22 my $key = 0;
   23 
   24 # These aren't set to expire.
   25 my $mget = '';
   26 for ($key = 0; $key < 120; $key++) {
   27     $mget .= "key$key " if $key < 115;
   28     print $sock "set key$key 0 0 66560\r\n$value\r\n";
   29     is(scalar <$sock>, "STORED\r\n", "stored key$key");
   30 }
   31 chop $mget;
   32 
   33 my $stats  = mem_stats($sock, "items");
   34 isnt($stats->{"items:31:evicted"}, "0", "check evicted");
   35 
   36 my $lrutail_reflocked = $stats->{"items:31:lrutail_reflocked"};
   37 is($lrutail_reflocked, "0", "check no slab lrutail_reflocked");
   38 
   39 $stats = mem_stats($sock);
   40 is($stats->{"lrutail_reflocked"}, "0", "check no total lrutail_reflocked");
   41 
   42 # Don't intend to read the results, need to fill the socket.
   43 # TODO: This test would be smarter if we cranked down the socket buffers
   44 # first? Or perhaps used a unix domain socket.
   45 print $hangsock "get $mget\r\n";
   46 #sleep 8;
   47 # Now we try a bunch of sets again, and see if they start coming back as OOM's
   48 for ($key = 121; $key < 240; $key++) {
   49     print $sock "set key$key 0 0 66560\r\n$value\r\n";
   50     my $res = scalar <$sock>;
   51 }
   52 
   53 $stats = mem_stats($sock, "items");
   54 # Some items will OOM since we only clear a handful per alloc attempt.
   55 ok($stats->{"items:31:outofmemory"} > 0, "some ooms happened");
   56 ok($stats->{"items:31:outofmemory"} < 20, "fewer than 20 ooms");
   57 isnt($stats->{"items:31:lrutail_reflocked"}, "0", "nonzero lrutail_reflocked");
   58 
   59 $stats = mem_stats($sock);
   60 isnt($stats->{"lrutail_reflocked"}, "0", "nonzero total lrutail_reflocked");