File: rrdcached-test

package info (click to toggle)
rrdtool 1.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,772 kB
  • sloc: ansic: 39,371; sh: 1,810; perl: 1,268; cs: 652; makefile: 573; python: 169; ruby: 61; awk: 30
file content (52 lines) | stat: -rwxr-xr-x 1,327 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -e

echo "===== Starting rrdcached test ====="

TEST_RRD="/var/lib/rrdcached/db/cachedtest.rrd"
SOCK="/run/rrdcached.sock"

# Clean up previous runs
rm -f "$TEST_RRD"

# start socket
echo "--> rrdcached socket should be enabled"
systemctl status rrdcached.socket
systemctl is-enabled rrdcached.socket
systemctl is-active rrdcached.socket

echo "--> rrdcached service should not be active now"
if systemctl is-active rrdcached.service; then
    echo 'rrdcached.service should not be active'
    exit 1
fi
if systemctl is-enabled rrdcached.service; then
    echo 'rrdcached.service should not be enabled'
    exit 1
fi

# Create an RRD file for testing
echo "--> Creating RRD file..."
rrdtool create "$TEST_RRD" \
    --start now-10m --step 60 \
    --daemon "unix:$SOCK" \
    DS:test:GAUGE:120:0:100 \
    RRA:AVERAGE:0.5:1:10
echo "OK: RRD file created."

# Update via daemon
echo "--> Updating RRD via daemon..."
rrdtool update --daemon "unix:$SOCK" "$TEST_RRD" N:50
echo "OK: Update command sent to daemon."

# Flush data to disk
echo "--> Flushing data..."
rrdtool flushcached --daemon "unix:$SOCK" "$TEST_RRD"
echo "OK: Flush command sent."

# now the service should be active
echo "--> Check service being active now"
systemctl is-active rrdcached.service

echo "===== rrdcached test PASSED ====="
exit 0