#!/bin/bash

. $(dirname $0)/functions

BASE=$BASEDIR/$(basename $0)-test
BUILD=$BUILDDIR/$(basename $0)-test

ST=1300000000
$RRDTOOL create ${BUILD}a1.rrd --start $(($ST-1)) --step 60 DS:a:GAUGE:120:0:U  RRA:AVERAGE:0.5:1:20 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 
report create1

V=10
N=0
CNT=25
for A in $(seq $ST 60 $(($ST + 60*($CNT - 1))) ) ; do
	V=$(($V + 20))
	N=$(($N + 1))
	ST=$A
	$RRDTOOL update ${BUILD}a1.rrd  $A:$V

	rm -f ${BUILD}a1.xml ${BUILD}r1.rrd ${BUILD}r1.xml

	$RRDTOOL dump ${BUILD}a1.rrd ${BUILD}a1.xml
	$RRDTOOL restore ${BUILD}a1.xml ${BUILD}r1.rrd
	$RRDTOOL dump ${BUILD}r1.rrd ${BUILD}r1.xml

	$DIFF ${BUILD}a1.xml ${BUILD}r1.xml 
	report dump-restore-cycle $N/$CNT
done

rm -f ${BUILD}a1.xml ${BUILD}r1.rrd ${BUILD}r1.xml
rm -f ${BUILD}a1.rrd 

