root/branches/append/server/t/stats.t

Revision 509, 1.3 kB (checked in by sgrimm, 3 years ago)

Merge multithreaded into trunk, commit #2 (first commit only did the
new files, not the modified ones.)

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2
3use strict;
4use Test::More tests => 17;
5use FindBin qw($Bin);
6use lib "$Bin/lib";
7use MemcachedTest;
8
9my $server = new_memcached();
10my $sock = $server->sock;
11
12
13## Output looks like this:
14##
15## STAT pid 16293
16## STAT uptime 7
17## STAT time 1174419597
18## STAT version 1.2.1
19## STAT pointer_size 32
20## STAT rusage_user 0.012998
21## STAT rusage_system 0.119981
22## STAT curr_items 0
23## STAT total_items 0
24## STAT bytes 0
25## STAT curr_connections 1
26## STAT total_connections 2
27## STAT connection_structures 2
28## STAT cmd_get 0
29## STAT cmd_set 0
30## STAT get_hits 0
31## STAT get_misses 0
32## STAT evictions 0
33## STAT bytes_read 7
34## STAT bytes_written 0
35## STAT limit_maxbytes 67108864
36
37my $stats = mem_stats($sock);
38
39# Test number of keys
40is(scalar(keys(%$stats)), 22, "22 stats values");
41
42# Test initial state
43foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits evictions get_misses bytes_written)) {
44    is($stats->{$key}, 0, "initial $key is zero");
45}
46
47# Do some operations
48
49print $sock "set foo 0 0 6\r\nfooval\r\n";
50is(scalar <$sock>, "STORED\r\n", "stored foo");
51mem_get_is($sock, "foo", "fooval");
52
53my $stats = mem_stats($sock);
54
55foreach my $key (qw(total_items curr_items cmd_get cmd_set get_hits)) {
56    is($stats->{$key}, 1, "after one set/one get $key is 1");
57}
Note: See TracBrowser for help on using the browser.