1 AT_BANNER([JSON-RPC - Python])
3 AT_SETUP([JSON-RPC request and successful reply - Python])
4 AT_SKIP_IF([test $HAVE_PYTHON = no])
5 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
6 AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile=`pwd`/pid listen punix:socket])
7 AT_CHECK([test -s pid])
8 AT_CHECK([kill -0 `cat pid`])
10 [[$PYTHON $srcdir/test-jsonrpc.py request unix:socket echo '[{"a": "b", "x": null}]']], [0],
11 [[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
12 ]], [], [test ! -e pid || kill `cat pid`])
13 AT_CHECK([kill `cat pid`])
16 AT_SETUP([JSON-RPC request and error reply - Python])
17 AT_SKIP_IF([test $HAVE_PYTHON = no])
18 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
19 AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile=`pwd`/pid listen punix:socket])
20 AT_CHECK([test -s pid])
21 AT_CHECK([kill -0 `cat pid`])
23 [[$PYTHON $srcdir/test-jsonrpc.py request unix:socket bad-request '[]']], [0],
24 [[{"error":{"error":"unknown method"},"id":0,"result":null}
25 ]], [], [test ! -e pid || kill `cat pid`])
26 AT_CHECK([kill `cat pid`])
29 AT_SETUP([JSON-RPC notification - Python])
30 AT_SKIP_IF([test $HAVE_PYTHON = no])
31 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
32 AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile=`pwd`/pid listen punix:socket])
33 AT_CHECK([test -s pid])
34 # When a daemon dies it deletes its pidfile, so make a copy.
35 AT_CHECK([cp pid pid2])
36 AT_CHECK([kill -0 `cat pid2`])
37 AT_CHECK([[$PYTHON $srcdir/test-jsonrpc.py notify unix:socket shutdown '[]']], [0], [],
38 [], [kill `cat pid2`])
41 # First try a quick sleep, so that the test completes very quickly
42 # in the normal case. POSIX doesn't require fractional times to
43 # work, so this might not work.
44 sleep 0.1; if kill -0 $pid; then :; else echo success; exit 0; fi
45 # Then wait up to 2 seconds.
46 sleep 1; if kill -0 $pid; then :; else echo success; exit 0; fi
47 sleep 1; if kill -0 $pid; then :; else echo success; exit 0; fi
48 echo failure; exit 1], [0], [success
50 AT_CHECK([test ! -e pid])