]> git.proxmox.com Git - mirror_ovs.git/blame - tests/jsonrpc-py.at
dpif_packet: Rename to dp_packet
[mirror_ovs.git] / tests / jsonrpc-py.at
CommitLineData
99155935
BP
1AT_BANNER([JSON-RPC - Python])
2
3AT_SETUP([JSON-RPC request and successful reply - Python])
4AT_SKIP_IF([test $HAVE_PYTHON = no])
2c487bc8 5OVS_RUNDIR=`pwd`; export OVS_RUNDIR
b153e667 6AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile=`pwd`/pid listen punix:socket])
99155935
BP
7AT_CHECK([test -s pid])
8AT_CHECK([kill -0 `cat pid`])
9AT_CHECK(
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}]}
7fcfe998 12]], [], [test ! -e pid || kill `cat pid`])
99155935
BP
13AT_CHECK([kill `cat pid`])
14AT_CLEANUP
15
16AT_SETUP([JSON-RPC request and error reply - Python])
17AT_SKIP_IF([test $HAVE_PYTHON = no])
2c487bc8 18OVS_RUNDIR=`pwd`; export OVS_RUNDIR
b153e667 19AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile=`pwd`/pid listen punix:socket])
99155935
BP
20AT_CHECK([test -s pid])
21AT_CHECK([kill -0 `cat pid`])
22AT_CHECK(
23 [[$PYTHON $srcdir/test-jsonrpc.py request unix:socket bad-request '[]']], [0],
24 [[{"error":{"error":"unknown method"},"id":0,"result":null}
7fcfe998 25]], [], [test ! -e pid || kill `cat pid`])
99155935
BP
26AT_CHECK([kill `cat pid`])
27AT_CLEANUP
28
29AT_SETUP([JSON-RPC notification - Python])
30AT_SKIP_IF([test $HAVE_PYTHON = no])
2c487bc8 31OVS_RUNDIR=`pwd`; export OVS_RUNDIR
b153e667 32AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile=`pwd`/pid listen punix:socket])
99155935
BP
33AT_CHECK([test -s pid])
34# When a daemon dies it deletes its pidfile, so make a copy.
35AT_CHECK([cp pid pid2])
36AT_CHECK([kill -0 `cat pid2`])
37AT_CHECK([[$PYTHON $srcdir/test-jsonrpc.py notify unix:socket shutdown '[]']], [0], [],
7fcfe998 38 [], [kill `cat pid2`])
99155935
BP
39AT_CHECK(
40 [pid=`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
49], [ignore])
50AT_CHECK([test ! -e pid])
51AT_CLEANUP