Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ssinyagin/perl-rrd-tweak
base: 4a727e7cce
...
head fork: ssinyagin/perl-rrd-tweak
compare: d9f056af97
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 107 additions and 3 deletions.
  1. +3 −3 lib/RRD/Tweak.pm
  2. +104 −0 t/add_del_ds_rra.t
View
6 lib/RRD/Tweak.pm
@@ -428,7 +428,7 @@ sub load_file {
# populate $self->{'rra'}[$rra]->{'cdp_prep_defaults'}
my $n_rra = scalar(@{$self->{'rra'}});
for( my $rra=0; $rra < $n_rra; $rra++) {
- $self->_default_cdp_prep_attrinutes($rra);
+ $self->_default_cdp_prep_attributes($rra);
}
if( not $self->validate() ) {
@@ -636,7 +636,7 @@ sub create {
# populates $self->{'rra'}[$rra]->{'cdp_prep_defaults'}
# see details in rrd_create.c
-sub _default_cdp_prep_attrinutes {
+sub _default_cdp_prep_attributes {
my $self = shift;
my $rra = shift;
@@ -1059,7 +1059,7 @@ sub add_rra {
# populate cdp_prep_defaults for the newly created RRA
- $self->_default_cdp_prep_attrinutes($new_rra);
+ $self->_default_cdp_prep_attributes($new_rra);
# create cdp_prep entries
View
104 t/add_del_ds_rra.t
@@ -0,0 +1,104 @@
+#!perl -T
+
+use Test::More tests => 8;
+
+use File::Temp qw/tmpnam/;
+use RRDs;
+use Data::Compare;
+use Data::Dumper;
+
+BEGIN {
+ use_ok('RRD::Tweak', "use RRD::Tweak") or
+ BAIL_OUT("cannot load the module");
+}
+
+diag("Testing RRD::Tweak $RRD::Tweak::VERSION, Perl $], $^X");
+
+my $rrd1 = RRD::Tweak->new();
+ok((defined($rrd1)), "RRD::Tweak->new()");
+
+$rrd1->create({step => 300,
+ start => time(),
+ ds => [{name => 'InOctets',
+ type=> 'COUNTER',
+ heartbeat => 600},
+ {name => 'OutOctets',
+ type => 'COUNTER',
+ heartbeat => 600},
+ {name => 'Load',
+ type => 'GAUGE',
+ heartbeat => 800,
+ min => 0,
+ max => 255}],
+ rra => [{cf => 'AVERAGE',
+ xff => 0.5,
+ steps => 1,
+ rows => 2016},
+ {cf => 'AVERAGE',
+ xff => 0.25,
+ steps => 12,
+ rows => 768},
+ {cf => 'MAX',
+ xff => 0.25,
+ steps => 12,
+ rows => 768}]});
+
+diag("created RRD::Tweak with new RRD data");
+
+# check the edge case: duplicate DS name
+eval { $rrd1->add_ds({name => 'InOctets',
+ type=> 'COUNTER',
+ heartbeat => 600}) };
+ok($@, "add_ds with duplicate name") or
+ BAIL_OUT('added a DS with duplicate name, but did not get an error');
+
+$rrd1->add_ds({name => 'InErrors',
+ type=> 'COUNTER',
+ heartbeat => 755});
+
+$rrd1->del_ds(1);
+
+my $rrd1_info = $rrd1->info();
+
+ok((scalar(@{$rrd1_info->{ds}}) == 3),
+ 'after adding and deleting DS, should get 3 datasources');
+
+
+ok(($rrd1_info->{ds}[2]{heartbeat} == 755),
+ '$rrd1_info->{ds}[2]{heartbeat}) == 755');
+
+
+# check the edge case: duplicate RRA
+eval { $rrd1->add_rra({cf => 'MAX',
+ xff => 0.77,
+ steps => 12,
+ rows => 1010}) };
+ok($@, "add_rra with duplicate RRA") or
+ BAIL_OUT('added RRA with duplicate CF and steps, but did not get an error');
+
+$rrd1->add_rra({cf => 'MIN',
+ xff => 0.3,
+ steps => 288,
+ rows => 768});
+
+$rrd1->del_rra(1);
+$rrd1_info = $rrd1->info();
+
+ok((scalar(@{$rrd1_info->{rra}}) == 3),
+ 'after adding a deleting RRA, should get 3 RRAs');
+
+
+ok(($rrd1_info->{rra}[2]{steps} == 288),
+ '$rrd1_info->{rra}[2]{steps} == 288');
+
+
+
+# Local Variables:
+# mode: cperl
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# cperl-continued-statement-offset: 4
+# cperl-continued-brace-offset: -4
+# cperl-brace-offset: 0
+# cperl-label-offset: -2
+# End:

No commit comments for this range

Something went wrong with that request. Please try again.