summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eeff495)
raw | patch | inline | side by side (parent: eeff495)
author | Matthias Bethke <mbe@financial.com> | |
Tue, 22 Nov 2016 17:36:12 +0000 (00:36 +0700) | ||
committer | Matthias Bethke <mbe@financial.com> | |
Tue, 22 Nov 2016 17:36:12 +0000 (00:36 +0700) |
bindings/perl/lib/Collectd/MockDaemon.pm | patch | blob | history | |
bindings/perl/t/01_methods.t | patch | blob | history |
index 9d784b7c353e8a52d466b93d20faaf1187e1f6f2..300d2c4a85a3739a7b637a9063d6afb73abfcc46 100644 (file)
}
sub listval {
- my $trunc_now = substr(time, 0, -1);
- my $toggle;
+ my @timevals = (
+ 1479835353.75,
+ 1479835354.434,
+ 1479835356,
+ 1479835354,
+ 1479835354,
+ 1479835350.820,
+ 1479835351,
+ 1479835354.2,
+ 1479835353,
+ );
+ my $i = 0;
return print_nvalues(scalar @metrics) .
- join('', map { $trunc_now . int(rand(10)) . ($toggle=!$toggle ? ".".int(rand(1000)) : '') . " $_\n" } @metrics);
+ join('', map { $timevals[$i++ % @timevals] . " $_\n" } @metrics);
}
sub getval {
index 4e94f8e8d235f53fa742bd716a1b738b6aade28f..4a4822aeff4b15192fe0e53254428b775831fbe3 100644 (file)
my $path = mockd_start();
END { mockd_stop(); }
-sub filter_time { return map { delete $_->{time}; $_ } @_ }
-
sub test_query {
my ($s, $attr, $results) = @_;
my ($nresults, $resultdata) = @$results;
my @values = $s->listval;
is(scalar @values, 4984, "Correct number of results from LISTVAL");
-delete $values[1234]{time}; # won't be constant
is_deeply($values[1234], {
type_instance => 'nice',
plugin_instance => 21,
plugin => 'cpu',
type => 'cpu',
- host => 'h2gdf6120'
+ host => 'h2gdf6120',
+ time => 1479835354.434,
}, "Correct data returned for select element");
@values = ();
-is_deeply([ filter_time $s->listval_filter() ] , [ filter_time $s->listval ], "listval_filter() w/o filter equivalent to listval()");
+is_deeply([ $s->listval_filter() ] , [ $s->listval ], "listval_filter() w/o filter equivalent to listval()");
is_deeply(
- [ filter_time $s->listval_filter(host => 'a1d8f6310', plugin => 'disk', plugin_instance => 'vda6') ],
+ [ $s->listval_filter(host => 'a1d8f6310', plugin => 'disk', plugin_instance => 'vda6') ],
[
- { 'plugin_instance' => 'vda6', 'type' => 'disk_merged', 'plugin' => 'disk', 'host' => 'a1d8f6310' },
- { 'host' => 'a1d8f6310', 'plugin' => 'disk', 'plugin_instance' => 'vda6', 'type' => 'disk_octets' },
- { 'type' => 'disk_ops', 'plugin_instance' => 'vda6', 'plugin' => 'disk', 'host' => 'a1d8f6310' },
- { 'plugin' => 'disk', 'host' => 'a1d8f6310', 'type' => 'disk_time', 'plugin_instance' => 'vda6' }
+ { 'plugin_instance' => 'vda6', 'type' => 'disk_merged', 'plugin' => 'disk', 'host' => 'a1d8f6310', time => 1479835354.434 },
+ { 'host' => 'a1d8f6310', 'plugin' => 'disk', 'plugin_instance' => 'vda6', 'type' => 'disk_octets', time => 1479835356 },
+ { 'type' => 'disk_ops', 'plugin_instance' => 'vda6', 'plugin' => 'disk', 'host' => 'a1d8f6310', time => 1479835354 },
+ { 'plugin' => 'disk', 'host' => 'a1d8f6310', 'type' => 'disk_time', 'plugin_instance' => 'vda6', time => 1479835354 }
],
"Correct result from listval_filter on <host>, <plugin> and <plugin_instance>"
);