]> git.proxmox.com Git - mirror_ovs.git/blame - tests/jsonrpc.at
check-kmod: Remove all OVS modules in this target.
[mirror_ovs.git] / tests / jsonrpc.at
CommitLineData
99155935 1AT_BANNER([JSON-RPC - C])
f2129093
BP
2
3AT_SETUP([JSON-RPC request and successful reply])
eadd1644 4AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
f2129093
BP
5AT_CHECK([test -s pid])
6AT_CHECK([kill -0 `cat pid`])
7AT_CHECK(
eadd1644 8 [[ovstest test-jsonrpc request unix:socket echo '[{"a": "b", "x": null}]']], [0],
f2129093 9 [[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
7fcfe998 10]], [], [test ! -e pid || kill `cat pid`])
f2129093
BP
11AT_CHECK([kill `cat pid`])
12AT_CLEANUP
13
14AT_SETUP([JSON-RPC request and error reply])
eadd1644 15AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
f2129093
BP
16AT_CHECK([test -s pid])
17AT_CHECK([kill -0 `cat pid`])
18AT_CHECK(
eadd1644 19 [[ovstest test-jsonrpc request unix:socket bad-request '[]']], [0],
f2129093 20 [[{"error":{"error":"unknown method"},"id":0,"result":null}
7fcfe998 21]], [], [test ! -e pid || kill `cat pid`])
f2129093
BP
22AT_CHECK([kill `cat pid`])
23AT_CLEANUP
24
25AT_SETUP([JSON-RPC notification])
eadd1644 26AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
f2129093
BP
27AT_CHECK([test -s pid])
28# When a daemon dies it deletes its pidfile, so make a copy.
29AT_CHECK([cp pid pid2])
30AT_CHECK([kill -0 `cat pid2`])
eadd1644 31AT_CHECK([[ovstest test-jsonrpc notify unix:socket shutdown '[]']], [0], [],
7fcfe998 32 [], [kill `cat pid2`])
f2129093
BP
33AT_CHECK(
34 [pid=`cat pid2`
35 # First try a quick sleep, so that the test completes very quickly
36 # in the normal case. POSIX doesn't require fractional times to
37 # work, so this might not work.
38 sleep 0.1; if kill -0 $pid; then :; else echo success; exit 0; fi
39 # Then wait up to 2 seconds.
40 sleep 1; if kill -0 $pid; then :; else echo success; exit 0; fi
41 sleep 1; if kill -0 $pid; then :; else echo success; exit 0; fi
42 echo failure; exit 1], [0], [success
43], [ignore])
44AT_CHECK([test ! -e pid])
45AT_CLEANUP