components/memcached/patches/02-lru-maintainer.patch
changeset 6945 6e11c0218972
child 7487 6506549e143f
equal deleted inserted replaced
6944:8e80fd26ac48 6945:6e11c0218972
       
     1 Ignore lru-maintainer.t because it is inconsistent.
       
     2 Upstream is irresponsible https://groups.google.com/forum/#!topic/memcached/35wG9noM9rM
       
     3 
       
     4 --- a/t/lru-maintainer.t	2015-11-18 22:49:43.000000000 -0800
       
     5 +++ /dev/null	2016-09-20 11:14:16.000000000 -0700
       
     6 @@ -1,90 +0,0 @@
       
     7 -#!/usr/bin/perl
       
     8 -
       
     9 -use strict;
       
    10 -use Test::More tests => 224;
       
    11 -use FindBin qw($Bin);
       
    12 -use lib "$Bin/lib";
       
    13 -use MemcachedTest;
       
    14 -
       
    15 -my $server = new_memcached('-m 6 -o lru_maintainer,lru_crawler');
       
    16 -my $sock = $server->sock;
       
    17 -
       
    18 -for (1 .. 10) {
       
    19 -    print $sock "set ifoo$_ 0 1 2\r\nok\r\n";
       
    20 -    is(scalar <$sock>, "STORED\r\n", "stored key");
       
    21 -}
       
    22 -
       
    23 -sleep 3;
       
    24 -
       
    25 -{
       
    26 -    my $stats = mem_stats($sock);
       
    27 -    is($stats->{reclaimed}, 10, "expired key automatically reclaimed");
       
    28 -}
       
    29 -
       
    30 -my $value = "B"x66560;
       
    31 -
       
    32 -print $sock "set canary 0 0 66560\r\n$value\r\n";
       
    33 -is(scalar <$sock>, "STORED\r\n", "stored canary key");
       
    34 -
       
    35 -# Now flush the slab class with junk.
       
    36 -for (my $key = 0; $key < 100; $key++) {
       
    37 -    if ($key == 30) {
       
    38 -        my $stats;
       
    39 -        for (0..2) {
       
    40 -            # Give the juggler some time to move. some platforms suffer at
       
    41 -            # this more than others (solaris amd64?)
       
    42 -            $stats = mem_stats($sock, "items");
       
    43 -            if ($stats->{"items:31:moves_to_cold"} == 0) { sleep 1; next; }
       
    44 -            last;
       
    45 -        }
       
    46 -        isnt($stats->{"items:31:moves_to_cold"}, 0, "moved some items to cold");
       
    47 -        # Fetch the canary once, so it's now marked as active.
       
    48 -        mem_get_is($sock, "canary", $value);
       
    49 -    }
       
    50 -    print $sock "set key$key 0 0 66560\r\n$value\r\n";
       
    51 -    is(scalar <$sock>, "STORED\r\n", "stored key$key");
       
    52 -}
       
    53 -
       
    54 -{
       
    55 -    my $stats = mem_stats($sock);
       
    56 -    isnt($stats->{evictions}, 0, "some evictions happened");
       
    57 -    my $istats = mem_stats($sock, "items");
       
    58 -    isnt($stats->{"items:31:number_warm"}, 0, "our canary moved to warm");
       
    59 -}
       
    60 -
       
    61 -# Key should've been saved to the WARM_LRU, and still exists.
       
    62 -mem_get_is($sock, "canary", $value);
       
    63 -
       
    64 -# Test NOEXP_LRU
       
    65 -$server = new_memcached('-m 2 -o lru_maintainer,lru_crawler,expirezero_does_not_evict');
       
    66 -$sock = $server->sock;
       
    67 -
       
    68 -{
       
    69 -    my $stats = mem_stats($sock, "settings");
       
    70 -    is($stats->{expirezero_does_not_evict}, "yes");
       
    71 -}
       
    72 -
       
    73 -print $sock "set canary 0 0 66560\r\n$value\r\n";
       
    74 -is(scalar <$sock>, "STORED\r\n", "stored noexpire canary key");
       
    75 -
       
    76 -{
       
    77 -    my $stats = mem_stats($sock, "items");
       
    78 -    is($stats->{"items:31:number_noexp"}, 1, "one item in noexpire LRU");
       
    79 -    is($stats->{"items:31:number_hot"}, 0, "item did not go into hot LRU");
       
    80 -}
       
    81 -
       
    82 -# *Not* fetching the key, and flushing the slab class with junk.
       
    83 -# Using keys with actual TTL's here.
       
    84 -for (my $key = 0; $key < 100; $key++) {
       
    85 -    print $sock "set key$key 0 3600 66560\r\n$value\r\n";
       
    86 -    is(scalar <$sock>, "STORED\r\n", "stored key$key");
       
    87 -}
       
    88 -
       
    89 -{
       
    90 -    my $stats = mem_stats($sock, "items");
       
    91 -    isnt($stats->{evictions}, 0, "some evictions happened");
       
    92 -    isnt($stats->{number_hot}, 0, "nonzero exptime items went into hot LRU");
       
    93 -}
       
    94 -# Canary should still exist, even unfetched, because it's protected by
       
    95 -# noexpire.
       
    96 -mem_get_is($sock, "canary", $value);