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])
23 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
24 m4_foreach([txn], [$3],
25 [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])])
26 AT_CAPTURE_FILE([ovsdb-server-log])
27 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],
29 AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output],
30 [0], [ignore], [ignore], [kill `cat server-pid`])
31 m4_foreach([txn], [$6],
32 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
33 [ignore], [ignore], [kill `cat server-pid client-pid`])])
34 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
35 [ignore], [ignore], [kill `cat server-pid client-pid`])
36 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore])
37 OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
38 AT_CHECK([perl $srcdir/ovsdb-monitor-sort.pl < output | perl $srcdir/uuidfilt.pl], [0], [$7], [ignore])
41 OVSDB_CHECK_MONITOR([monitor insert into empty table],
44 [ordinals], [ordinals],
48 "row": {"number": 0, "name": "zero"}}]]]],
49 [[row,action,name,number,_version
50 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
53 OVSDB_CHECK_MONITOR([monitor insert into populated table],
58 "row": {"number": 10, "name": "ten"}}]]]],
59 [ordinals], [ordinals],
63 "row": {"number": 0, "name": "zero"}}]]]],
64 [[row,action,name,number,_version
65 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
67 row,action,name,number,_version
68 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
71 OVSDB_CHECK_MONITOR([monitor delete],
76 "row": {"number": 10, "name": "ten"}}]]]],
77 [ordinals], [ordinals],
81 "where": [["number", "==", 10]]}]]]],
82 [[row,action,name,number,_version
83 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
85 row,action,name,number,_version
86 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
89 OVSDB_CHECK_MONITOR([monitor row update],
94 "row": {"number": 10, "name": "ten"}}]]]],
95 [ordinals], [ordinals],
99 "where": [["number", "==", 10]],
100 "row": {"name": "five plus five"}}]]]],
101 [[row,action,name,number,_version
102 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
104 row,action,name,number,_version
105 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
106 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
109 OVSDB_CHECK_MONITOR([monitor no-op row updates],
114 "row": {"number": 10, "name": "ten"}}]]]],
115 [ordinals], [ordinals],
119 "where": [["number", "==", 10]],
120 "row": {"number": 10, "name": "ten"}}]]],
124 "row": {"number": 9, "name": "nine"}}]]]],
125 [[row,action,name,number,_version
126 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
128 row,action,name,number,_version
129 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
132 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
137 "row": {"number": 10, "name": "ten"}}]]]],
138 [ordinals], [ordinals],
142 "row": {"number": 9, "name": "nine"},
143 "uuid-name": "nine"},
146 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
147 "row": {"name": "three squared"}}]]]],
148 [[row,action,name,number,_version
149 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
151 row,action,name,number,_version
152 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
155 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
160 "row": {"number": 10, "name": "ten"}}]]]],
161 [ordinals], [ordinals],
165 "row": {"number": 9, "name": "nine"},
166 "uuid-name": "nine"},
169 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
170 "row": {"name": "three squared"}},
173 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
176 "row": {"number": 7, "name": "seven"}}]]]],
177 [[row,action,name,number,_version
178 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
180 row,action,name,number,_version
181 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
184 OVSDB_CHECK_MONITOR([monitor weak reference change],
190 "a2a1": ["named-uuid", "a0"],
191 "a2b": ["named-uuid", "b2"]},
196 "a2a": ["named-uuid", "a0"],
197 "a2a1": ["named-uuid", "a1"],
198 "a2b": ["named-uuid", "b2"]},
203 "uuid-name": "b2"}]]]],
208 "where": [["a", "==", 0]]}]]]],
209 [[row,action,a,a2a,a2a1,a2b,_version
210 <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
211 <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
213 row,action,a,a2a,a2a1,a2b,_version
214 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
215 <3>,old,,"[""uuid"",""<0>""]",,,
216 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
219 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
224 "row": {"number": 10, "name": "ten"}}]]]],
225 [ordinals], [ordinals],
229 "row": {"number": 9, "name": "nine"},
230 "uuid-name": "nine"},
233 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
234 "row": {"name": "three squared"}},
237 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
240 "row": {"number": 7, "name": "seven"}}]]]],
241 [[row,action,name,number,_version
242 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
244 row,action,name,number,_version
245 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
248 AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
250 m4_define([OVSDB_MONITOR_INITIAL],
254 "row": {"number": 10, "name": "ten"}}]]]])
255 m4_define([OVSDB_MONITOR_TXNS],
259 "row": {"number": 5, "name": "five"}}]]],
263 "where": [["name", "==", "five"]],
264 "row": {"name": "FIVE"}}]]],
270 OVSDB_CHECK_MONITOR([monitor all operations],
271 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
272 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
273 [[row,action,name,number,_version
274 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
276 row,action,name,number,_version
277 <2>,insert,"""five""",5,"[""uuid"",""<3>""]"
279 row,action,name,number,_version
280 <2>,old,"""five""",,"[""uuid"",""<3>""]"
281 ,new,"""FIVE""",5,"[""uuid"",""<4>""]"
283 row,action,name,number,_version
284 <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
285 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
288 dnl A monitor with "initial" only doesn't really make sense,
289 dnl but it's still allowed and should work.
290 OVSDB_CHECK_MONITOR([monitor initial only],
291 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
292 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
293 [[row,action,name,number,_version
294 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
295 ]], [!insert,!delete,!modify])
297 OVSDB_CHECK_MONITOR([monitor insert only],
298 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
299 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
300 [[row,action,name,number,_version
301 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
302 ]], [!initial,!delete,!modify])
304 OVSDB_CHECK_MONITOR([monitor delete only],
305 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
306 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
307 [[row,action,name,number,_version
308 <0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
309 <2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
310 ]], [!initial,!insert,!modify])
312 OVSDB_CHECK_MONITOR([monitor modify only],
313 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
314 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
315 [[row,action,name,number,_version
316 <0>,old,"""five""",,"[""uuid"",""<1>""]"
317 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"
318 ]], [!initial,!insert,!delete])