"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/extstore-jbod.t" (30 Mar 2022, 2075 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. See also the latest Fossies "Diffs" side-by-side code changes report for "extstore-jbod.t": 1.6.14_vs_1.6.15.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


    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 my $ext_path2;
   13 
   14 if (!supports_extstore()) {
   15     plan skip_all => 'extstore not enabled';
   16     exit 0;
   17 }
   18 
   19 $ext_path = "/tmp/extstore1.$$";
   20 $ext_path2 = "/tmp/extstore2.$$";
   21 
   22 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.9,ext_path=$ext_path:64m,ext_path=$ext_path2:96m,slab_automove=1,ext_max_sleep=100000");
   23 my $sock = $server->sock;
   24 
   25 my $value;
   26 {
   27     my @chars = ("C".."Z");
   28     for (1 .. 20000) {
   29         $value .= $chars[rand @chars];
   30     }
   31 }
   32 
   33 # fill some larger objects
   34 {
   35     # interleave sets with 0 ttl vs long ttl's.
   36     my $keycount = 3700;
   37     for (1 .. $keycount) {
   38         print $sock "set nfoo$_ 0 0 20000 noreply\r\n$value\r\n";
   39         print $sock "set lfoo$_ 0 0 20000 noreply\r\n$value\r\n";
   40     }
   41     # wait for a flush
   42     wait_ext_flush($sock);
   43     # delete half
   44     mem_get_is($sock, "nfoo1", $value);
   45     for (1 .. $keycount) {
   46         print $sock "delete lfoo$_ noreply\r\n";
   47     }
   48     print $sock "lru_crawler crawl all\r\n";
   49     <$sock>;
   50     sleep 10;
   51     # fetch
   52     # check extstore counters
   53     my $stats = mem_stats($sock);
   54     is($stats->{evictions}, 0, 'no RAM evictions');
   55     cmp_ok($stats->{extstore_page_allocs}, '>', 0, 'at least one page allocated');
   56     cmp_ok($stats->{extstore_objects_written}, '>', $keycount / 2, 'some objects written');
   57     cmp_ok($stats->{extstore_bytes_written}, '>', length($value) * 2, 'some bytes written');
   58     cmp_ok($stats->{get_extstore}, '>', 0, 'one object was fetched');
   59     cmp_ok($stats->{extstore_objects_read}, '>', 0, 'one object read');
   60     cmp_ok($stats->{extstore_bytes_read}, '>', length($value), 'some bytes read');
   61     cmp_ok($stats->{extstore_page_reclaims}, '>', 1, 'at least two pages reclaimed');
   62 }
   63 
   64 done_testing();
   65 
   66 END {
   67     unlink $ext_path if $ext_path;
   68     unlink $ext_path2 if $ext_path2;
   69 }