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 AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output],
31 [0], [ignore], [ignore], [kill `cat server-pid`])
32 m4_foreach([txn], [$6],
33 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
34 [ignore], [ignore], [kill `cat server-pid client-pid`])])
35 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
36 [ignore], [ignore], [kill `cat server-pid client-pid`])
37 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore])
38 OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
39 AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore])
42 OVSDB_CHECK_MONITOR([monitor insert into empty table],
45 [ordinals], [ordinals],
49 "row": {"number": 0, "name": "zero"}}]]]],
50 [[row,action,name,number,_version
51 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
54 OVSDB_CHECK_MONITOR([monitor insert into populated table],
59 "row": {"number": 10, "name": "ten"}}]]]],
60 [ordinals], [ordinals],
64 "row": {"number": 0, "name": "zero"}}]]]],
65 [[row,action,name,number,_version
66 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
68 row,action,name,number,_version
69 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
72 OVSDB_CHECK_MONITOR([monitor delete],
77 "row": {"number": 10, "name": "ten"}}]]]],
78 [ordinals], [ordinals],
82 "where": [["number", "==", 10]]}]]]],
83 [[row,action,name,number,_version
84 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
86 row,action,name,number,_version
87 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
90 OVSDB_CHECK_MONITOR([monitor row update],
95 "row": {"number": 10, "name": "ten"}}]]]],
96 [ordinals], [ordinals],
100 "where": [["number", "==", 10]],
101 "row": {"name": "five plus five"}}]]]],
102 [[row,action,name,number,_version
103 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
105 row,action,name,number,_version
106 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
107 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
110 OVSDB_CHECK_MONITOR([monitor no-op row updates],
115 "row": {"number": 10, "name": "ten"}}]]]],
116 [ordinals], [ordinals],
120 "where": [["number", "==", 10]],
121 "row": {"number": 10, "name": "ten"}}]]],
125 "row": {"number": 9, "name": "nine"}}]]]],
126 [[row,action,name,number,_version
127 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
129 row,action,name,number,_version
130 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
133 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
138 "row": {"number": 10, "name": "ten"}}]]]],
139 [ordinals], [ordinals],
143 "row": {"number": 9, "name": "nine"},
144 "uuid-name": "nine"},
147 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
148 "row": {"name": "three squared"}}]]]],
149 [[row,action,name,number,_version
150 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
152 row,action,name,number,_version
153 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
156 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
161 "row": {"number": 10, "name": "ten"}}]]]],
162 [ordinals], [ordinals],
166 "row": {"number": 9, "name": "nine"},
167 "uuid-name": "nine"},
170 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
171 "row": {"name": "three squared"}},
174 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
177 "row": {"number": 7, "name": "seven"}}]]]],
178 [[row,action,name,number,_version
179 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
181 row,action,name,number,_version
182 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
185 OVSDB_CHECK_MONITOR([monitor weak reference change],
191 "a2a1": ["named-uuid", "a0"],
192 "a2b": ["named-uuid", "b2"]},
197 "a2a": ["named-uuid", "a0"],
198 "a2a1": ["named-uuid", "a1"],
199 "a2b": ["named-uuid", "b2"]},
204 "uuid-name": "b2"}]]]],
209 "where": [["a", "==", 0]]}]]]],
210 [[row,action,a,a2a,a2a1,a2b,_version
211 <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
212 <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
214 row,action,a,a2a,a2a1,a2b,_version
215 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
216 <3>,old,,"[""uuid"",""<0>""]",,,
217 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
220 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
225 "row": {"number": 10, "name": "ten"}}]]]],
226 [ordinals], [ordinals],
230 "row": {"number": 9, "name": "nine"},
231 "uuid-name": "nine"},
234 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
235 "row": {"name": "three squared"}},
238 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
241 "row": {"number": 7, "name": "seven"}}]]]],
242 [[row,action,name,number,_version
243 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
245 row,action,name,number,_version
246 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
249 AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
251 m4_define([OVSDB_MONITOR_INITIAL],
255 "row": {"number": 10, "name": "ten"}}]]]])
256 m4_define([OVSDB_MONITOR_TXNS],
260 "row": {"number": 5, "name": "five"}}]]],
264 "where": [["name", "==", "five"]],
265 "row": {"name": "FIVE"}}]]],
271 OVSDB_CHECK_MONITOR([monitor all operations],
272 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
273 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
274 [[row,action,name,number,_version
275 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
277 row,action,name,number,_version
278 <2>,insert,"""five""",5,"[""uuid"",""<3>""]"
280 row,action,name,number,_version
281 <2>,old,"""five""",,"[""uuid"",""<3>""]"
282 ,new,"""FIVE""",5,"[""uuid"",""<4>""]"
284 row,action,name,number,_version
285 <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
286 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
289 dnl A monitor with "initial" only doesn't really make sense,
290 dnl but it's still allowed and should work.
291 OVSDB_CHECK_MONITOR([monitor initial only],
292 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
293 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
294 [[row,action,name,number,_version
295 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
296 ]], [!insert,!delete,!modify])
298 OVSDB_CHECK_MONITOR([monitor insert only],
299 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
300 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
301 [[row,action,name,number,_version
302 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
303 ]], [!initial,!delete,!modify])
305 OVSDB_CHECK_MONITOR([monitor delete only],
306 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
307 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
308 [[row,action,name,number,_version
309 <0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
310 <2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
311 ]], [!initial,!insert,!modify])
313 OVSDB_CHECK_MONITOR([monitor modify only],
314 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
315 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
316 [[row,action,name,number,_version
317 <0>,old,"""five""",,"[""uuid"",""<1>""]"
318 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"
319 ]], [!initial,!insert,!delete])