X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Fintegration%2Fquery.sh;h=72a0b88426adae7496deee4c9b4d8f6d7e845c02;hb=c51faedff43c34207645ae6c45f7355e35160e1d;hp=39522cf9be6c09928952f121b621b6121286e54a;hpb=6efa08926a3f15b38dd008198680a60c80a5fc63;p=sysdb.git diff --git a/t/integration/query.sh b/t/integration/query.sh index 39522cf..72a0b88 100755 --- a/t/integration/query.sh +++ b/t/integration/query.sh @@ -38,18 +38,42 @@ Listen "$SOCKET_FILE" PluginDir "$PLUGIN_DIR" Interval 2 +LoadPlugin mock_timeseries +EOF + +run_sysdbd -D -C "$SYSDBD_CONF" +wait_for_sysdbd + +cat < "${SYSDBD_CONF}.sender" +Listen "${SOCKET_FILE}.sender" +PluginDir "$PLUGIN_DIR" +Interval 2 + +LoadPlugin "store::network" + + Server "$SOCKET_FILE" + + LoadBackend mock_plugin EOF -run_sysdbd -D -C "$SYSDBD_CONF" +run_sysdbd_foreground -D -C "${SYSDBD_CONF}.sender" & +SYSDBD_PID2=$! +trap "kill \$SYSDBD_PID2" EXIT +wait_for_sysdbd "${SOCKET_FILE}.sender" -wait_for_sysdbd +# wait for initial data sleep 3 +# Invalid user. +output="$( run_sysdb_nouser -H "$SOCKET_FILE" \ + -U $SYSDB_USER-invalid -c 'LIST hosts' 2>&1 )" && exit 1 +echo "$output" | grep -F 'Access denied' + # On parse errors, expect a non-zero exit code. -output="$( run_sysdb -H "$SOCKET_FILE" -c INVALID )" && exit 1 +output="$( run_sysdb -H "$SOCKET_FILE" -c INVALID 2>&1 )" && exit 1 echo "$output" | grep "Failed to parse query 'INVALID'" echo "$output" | grep "parse error: syntax error" @@ -94,24 +118,40 @@ echo "$output" | grep -F 'other.host.name' && exit 1 echo "$output" | grep -F 'some.host.name' && exit 1 output="$( run_sysdb -H "$SOCKET_FILE" \ - -c "FETCH host 'host1.example.com' FILTER last_update < 0" )" \ + -c "FETCH host 'host1.example.com' FILTER last_update < 0" 2>&1 )" \ && exit 1 echo "$output" | grep -F 'not found' (echo 'LIST hosts;'; sleep 1; echo "FETCH host 'host1.example.com'") \ | run_sysdb -H "$SOCKET_FILE" +output="$( run_sysdb -H "$SOCKET_FILE" \ + -c "FETCH host 'host1.example.com' FILTER age < 0" 2>&1 )" && exit 1 +echo "$output" | grep -F 'not found' + # When requesting information for unknown hosts, expect a non-zero exit code. -output="$( run_sysdb -H "$SOCKET_FILE" -c "FETCH host 'does.not.exist'" )" \ - && exit 1 +output="$( run_sysdb -H "$SOCKET_FILE" \ + -c "FETCH host 'does.not.exist'" 2>&1 )" && exit 1 echo "$output" | grep -F 'not found' run_sysdb -H "$SOCKET_FILE" \ -c "TIMESERIES 'invalid.host'.'invalid-metric'" && exit 1 # Does not work yet since there is no fetcher plugin. -run_sysdb -H "$SOCKET_FILE" \ - -c "TIMESERIES 'some.host.name'.'foo/bar/qux'" && exit 1 +output="$( run_sysdb -H "$SOCKET_FILE" \ + -c "TIMESERIES 'some.host.name'.'foo/bar/qux'" )" +echo "$output" \ + | grep -F '"value": "1.000000"' \ + | grep -F '"value": "2.000000"' \ + | grep -F '"value": "3.000000"' \ + | grep -F '"value": "4.000000"' \ + | grep -F '"value": "5.000000"' \ + | grep -F '"value": "6.000000"' \ + | grep -F '"value": "7.000000"' \ + | grep -F '"value": "8.000000"' \ + | grep -F '"value": "9.000000"' \ + | grep -F '"value": "10.000000"' stop_sysdbd +# vim: set tw=78 sw=4 ts=4 noexpandtab :