"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.9/t/idle-timeout.t" (21 Nov 2020, 1170 Bytes) of package /linux/www/memcached-1.6.9.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 "idle-timeout.t": 1.6.8_vs_1.6.9.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 
    6 use Test::More tests => 11;
    7 
    8 use FindBin qw($Bin);
    9 use lib "$Bin/lib";
   10 use MemcachedTest;
   11 
   12 # start up a server with 10 maximum connections
   13 my $server = new_memcached("-o idle_timeout=3 -l 127.0.0.1");
   14 my $sock = $server->sock;
   15 
   16 # Make sure we can talk to start with
   17 my $stats = mem_stats($sock);
   18 is($stats->{idle_kicks}, "0", "check stats initial");
   19 isnt($sock->connected(), undef, "check connected");
   20 
   21 # Make sure we don't timeout when active
   22 for (my $i = 0; $i < 6; $i++) {
   23     $stats = mem_stats($sock);
   24     isnt($stats->{version}, undef, "check active $i");
   25 }
   26 $stats = mem_stats($sock);
   27 is($stats->{idle_kicks}, "0", "check stats 2");
   28 
   29 # Make sure we do timeout when not
   30 sleep(10);
   31 mem_stats($sock);   # Network activity, so socket code will see dead socket
   32 sleep(1);
   33 # we run SSL tests over TCP; hence IO::Socket::SSL returns
   34 # '' upon disconnecting with the server.
   35 if (enabled_tls_testing()) {
   36     is($sock->connected(),'', "check disconnected");
   37 } else {
   38     is($sock->connected(),undef, "check disconnected");
   39 }
   40 
   41 $sock = $server->sock;
   42 $stats = mem_stats($sock);
   43 isnt($stats->{idle_kicks}, 0, "check stats timeout");