File: idle-timeout.t

package info (click to toggle)
memcached 1.6.9%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,820 kB
  • sloc: ansic: 21,174; perl: 7,113; sh: 4,340; python: 402; makefile: 202; xml: 59
file content (43 lines) | stat: -rw-r--r-- 1,170 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 11;

use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;

# start up a server with 10 maximum connections
my $server = new_memcached("-o idle_timeout=3 -l 127.0.0.1");
my $sock = $server->sock;

# Make sure we can talk to start with
my $stats = mem_stats($sock);
is($stats->{idle_kicks}, "0", "check stats initial");
isnt($sock->connected(), undef, "check connected");

# Make sure we don't timeout when active
for (my $i = 0; $i < 6; $i++) {
    $stats = mem_stats($sock);
    isnt($stats->{version}, undef, "check active $i");
}
$stats = mem_stats($sock);
is($stats->{idle_kicks}, "0", "check stats 2");

# Make sure we do timeout when not
sleep(10);
mem_stats($sock);   # Network activity, so socket code will see dead socket
sleep(1);
# we run SSL tests over TCP; hence IO::Socket::SSL returns
# '' upon disconnecting with the server.
if (enabled_tls_testing()) {
    is($sock->connected(),'', "check disconnected");
} else {
    is($sock->connected(),undef, "check disconnected");
}

$sock = $server->sock;
$stats = mem_stats($sock);
isnt($stats->{idle_kicks}, 0, "check stats timeout");