1# $Id: 24retention_period.t 965 2007-03-01 19:11:23Z nicolaw $
2
3chdir('t') if -d 't';
4my $rrdfile = -d 't' ? 't/24test.rrd' : '24test.rrd';
5unlink $rrdfile if -f $rrdfile;
6
7use strict;
8
9BEGIN {
10	use Test::More;
11	eval "use RRDs";
12	plan skip_all => "RRDs.pm *MUST* be installed!" if $@;
13	plan tests => 31 if !$@;
14}
15
16use lib qw(./lib ../lib);
17use RRD::Simple 1.35 ();
18
19use vars qw($rra %retention_periods %scheme_graphs @schemes %graph_return);
20require 'answers.pl';
21
22ok(my $rrd = RRD::Simple->new(),'new');
23
24for my $p (keys %retention_periods) {
25	ok($rrd->create($rrdfile, $p,
26			bytesIn => 'GAUGE',
27			bytesOut => 'GAUGE',
28		),"$p create");
29
30	ok($rrd->update($rrdfile,
31			bytesIn => 100,
32			bytesOut => 100,
33		),"$p update");
34
35	ok(join(',',sort $rrd->sources($rrdfile)) eq 'bytesIn,bytesOut',
36		"$p sources");
37
38	ok(my $period = $rrd->retention_period($rrdfile),"$p retention_period");
39	ok($period > ($retention_periods{$p} * 0.95) &&
40		$period < ($retention_periods{$p} * 1.05),
41		"$p retention_period result");
42
43	unlink $rrdfile if -f $rrdfile;
44}
45
46unlink $rrdfile if -f $rrdfile;
47
481;
49
50