1 AT_BANNER([OVSDB -- ovsdb-server monitors])
3 # OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
4 # TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS])
6 # Creates a database with the given SCHEMA, starts an ovsdb-server on
7 # that database, and runs each of the TRANSACTIONS (which should be a
8 # quoted list of quoted strings) against it with ovsdb-client one at a
9 # time. COLUMNS, if specified, is passed to ovsdb-client as the set
10 # of columns and operations to select.
12 # Checks that the overall output is OUTPUT, but UUIDs in the output
13 # are replaced by markers of the form <N> where N is a number. The
14 # first unique UUID is replaced by <0>, the next by <1>, and so on.
15 # If a given UUID appears more than once it is always replaced by the
18 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
19 m4_define([OVSDB_CHECK_MONITOR],
21 AT_KEYWORDS([ovsdb server monitor positive $9])
22 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
24 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
25 m4_foreach([txn], [$3],
26 [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])])
27 AT_CAPTURE_FILE([ovsdb-server-log])
28 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/server-pid --remote=punix:socket --unixctl="`pwd`"/unixctl --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1],
30 if test "$IS_WIN32" = "yes"; then
31 AT_CHECK([ovsdb-client -vjsonrpc --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output &],
32 [0], [ignore], [ignore], [kill `cat server-pid`])
35 AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output],
36 [0], [ignore], [ignore], [kill `cat server-pid`])
38 m4_foreach([txn], [$6],
39 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
40 [ignore], [ignore], [kill `cat server-pid client-pid`])])
41 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
42 [ignore], [ignore], [kill `cat server-pid client-pid`])
43 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore])
44 OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
45 AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore])
48 OVSDB_CHECK_MONITOR([monitor insert into empty table],
51 [ordinals], [ordinals],
55 "row": {"number": 0, "name": "zero"}}]]]],
56 [[row,action,name,number,_version
57 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
60 OVSDB_CHECK_MONITOR([monitor insert into populated table],
65 "row": {"number": 10, "name": "ten"}}]]]],
66 [ordinals], [ordinals],
70 "row": {"number": 0, "name": "zero"}}]]]],
71 [[row,action,name,number,_version
72 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
74 row,action,name,number,_version
75 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
78 OVSDB_CHECK_MONITOR([monitor delete],
83 "row": {"number": 10, "name": "ten"}}]]]],
84 [ordinals], [ordinals],
88 "where": [["number", "==", 10]]}]]]],
89 [[row,action,name,number,_version
90 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
92 row,action,name,number,_version
93 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
96 OVSDB_CHECK_MONITOR([monitor row update],
101 "row": {"number": 10, "name": "ten"}}]]]],
102 [ordinals], [ordinals],
106 "where": [["number", "==", 10]],
107 "row": {"name": "five plus five"}}]]]],
108 [[row,action,name,number,_version
109 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
111 row,action,name,number,_version
112 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
113 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
116 OVSDB_CHECK_MONITOR([monitor no-op row updates],
121 "row": {"number": 10, "name": "ten"}}]]]],
122 [ordinals], [ordinals],
126 "where": [["number", "==", 10]],
127 "row": {"number": 10, "name": "ten"}}]]],
131 "row": {"number": 9, "name": "nine"}}]]]],
132 [[row,action,name,number,_version
133 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
135 row,action,name,number,_version
136 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
139 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
144 "row": {"number": 10, "name": "ten"}}]]]],
145 [ordinals], [ordinals],
149 "row": {"number": 9, "name": "nine"},
150 "uuid-name": "nine"},
153 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
154 "row": {"name": "three squared"}}]]]],
155 [[row,action,name,number,_version
156 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
158 row,action,name,number,_version
159 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
162 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
167 "row": {"number": 10, "name": "ten"}}]]]],
168 [ordinals], [ordinals],
172 "row": {"number": 9, "name": "nine"},
173 "uuid-name": "nine"},
176 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
177 "row": {"name": "three squared"}},
180 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
183 "row": {"number": 7, "name": "seven"}}]]]],
184 [[row,action,name,number,_version
185 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
187 row,action,name,number,_version
188 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
191 OVSDB_CHECK_MONITOR([monitor weak reference change],
197 "a2a1": ["named-uuid", "a0"],
198 "a2b": ["named-uuid", "b2"]},
203 "a2a": ["named-uuid", "a0"],
204 "a2a1": ["named-uuid", "a1"],
205 "a2b": ["named-uuid", "b2"]},
210 "uuid-name": "b2"}]]]],
215 "where": [["a", "==", 0]]}]]]],
216 [[row,action,a,a2a,a2a1,a2b,_version
217 <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
218 <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
220 row,action,a,a2a,a2a1,a2b,_version
221 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
222 <3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
223 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
226 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
231 "row": {"number": 10, "name": "ten"}}]]]],
232 [ordinals], [ordinals],
236 "row": {"number": 9, "name": "nine"},
237 "uuid-name": "nine"},
240 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
241 "row": {"name": "three squared"}},
244 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
247 "row": {"number": 7, "name": "seven"}}]]]],
248 [[row,action,name,number,_version
249 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
251 row,action,name,number,_version
252 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
255 AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
257 m4_define([OVSDB_MONITOR_INITIAL],
261 "row": {"number": 10, "name": "ten"}}]]]])
262 m4_define([OVSDB_MONITOR_TXNS],
266 "row": {"number": 5, "name": "five"}}]]],
270 "where": [["name", "==", "five"]],
271 "row": {"name": "FIVE"}}]]],
277 OVSDB_CHECK_MONITOR([monitor all operations],
278 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
279 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
280 [[row,action,name,number,_version
281 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
283 row,action,name,number,_version
284 <2>,insert,"""five""",5,"[""uuid"",""<3>""]"
286 row,action,name,number,_version
287 <2>,old,"""five""",,"[""uuid"",""<3>""]"
288 ,new,"""FIVE""",5,"[""uuid"",""<4>""]"
290 row,action,name,number,_version
291 <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
292 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
295 dnl A monitor with "initial" only doesn't really make sense,
296 dnl but it's still allowed and should work.
297 OVSDB_CHECK_MONITOR([monitor initial only],
298 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
299 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
300 [[row,action,name,number,_version
301 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
302 ]], [!insert,!delete,!modify])
304 OVSDB_CHECK_MONITOR([monitor insert only],
305 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
306 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
307 [[row,action,name,number,_version
308 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
309 ]], [!initial,!delete,!modify])
311 OVSDB_CHECK_MONITOR([monitor delete only],
312 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
313 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
314 [[row,action,name,number,_version
315 <0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
316 <2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
317 ]], [!initial,!insert,!modify])
319 OVSDB_CHECK_MONITOR([monitor modify only],
320 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
321 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
322 [[row,action,name,number,_version
323 <0>,old,"""five""",,"[""uuid"",""<1>""]"
324 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"
325 ]], [!initial,!insert,!delete])