"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/item_size_max.t" (16 Jul 2020, 1266 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 Test::More tests => 7;
    5 use FindBin qw($Bin);
    6 use lib "$Bin/lib";
    7 use MemcachedTest;
    8 
    9 my $server = new_memcached();
   10 my $sock = $server->sock;
   11 
   12 my $stats = mem_stats($sock, ' settings');
   13 
   14 # Ensure default still works.
   15 is($stats->{item_size_max}, 1024 * 1024);
   16 $server->stop();
   17 
   18 # Should die.
   19 eval {
   20     $server = new_memcached('-I 1000');
   21 };
   22 ok($@ && $@ =~ m/^Failed/, "Shouldn't start with < 1k item max");
   23 
   24 eval {
   25     $server = new_memcached('-I 256m');
   26 };
   27 ok($@ && $@ =~ m/^Failed/, "Shouldn't start with > 128m item max");
   28 
   29 # Minimum.
   30 $server = new_memcached('-I 1024 -o slab_chunk_max=1024');
   31 my $stats = mem_stats($server->sock, ' settings');
   32 is($stats->{item_size_max}, 1024);
   33 $server->stop();
   34 
   35 # Reasonable but unreasonable.
   36 $server = new_memcached('-I 2097152');
   37 my $stats = mem_stats($server->sock, ' settings');
   38 is($stats->{item_size_max}, 2097152);
   39 $server->stop();
   40 
   41 # Suffix kilobytes.
   42 $server = new_memcached('-I 512k -o slab_chunk_max=16384');
   43 my $stats = mem_stats($server->sock, ' settings');
   44 is($stats->{item_size_max}, 524288);
   45 $server->stop();
   46 
   47 # Suffix megabytes.
   48 $server = new_memcached('-m 256 -I 32m');
   49 my $stats = mem_stats($server->sock, ' settings');
   50 is($stats->{item_size_max}, 33554432);
   51 $server->stop();
   52