]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix tune related test scripts to work in the presence of a caching daemon. 531/head
authorPeter Stamfest <peter@stamfest.at>
Fri, 5 Sep 2014 06:39:42 +0000 (08:39 +0200)
committerPeter Stamfest <peter@stamfest.at>
Fri, 5 Sep 2014 09:40:08 +0000 (11:40 +0200)
Also do explicit "forgetting" of just tuned RRD, because "tune" is
never done via rrdcached.

src/rrd_tune.c
tests/functions
tests/tune1
tests/tune2

index ad41d73f17f2a9483c119ce7c841355a5d187711..4d73d41081eb9dc52ce8201c94e4405c84eb974d 100644 (file)
@@ -88,6 +88,7 @@ int rrd_tune(
     rrd_file_t *rrd_file = NULL;
     char      *opt_daemon = NULL;
     char      double_str[ 12 ];
+    const char *in_filename = NULL;
     struct option long_options[] = {
         {"heartbeat", required_argument, 0, 'h'},
         {"minimum", required_argument, 0, 'i'},
@@ -145,7 +146,7 @@ int rrd_tune(
     
     // connect to daemon (will take care of environment variable automatically)
     if (rrdc_connect(opt_daemon) != 0) {
-       rrd_set_error("Cannot connect to daemon");
+       rrd_set_error("Cannot connect to daemon");
        return 1;
     }
 
@@ -164,7 +165,7 @@ int rrd_tune(
     the back, starting with optind. This means the file name has travelled to
     argv[optind] */
     
-    const char *in_filename = argv[optind];
+    in_filename = argv[optind];
     
     if (rrdc_is_any_connected()) {
        // is it a good idea to just ignore the error ????
@@ -412,6 +413,19 @@ int rrd_tune(
     
     rc = 0;
 done:
+    if (in_filename && rrdc_is_any_connected()) {
+        // save any errors....
+        char *e = strdup(rrd_get_error());
+       // is it a good idea to just ignore the error ????
+       rrdc_forget(in_filename);
+       rrd_clear_error();
+        
+        if (e && *e) {
+            rrd_set_error(e);
+        }
+        if (e) free(e);
+        
+    }
     if (rrd_file) {
        rrd_close(rrd_file);
     }
index f68ecc43478cc0b5a5689d8b711c692534350e5a..0b0816529bf0f6c2696f18071581618b8d1c8eda 100644 (file)
@@ -124,10 +124,14 @@ function stop_cached {
         fi
 }
 
+function is_cached {
+        [ -n "$RRDCACHED_ADDRESS" ]
+}
+
 function exit_if_cached_running {
         local E="$1"
         local MSG="$2"
-        if [ -n "$RRDCACHED_ADDRESS" ] ; then
+        if is_cached ; then
                 echo >&2 "$MSG"
                 exit ${E:-1}
         fi
index ee0e0d5ab26cb22e022efe3cfb00a55ea06769d0..83e581ef8eeb6d5fe15a7ada3ab32939fa7bee73 100755 (executable)
@@ -17,11 +17,18 @@ done
 $RRDTOOL update ${BUILD}org.rrd --template a $U 
 report "update"
 
+# NOTE: for rrdcached based tests, we must flush before we can copy...
+is_cached && ( $RRDTOOL flushcached ${BUILD}org.rrd || fail flushcached)
+
+
 cp ${BUILD}org.rrd ${BUILD}a.rrd
 $RRDTOOL tune ${BUILD}a.rrd --heartbeat a:90 --minimum b:-100
 $RRDTOOL dump ${BUILD}a.rrd | $DIFF - ${BASE}a-mod1.dump
 report "tune heartbeat/minimum" 
 
+# NOTE: for rrdcached based tests, we must flush before we can copy...
+is_cached && ( $RRDTOOL flushcached ${BUILD}org.rrd || fail flushcached )
+
 cp ${BUILD}org.rrd ${BUILD}a.rrd
 $RRDTOOL tune ${BUILD}a.rrd --data-source-type a:COUNTER --data-source-rename b:c
 $RRDTOOL dump ${BUILD}a.rrd | $DIFF - ${BASE}a-mod2.dump
index 378e68c36606db14a77267d2be73e71cc518f258..f720dd1d34a4324fe6e633a9dac6e8aa3128aebe 100755 (executable)
@@ -11,10 +11,10 @@ $RRDTOOL create ${BUILD}org.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U
 $RRDTOOL dump ${BUILD}org.rrd | $DIFF - ${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
-[ $? != 0 ] 
+! $RRDTOOL tune ${BUILD}a.rrd --beta 1.4 2>/dev/null
 report "out of range beta error"
 $RRDTOOL dump ${BUILD}a.rrd | $DIFF - ${BASE}org.dump
 report "RRD unchanged"