5 use Test::More tests => 14;
6 use Collectd::Unixsock;
7 use Collectd::MockDaemon;
9 my $path = mockd_start();
13 my ($s, $attr, $results) = @_;
14 my ($nresults, $resultdata) = @$results;
15 my $r = $s->getval(%{Collectd::Unixsock::_parse_identifier($attr)});
16 is(ref $r, 'HASH', "Got a result for $attr");
17 is(scalar keys %$r, $nresults, "$nresults result result for $attr");
18 is_deeply($r, $resultdata, "Data or $attr matches");
21 my $s = Collectd::Unixsock->new($path);
22 isnt($s, undef, "Collectd::Unixsock object created");
25 'w83df6600/vmem/vmpage_number-vmscan_write' => [ 1, { value => 0 } ],
26 'a1d8f6310/load/load' => [ 3, { longterm => '0.07', shortterm => 0, midterm => '0.06' } ],
27 'w83df6600/disk-sda/disk_octets' => [ 2, { read => 0, write => 0 } ],
30 test_query($s, $_, $queries{$_}) for sort keys %queries;
32 my @values = $s->listval;
33 is(scalar @values, 4984, "Correct number of results from LISTVAL");
34 is_deeply($values[1234], {
35 type_instance => 'nice',
36 plugin_instance => 21,
40 time => 1479835354.434,
41 }, "Correct data returned for select element");
44 is_deeply([ $s->listval_filter() ] , [ $s->listval ], "listval_filter() w/o filter equivalent to listval()");
46 [ $s->listval_filter(host => 'a1d8f6310', plugin => 'disk', plugin_instance => 'vda6') ],
48 { 'plugin_instance' => 'vda6', 'type' => 'disk_merged', 'plugin' => 'disk', 'host' => 'a1d8f6310', time => 1479835354.434 },
49 { 'host' => 'a1d8f6310', 'plugin' => 'disk', 'plugin_instance' => 'vda6', 'type' => 'disk_octets', time => 1479835356 },
50 { 'type' => 'disk_ops', 'plugin_instance' => 'vda6', 'plugin' => 'disk', 'host' => 'a1d8f6310', time => 1479835354 },
51 { 'plugin' => 'disk', 'host' => 'a1d8f6310', 'type' => 'disk_time', 'plugin_instance' => 'vda6', time => 1479835354 }
53 "Correct result from listval_filter on <host>, <plugin> and <plugin_instance>"
56 # TODO more test for putval() and the like