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