Code

plugin: Dynamically populate timeseries information when querying metrics.
[sysdb.git] / t / integration / query_timeseries.sh
1 #! /bin/bash
2 #
3 # SysDB -- t/integration/basic_query.sh
4 # Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 #    notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 #    notice, this list of conditions and the following disclaimer in the
14 #    documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
20 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #
29 # Integration tests using basic queries.
30 #
32 set -ex
34 source "$( dirname "$0" )/test_lib.sh"
36 cat <<EOF > "$SYSDBD_CONF"
37 Listen "$SOCKET_FILE"
38 PluginDir "$PLUGIN_DIR"
39 Interval 2
41 LoadPlugin "store::memory"
42 LoadPlugin "mock_timeseries"
43 EOF
45 run_sysdbd -D -C "$SYSDBD_CONF"
46 wait_for_sysdbd
48 cat <<EOF > "${SYSDBD_CONF}.sender"
49 Listen "${SOCKET_FILE}.sender"
50 PluginDir "$PLUGIN_DIR"
51 Interval 2
53 LoadPlugin "store::network"
54 <Plugin "store::network">
55   Server "$SOCKET_FILE"
56 </Plugin>
58 LoadBackend "mock_plugin"
59 <Backend "mock_plugin">
60 </Backend>
61 EOF
63 run_sysdbd_foreground -D -C "${SYSDBD_CONF}.sender" &
64 SYSDBD_PID2=$!
65 trap "kill \$SYSDBD_PID2" EXIT
66 wait_for_sysdbd "${SOCKET_FILE}.sender"
68 # wait for initial data
69 sleep 3
71 # Check data-source names.
72 output="$( run_sysdb -H "$SOCKET_FILE" \
73         -c "FETCH metric 'some.host.name'.'foo/bar/qux'" )"
74 echo "$output" | grep -F '"data_names": ["nameA", "nameB"]'
76 # TIMESERIES commands.
77 run_sysdb -H "$SOCKET_FILE" \
78                 -c "TIMESERIES 'invalid.host'.'invalid-metric'" && exit 1
80 output="$( run_sysdb -H "$SOCKET_FILE" \
81         -c "TIMESERIES 'some.host.name'.'foo/bar/qux'" )"
82 echo "$output" \
83         | grep -F '"value": "1.000000"' \
84         | grep -F '"value": "2.000000"' \
85         | grep -F '"value": "3.000000"' \
86         | grep -F '"value": "4.000000"' \
87         | grep -F '"value": "5.000000"' \
88         | grep -F '"value": "6.000000"' \
89         | grep -F '"value": "7.000000"' \
90         | grep -F '"value": "8.000000"' \
91         | grep -F '"value": "9.000000"' \
92         | grep -F '"value": "10.000000"'
94 stop_sysdbd
96 # vim: set tw=78 sw=4 ts=4 noexpandtab :