"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/extstore-buckets.t" (16 Jul 2020, 1790 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 use Test::More;
    6 use FindBin qw($Bin);
    7 use lib "$Bin/lib";
    8 use MemcachedTest;
    9 use Data::Dumper qw/Dumper/;
   10 
   11 my $ext_path;
   12 
   13 if (!supports_extstore()) {
   14     plan skip_all => 'extstore not enabled';
   15     exit 0;
   16 }
   17 
   18 $ext_path = "/tmp/extstore.$$";
   19 
   20 my $server = new_memcached("-m 256 -U 0 -o ext_page_size=8,ext_wbuf_size=2,ext_threads=1,ext_io_depth=2,ext_item_size=512,ext_item_age=2,ext_recache_rate=10000,ext_max_frag=0,ext_path=$ext_path:64m,ext_low_ttl=60,slab_automove=1");
   21 my $sock = $server->sock;
   22 
   23 my $value;
   24 {
   25     my @chars = ("C".."Z");
   26     for (1 .. 20000) {
   27         $value .= $chars[rand @chars];
   28     }
   29 }
   30 
   31 # fill some larger objects
   32 {
   33     # interleave sets with 0 ttl vs long ttl's.
   34     my $keycount = 1200;
   35     for (1 .. $keycount) {
   36         print $sock "set nfoo$_ 0 0 20000 noreply\r\n$value\r\n";
   37         print $sock "set lfoo$_ 0 5 20000 noreply\r\n$value\r\n";
   38     }
   39     # wait for a flush
   40     sleep 10;
   41     print $sock "lru_crawler crawl all\r\n";
   42     <$sock>;
   43     sleep 2;
   44     # fetch
   45     mem_get_is($sock, "nfoo1", $value);
   46     # check extstore counters
   47     my $stats = mem_stats($sock);
   48     cmp_ok($stats->{extstore_page_allocs}, '>', 0, 'at least one page allocated');
   49     cmp_ok($stats->{extstore_objects_written}, '>', $keycount / 2, 'some objects written');
   50     cmp_ok($stats->{extstore_bytes_written}, '>', length($value) * 2, 'some bytes written');
   51     cmp_ok($stats->{get_extstore}, '>', 0, 'one object was fetched');
   52     cmp_ok($stats->{extstore_objects_read}, '>', 0, 'one object read');
   53     cmp_ok($stats->{extstore_bytes_read}, '>', length($value), 'some bytes read');
   54     cmp_ok($stats->{extstore_page_reclaims}, '>', 1, 'at least two pages reclaimed');
   55 }
   56 
   57 done_testing();
   58 
   59 END {
   60     unlink $ext_path if $ext_path;
   61 }