1 AT_BANNER([OVSDB -- lock])
3 # OVSDB_CHECK_LOCK_SETUP(TITILE, KEYWORDS)
5 # Starts an OVSDB server and the default lock transaction, acquire "lock0",
6 # using the ovsdb-client tool. Execute additional <LOCK_TRANSACTIONS>,
7 # and compare output file catured from ovsdb-client tools to <OUTPUT>.
9 m4_define([OVSDB_CHECK_LOCK_SETUP],
10 [AT_SETUP([ovsdb lock -- $1])
11 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
12 AT_KEYWORDS([ovsdb lock $2])
13 ordinal_schema > schema
14 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
15 AT_CAPTURE_FILE([ovsdb-server-log])
16 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1], [0], [], [])])
19 # Two sessions create two locks. Both sessions should be able to get their
20 # own lock immediately.
21 OVSDB_CHECK_LOCK_SETUP([lock], [positive])
22 AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c1-output 2>&1],
24 AT_CHECK([ovsdb-client --detach lock unix:socket lock1 >c2-output 2>&1],
26 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
27 AT_CHECK([cat c1-output], 0, [{"locked":true}
29 AT_CHECK([cat c2-output], 0, [{"locked":true}
34 # Two session wait on the same lock. The first session should be able
35 # to get the lock immediately, the second session will get a notification
36 # after the first session unlocks.
37 OVSDB_CHECK_LOCK_SETUP([unlock], [positive])
38 AT_CHECK([ovsdb-client --detach --pidfile lock unix:socket lock0 >c1-output 2>&1],
40 AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c2-output 2>&1],
42 AT_CHECK([ovs-appctl -t ovsdb-client unlock lock0], [0], [], [])
43 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
44 AT_CHECK([cat c1-output], 0, [{"locked":true}
47 AT_CHECK([cat c2-output], 0, [{"locked":false}
54 # Two session waits on the same lock. The first session should be able
55 # to get the lock immediately. The second session tries to steal the lock, then
57 OVSDB_CHECK_LOCK_SETUP([steal], [positive])
58 AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c1-output 2>&1],
60 AT_CHECK([ovsdb-client --detach --pidfile steal unix:socket lock0 >c2-output 2>&1],
62 AT_CHECK([ovs-appctl -t ovsdb-client unlock lock0], [0], [], [])
63 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
64 AT_CHECK([cat c1-output], 0, [{"locked":true}
70 AT_CHECK([cat c2-output], 0, [{"locked":true}