#!/bin/bash

. $(dirname $0)/functions

BASE=$BASEDIR/tune2-test
BUILD=$BUILDDIR/tune2-test

xDIFF9="${DIFF9} -I .*<seasonal_smooth_idx>.*"

$RRDTOOL create ${BUILD}org.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U DS:b:COUNTER:120:0:U RRA:HWPREDICT:288:0.9:0.8:144
$RRDTOOL dump ${BUILD}org.rrd | $xDIFF9 - ${BASE}org.dump
report create

is_cached && ( $RRDTOOL flushcached ${BUILD}org.rrd || fail flushcached )
cp ${BUILD}org.rrd ${BUILD}a.rrd
# this must fail
! $RRDTOOL tune ${BUILD}a.rrd --beta 1.4 2>/dev/null
report "out of range beta error"
$RRDTOOL dump ${BUILD}a.rrd | $xDIFF9 - ${BASE}org.dump
report "RRD unchanged"

$RRDTOOL tune ${BUILD}a.rrd --beta 0.4 
$RRDTOOL dump ${BUILD}a.rrd | $xDIFF9 - ${BASE}a-mod1.dump
report "tune beta"

