"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/slabhang.t" (16 Jul 2020, 1785 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 => 74;
   15 
   16 # start up a server with 10 maximum connections
   17 my $server = new_memcached("-m 16 -o modern");
   18 my $sock = $server->sock;
   19 my $hangsock = $server->new_sock;
   20 my $value = "B"x260144;
   21 my $key = 0;
   22 
   23 # disable the normal automover.
   24 print $sock "slabs automove 0\r\n";
   25 is(scalar <$sock>, "OK\r\n", "automover disabled");
   26 
   27 # These aren't set to expire.
   28 my $mget = '';
   29 for ($key = 0; $key < 70; $key++) {
   30     $mget .= "key$key ";
   31     print $sock "set key$key 0 0 260144\r\n$value\r\n";
   32     is(scalar <$sock>, "STORED\r\n", "stored key$key");
   33 }
   34 chop $mget;
   35 
   36 # Don't intend to read the results, need to fill the socket.
   37 print $hangsock "get $mget\r\n";
   38 #sleep 8;
   39 my $stats = mem_stats($sock, "slabs");
   40 my $source = 0;
   41 for my $key (keys %$stats) {
   42     if ($key =~ m/^(\d+):total_pages/) {
   43         my $sid = $1;
   44         if ($stats->{$key} > 10) {
   45             $source = $sid;
   46             last;
   47         }
   48     }
   49 }
   50 isnt($source, 0, "found the source slab: $source");
   51 
   52 my $busy;
   53 my $tomove = 4;
   54 my $reassign = "slabs reassign $source 1\r\n";
   55 while ($tomove) {
   56     $busy = 0;
   57     print $sock $reassign;
   58     my $res = scalar <$sock>;
   59     while ($res =~ m/^BUSY/) {
   60         if ($hangsock && $busy > 5) {
   61             # unjam the pipeline
   62             $hangsock->close;
   63         }
   64         last if ($busy > 10);
   65         sleep 1;
   66         $busy++;
   67         print $sock $reassign;
   68         $res = scalar <$sock>;
   69     }
   70     last if ($busy > 10);
   71     $tomove--;
   72 }
   73 
   74 ok($busy <= 10, "didn't time out moving pages");
   75 
   76 $stats = mem_stats($sock);
   77 isnt($stats->{"slab_reassign_busy_deletes"}, "0", "deleted some busy items");