forked from memcached/memcached
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.t
executable file
·61 lines (48 loc) · 1.38 KB
/
stats.t
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl
use strict;
use Test::More tests => 18;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
my $server = new_memcached();
my $sock = $server->sock;
## Output looks like this:
##
## STAT pid 16293
## STAT uptime 7
## STAT time 1174419597
## STAT version 1.2.1
## STAT pointer_size 32
## STAT rusage_user 0.012998
## STAT rusage_system 0.119981
## STAT curr_items 0
## STAT total_items 0
## STAT bytes 0
## STAT curr_connections 1
## STAT total_connections 2
## STAT connection_structures 2
## STAT cmd_get 0
## STAT cmd_set 0
## STAT get_hits 0
## STAT get_misses 0
## STAT evictions 0
## STAT bytes_read 7
## STAT bytes_written 0
## STAT limit_maxbytes 67108864
my $stats = mem_stats($sock);
# Test number of keys
is(scalar(keys(%$stats)), 22, "22 stats values");
# Test initial state
foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits evictions get_misses bytes_written)) {
is($stats->{$key}, 0, "initial $key is zero");
}
# Do some operations
print $sock "set foo 0 0 6\r\nfooval\r\n";
is(scalar <$sock>, "STORED\r\n", "stored foo");
mem_get_is($sock, "foo", "fooval");
my $stats = mem_stats($sock);
foreach my $key (qw(total_items curr_items cmd_get cmd_set get_hits)) {
is($stats->{$key}, 1, "after one set/one get $key is 1");
}
my $cache_dump = mem_stats($sock, " cachedump 1 100");
ok(defined $cache_dump->{'foo'}, "got foo from cachedump");