1 AT_BANNER([OVSDB -- ovsdb-server monitors])
3 # OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
4 # TRANSACTIONS, OUTPUT, [SELECT], [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. SELECT, if specified, is passed to ovsdb-client as the
10 # operations to select. It should be a comma-separated list of
11 # "initial", "insert", "delete", or "modify" keywords.
13 # Checks that the overall output is OUTPUT, but UUIDs in the output
14 # are replaced by markers of the form <N> where N is a number. The
15 # first unique UUID is replaced by <0>, the next by <1>, and so on.
16 # If a given UUID appears more than once it is always replaced by the
19 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
20 m4_define([OVSDB_CHECK_MONITOR],
22 AT_KEYWORDS([ovsdb server monitor positive $9])
25 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
26 m4_foreach([txn], [$3],
27 [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])])
28 AT_CAPTURE_FILE([ovsdb-server-log])
29 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/server-pid --remote=punix:socket --unixctl=$PWD/unixctl --log-file=$PWD/ovsdb-server-log db >/dev/null 2>&1],
31 AT_CHECK([ovsdb-client -vjsonrpc --detach --pidfile=$PWD/client-pid -d json monitor --format=csv unix:socket $4 $5 '' $8 > output],
32 [0], [ignore], [ignore], [kill `cat server-pid`])
33 m4_foreach([txn], [$6],
34 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
35 [ignore], [ignore], [kill `cat server-pid client-pid`])])
36 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
37 [ignore], [ignore], [kill `cat server-pid client-pid`])
38 AT_CHECK([ovs-appctl -t $PWD/unixctl -e exit], [0], [ignore], [ignore])
39 OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
40 AT_CHECK([perl $srcdir/ovsdb-monitor-sort.pl < output | perl $srcdir/uuidfilt.pl], [0], [$7], [ignore])
43 OVSDB_CHECK_MONITOR([monitor insert into empty table],
46 [ordinals], [ordinals],
50 "row": {"number": 0, "name": "zero"}}]]]],
51 [[row,action,name,number,_version
52 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
55 OVSDB_CHECK_MONITOR([monitor insert into populated table],
60 "row": {"number": 10, "name": "ten"}}]]]],
61 [ordinals], [ordinals],
65 "row": {"number": 0, "name": "zero"}}]]]],
66 [[row,action,name,number,_version
67 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
69 row,action,name,number,_version
70 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
73 OVSDB_CHECK_MONITOR([monitor delete],
78 "row": {"number": 10, "name": "ten"}}]]]],
79 [ordinals], [ordinals],
83 "where": [["number", "==", 10]]}]]]],
84 [[row,action,name,number,_version
85 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
87 row,action,name,number,_version
88 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
91 OVSDB_CHECK_MONITOR([monitor row update],
96 "row": {"number": 10, "name": "ten"}}]]]],
97 [ordinals], [ordinals],
101 "where": [["number", "==", 10]],
102 "row": {"name": "five plus five"}}]]]],
103 [[row,action,name,number,_version
104 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
106 row,action,name,number,_version
107 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
108 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
111 OVSDB_CHECK_MONITOR([monitor no-op row updates],
116 "row": {"number": 10, "name": "ten"}}]]]],
117 [ordinals], [ordinals],
121 "where": [["number", "==", 10]],
122 "row": {"number": 10, "name": "ten"}}]]],
126 "row": {"number": 9, "name": "nine"}}]]]],
127 [[row,action,name,number,_version
128 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
130 row,action,name,number,_version
131 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
134 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
139 "row": {"number": 10, "name": "ten"}}]]]],
140 [ordinals], [ordinals],
144 "row": {"number": 9, "name": "nine"},
145 "uuid-name": "nine"},
148 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
149 "row": {"name": "three squared"}}]]]],
150 [[row,action,name,number,_version
151 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
153 row,action,name,number,_version
154 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
157 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
162 "row": {"number": 10, "name": "ten"}}]]]],
163 [ordinals], [ordinals],
167 "row": {"number": 9, "name": "nine"},
168 "uuid-name": "nine"},
171 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
172 "row": {"name": "three squared"}},
175 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
178 "row": {"number": 7, "name": "seven"}}]]]],
179 [[row,action,name,number,_version
180 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
182 row,action,name,number,_version
183 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
186 OVSDB_CHECK_MONITOR([monitor weak reference change],
192 "a2a1": ["named-uuid", "a0"],
193 "a2b": ["named-uuid", "b2"]},
198 "a2a": ["named-uuid", "a0"],
199 "a2a1": ["named-uuid", "a1"],
200 "a2b": ["named-uuid", "b2"]},
205 "uuid-name": "b2"}]]]],
210 "where": [["a", "==", 0]]}]]]],
211 [[row,action,a,a2a,a2a1,a2b,_version
212 <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
213 <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
215 row,action,a,a2a,a2a1,a2b,_version
216 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
217 <3>,old,,"[""uuid"",""<0>""]",,,
218 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
221 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
226 "row": {"number": 10, "name": "ten"}}]]]],
227 [ordinals], [ordinals],
231 "row": {"number": 9, "name": "nine"},
232 "uuid-name": "nine"},
235 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
236 "row": {"name": "three squared"}},
239 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
242 "row": {"number": 7, "name": "seven"}}]]]],
243 [[row,action,name,number,_version
244 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
246 row,action,name,number,_version
247 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
250 AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
252 m4_define([OVSDB_MONITOR_INITIAL],
256 "row": {"number": 10, "name": "ten"}}]]]])
257 m4_define([OVSDB_MONITOR_TXNS],
261 "row": {"number": 5, "name": "five"}}]]],
265 "where": [["name", "==", "five"]],
266 "row": {"name": "FIVE"}}]]],
272 OVSDB_CHECK_MONITOR([monitor all operations],
273 [ORDINAL_SCHEMA], [OVSDB_MONITOR_INITIAL],
274 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
275 [[row,action,name,number,_version
276 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
278 row,action,name,number,_version
279 <2>,insert,"""five""",5,"[""uuid"",""<3>""]"
281 row,action,name,number,_version
282 <2>,old,"""five""",,"[""uuid"",""<3>""]"
283 ,new,"""FIVE""",5,"[""uuid"",""<4>""]"
285 row,action,name,number,_version
286 <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
287 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
290 dnl A monitor with "initial" only doesn't really make sense,
291 dnl but it's still allowed and should work.
292 OVSDB_CHECK_MONITOR([monitor initial only],
293 [ORDINAL_SCHEMA], [OVSDB_MONITOR_INITIAL],
294 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
295 [[row,action,name,number,_version
296 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
299 OVSDB_CHECK_MONITOR([monitor insert only],
300 [ORDINAL_SCHEMA], [OVSDB_MONITOR_INITIAL],
301 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
302 [[row,action,name,number,_version
303 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
306 OVSDB_CHECK_MONITOR([monitor delete only],
307 [ORDINAL_SCHEMA], [OVSDB_MONITOR_INITIAL],
308 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
309 [[row,action,name,number,_version
310 <0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
311 <2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
314 OVSDB_CHECK_MONITOR([monitor modify only],
315 [ORDINAL_SCHEMA], [OVSDB_MONITOR_INITIAL],
316 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
317 [[row,action,name,number,_version
318 <0>,old,"""five""",,"[""uuid"",""<1>""]"
319 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"