]> git.proxmox.com Git - ovs.git/blame - tests/ovsdb-lock.at
tests: Convert ovsdb-monitor-sort utility from Perl to Python.
[ovs.git] / tests / ovsdb-lock.at
CommitLineData
0ec19def
AZ
1AT_BANNER([OVSDB -- lock])
2
3# OVSDB_CHECK_LOCK_SETUP(TITILE, KEYWORDS)
4#
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>.
8
9m4_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], [], [])])
17
18#
19# Two sessions create two locks. Both sessions should be able to get their
20# own lock immediately.
21OVSDB_CHECK_LOCK_SETUP([lock], [positive])
22AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c1-output 2>&1],
23 [0], [], [])
24AT_CHECK([ovsdb-client --detach lock unix:socket lock1 >c2-output 2>&1],
25 [0], [], [])
26OVS_APP_EXIT_AND_WAIT([ovsdb-server])
27AT_CHECK([cat c1-output], 0, [{"locked":true}
28], [])
29AT_CHECK([cat c2-output], 0, [{"locked":true}
30], [])
31AT_CLEANUP
32
33#
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.
37OVSDB_CHECK_LOCK_SETUP([unlock], [positive])
38AT_CHECK([ovsdb-client --detach --pidfile lock unix:socket lock0 >c1-output 2>&1],
39 [0], [], [])
40AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c2-output 2>&1],
41 [0], [], [])
42AT_CHECK([ovs-appctl -t ovsdb-client unlock lock0], [0], [], [])
43OVS_APP_EXIT_AND_WAIT([ovsdb-server])
44AT_CHECK([cat c1-output], 0, [{"locked":true}
45{}
46])
47AT_CHECK([cat c2-output], 0, [{"locked":false}
48locked
49[["lock0"]]
50], [])
51AT_CLEANUP
52
53#
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
56# unlocks the lock.
57OVSDB_CHECK_LOCK_SETUP([steal], [positive])
58AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c1-output 2>&1],
59 [0], [], [])
60AT_CHECK([ovsdb-client --detach --pidfile steal unix:socket lock0 >c2-output 2>&1],
61 [0], [], [])
62AT_CHECK([ovs-appctl -t ovsdb-client unlock lock0], [0], [], [])
63OVS_APP_EXIT_AND_WAIT([ovsdb-server])
64AT_CHECK([cat c1-output], 0, [{"locked":true}
65stolen
66[["lock0"]]
67locked
68[["lock0"]]
69])
70AT_CHECK([cat c2-output], 0, [{"locked":true}
71{}
72], [])
73AT_CLEANUP