File: ovsdb-lock.at

package info (click to toggle)
openvswitch 3.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 97,848 kB
  • sloc: sh: 1,643,930; ansic: 313,386; python: 27,939; xml: 21,526; makefile: 546; javascript: 191
file content (73 lines) | stat: -rw-r--r-- 2,529 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
AT_BANNER([OVSDB -- lock])

# OVSDB_CHECK_LOCK_SETUP(TITILE, KEYWORDS)
#
# Starts an OVSDB server and the default lock transaction, acquire "lock0",
# using the ovsdb-client tool.  Execute additional <LOCK_TRANSACTIONS>,
# and compare output file catured from ovsdb-client tools to <OUTPUT>.

m4_define([OVSDB_CHECK_LOCK_SETUP],
   [AT_SETUP([ovsdb lock -- $1])
    AT_SKIP_IF([test "$IS_WIN32" = "yes"])
    AT_KEYWORDS([ovsdb lock $2])
    ordinal_schema > schema
    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
    AT_CAPTURE_FILE([ovsdb-server.log])
    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])])

#
# Two sessions create two locks. Both sessions should be able to get their
# own lock immediately.
OVSDB_CHECK_LOCK_SETUP([lock], [positive])
AT_CHECK([ovsdb-client --detach --no-chdir lock unix:socket lock0 >c1-output 2>&1],
      [0], [], [])
AT_CHECK([ovsdb-client --detach --no-chdir lock unix:socket lock1 >c2-output 2>&1],
      [0], [], [])
OVSDB_SERVER_SHUTDOWN
AT_CHECK([cat c1-output], 0, [{"locked":true}
], [])
AT_CHECK([cat c2-output], 0, [{"locked":true}
], [])
AT_CLEANUP

#
# Two session wait on the same lock. The first session should be able
# to get the lock immediately, the second session will get a notification
# after the first session unlocks.
OVSDB_CHECK_LOCK_SETUP([unlock], [positive])
AT_CHECK([ovsdb-client --detach --no-chdir --pidfile lock unix:socket lock0 >c1-output 2>&1],
      [0], [], [])
AT_CHECK([ovsdb-client --detach --no-chdir lock unix:socket lock0 >c2-output 2>&1],
      [0], [], [])
AT_CHECK([ovs-appctl -t ovsdb-client unlock lock0], [0], [], [])
OVSDB_SERVER_SHUTDOWN
AT_CHECK([cat c1-output], 0, [{"locked":true}
{}
])
AT_CHECK([cat c2-output], 0, [{"locked":false}
locked
[["lock0"]]
], [])
AT_CLEANUP

#
# Two session waits on the same lock. The first session should be able
# to get the lock immediately. The second session tries to steal the lock, then
# unlocks the lock.
OVSDB_CHECK_LOCK_SETUP([steal], [positive])
AT_CHECK([ovsdb-client --detach --no-chdir lock unix:socket lock0 >c1-output 2>&1],
      [0], [], [])
AT_CHECK([ovsdb-client --detach --no-chdir --pidfile steal unix:socket lock0 >c2-output 2>&1],
      [0], [], [])
AT_CHECK([ovs-appctl -t ovsdb-client unlock lock0], [0], [], [])
OVSDB_SERVER_SHUTDOWN
AT_CHECK([cat c1-output], 0, [{"locked":true}
stolen
[["lock0"]]
locked
[["lock0"]]
])
AT_CHECK([cat c2-output], 0, [{"locked":true}
{}
], [])
AT_CLEANUP