File: munin_master_plugin_multigraph_fetch.t

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (93 lines) | stat: -rw-r--r-- 1,907 bytes parent folder | download | duplicates (10)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- cperl -*-
# vim: ts=4 : sw=4 : et
use warnings;
use strict;

use English qw(-no_match_vars);
use Data::Dumper;

use Test::More tests => 2;

use_ok('Munin::Master::Node');

# use_ok('Munin::Master::Logger');
# logger_debug();

# Mock object enough to be able to call (some) object methods.
my $node = bless { address => "127.0.0.1",
		   port => "4949",
		   host => "localhost" }, "Munin::Master::Node";

$INPUT_RECORD_SEPARATOR = '';
my @input = split("\n",<DATA>);

# make time() return a known value.
BEGIN { *CORE::GLOBAL::time = sub { 1234567890 }; }
my $time = time;

my %answer = $node->parse_service_data("multigraph_tester", \@input);


# Output captured from Data::Dumper
my $fasit = {
    'multigraph_outofscope' => {
        i => {
            when  => [ $time ],
            value => [ 42    ],
        }
    },
    'multigraph_tester' => {
        three => {
            when  => [ $time ],
            value => [ 3     ],
        },
        one => {
            when  => [ $time ],
            value => [ 1     ],
        },
        two => {
            when  => [ 1256305817 ],
            value => [ 2          ],
        }
    },
    'multigraph_tester.en' => {
        one => {
            when  => [ 1256305817 ],
            value => [ 1          ],
        }
    },
    'multigraph_tester.to' => {
        two => {
            when  => [ $time ],
            value => [ 2     ],
        }
    },
    'multigraph_tester.tre' => {
        three => {
            when  => [ $time ],
            value => [ 3     ],
        }
    }
};

# print Dumper \%answer;

is_deeply(\%answer, $fasit, 'Multigraph plugin fetch output');


__DATA__
one.value 1
two.value 1256305817:2
three.value 3
#
multigraph multigraph_tester.en
one.value 1256305817:1
#
multigraph multigraph_tester.to
two.value 2
#
multigraph multigraph_tester.tre
three.value 3
#
multigraph multigraph_outofscope
i.value 42