2
# tests for functions documented in memcached_stats.pod
9
use Memcached::libmemcached
10
# functions explicitly tested by this file
13
# other functions used by the tests
15
memcached_server_count
19
use libmemcached_test;
21
my $memc = libmemcached_test_create();
30
# statistics information actually change from version to version,
31
# so we can't even be sure of the number of tests.
32
# We could probably do a version specific testing, but for now
33
# just check that the some constant items/constraints stay constant.
35
my $keys_defined_ok = 1;
36
my $hostport_defined_ok = 1;
38
my (%seen_hostport, %seen_distinct);
39
my $walk_stats_rc = $memc->walk_stats("", sub {
40
$arg_count_ok = scalar(@_) == 4 if $arg_count_ok;
41
my ($key, $value, $hostport, $type) = @_;
42
print "$hostport $type: $key=$value\n";
43
$keys_defined_ok = defined $key if $keys_defined_ok;
44
$hostport_defined_ok = defined $hostport if $hostport_defined_ok;
45
$type_ok = defined $type && "" eq $type if $type_ok;
46
$seen_hostport{$hostport} = 1;
47
$seen_distinct{"$hostport:$key"}++;
48
# XXX build $seen_hostport{$hostport} and it matches memcached_server_count
52
ok( $walk_stats_rc, "walk_stats should return true");
53
ok( $arg_count_ok, "walk_stats argument count is sane" );
54
ok( $keys_defined_ok, "keys are sane" );
55
ok( $hostport_defined_ok, "hostport are sane" );
56
ok( $type_ok, "types are sane" );
57
is( scalar keys %seen_hostport, memcached_server_count($memc),
58
"should see responses from each server");
59
is( scalar (grep { $_ != 1 } values %seen_distinct), 0,
60
"should see no distinct hostport+key more than once");