Code

store::memory: Add a plugin providing an in-memory store.
[sysdb.git] / t / integration / client.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 covering basic client functionality.
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 LoadBackend "mock_plugin"
43 <Backend "mock_plugin">
44 </Backend>
46 LoadPlugin "mock_timeseries"
47 EOF
49 run_sysdbd -D -C "$SYSDBD_CONF"
50 wait_for_sysdbd
52 # wait for initial data
53 sleep 3
55 # Usage errors.
56 output="$( run_sysdb -H "$SOCKET_FILE" --invalid 2>&1 )" && exit 1
57 echo "$output" | grep -F 'Usage:'
58 output="$( run_sysdb -H "$SOCKET_FILE" extra 2>&1 )" && exit 1
59 echo "$output" | grep -F 'Usage:'
61 # Invalid user.
62 output="$( run_sysdb_nouser -H "$SOCKET_FILE" \
63   -U $SYSDB_USER-invalid -c 'LIST hosts' 2>&1 )" && exit 1
64 echo "$output" | grep -F 'Access denied'
66 # Unreachable server.
67 output="$( run_sysdb -H "${SOCKET_FILE}.doesnotexist" -c '' 2>&1 )" && exit 1
68 echo "$output" | grep "Failed to connect to SysDBd"
70 # On parse errors, expect a non-zero exit code.
71 output="$( run_sysdb -H "$SOCKET_FILE" -c INVALID 2>&1 )" && exit 1
72 echo "$output" | grep "Failed to parse query 'INVALID'"
73 echo "$output" | grep "parse error: syntax error"
75 # Empty query.
76 output="$( run_sysdb -H "$SOCKET_FILE" -c '' )"
77 test -z "$output"
79 # Default user.
80 output="$( run_sysdb_nouser -H "$SOCKET_FILE" -c '' )"
82 stop_sysdbd
84 # vim: set tw=78 sw=4 ts=4 noexpandtab :