]>
Commit | Line | Data |
---|---|---|
a8425c53 BP |
1 | AT_BANNER([OVSDB -- ovsdb-server monitors]) |
2 | ||
7360012b | 3 | # OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE, |
20aa445d | 4 | # TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS]) |
a8425c53 BP |
5 | # |
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 | |
20aa445d BP |
9 | # time. COLUMNS, if specified, is passed to ovsdb-client as the set |
10 | # of columns and operations to select. | |
a8425c53 BP |
11 | # |
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 | |
16 | # same marker. | |
17 | # | |
18 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
19 | m4_define([OVSDB_CHECK_MONITOR], | |
20 | [AT_SETUP([$1]) | |
fd193af4 | 21 | AT_KEYWORDS([ovsdb server monitor positive $9]) |
39ab07af | 22 | $2 > schema |
7c126fbb | 23 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
8fcf509e | 24 | m4_foreach([txn], [$3], |
7c126fbb | 25 | [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])]) |
fd193af4 | 26 | AT_CAPTURE_FILE([ovsdb-server-log]) |
77a922c7 | 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], |
fd193af4 | 28 | [0], [], []) |
90fd9628 GS |
29 | if test "$IS_WIN32" = "yes"; then |
30 | AT_CHECK([ovsdb-client -vjsonrpc --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output &], | |
31 | [0], [ignore], [ignore], [kill `cat server-pid`]) | |
32 | sleep 1 | |
33 | else | |
34 | AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output], | |
a8425c53 | 35 | [0], [ignore], [ignore], [kill `cat server-pid`]) |
90fd9628 | 36 | fi |
7360012b | 37 | m4_foreach([txn], [$6], |
7c126fbb | 38 | [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], |
b12e3c41 | 39 | [ignore], [ignore], [kill `cat server-pid client-pid`])]) |
7360012b | 40 | AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0], |
7c126fbb | 41 | [ignore], [ignore], [kill `cat server-pid client-pid`]) |
37d03458 | 42 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore]) |
f5961335 | 43 | OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid]) |
5c6d0628 | 44 | AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore]) |
a8425c53 BP |
45 | AT_CLEANUP]) |
46 | ||
8fcf509e | 47 | OVSDB_CHECK_MONITOR([monitor insert into empty table], |
39ab07af | 48 | [ordinal_schema], |
a8425c53 | 49 | [], |
7360012b | 50 | [ordinals], [ordinals], |
9cb53f26 BP |
51 | [[[["ordinals", |
52 | {"op": "insert", | |
a8425c53 BP |
53 | "table": "ordinals", |
54 | "row": {"number": 0, "name": "zero"}}]]]], | |
55 | [[row,action,name,number,_version | |
56 | <0>,insert,"""zero""",0,"[""uuid"",""<1>""]" | |
57 | ]]) | |
8fcf509e BP |
58 | |
59 | OVSDB_CHECK_MONITOR([monitor insert into populated table], | |
39ab07af | 60 | [ordinal_schema], |
9cb53f26 BP |
61 | [[[["ordinals", |
62 | {"op": "insert", | |
8fcf509e BP |
63 | "table": "ordinals", |
64 | "row": {"number": 10, "name": "ten"}}]]]], | |
7360012b | 65 | [ordinals], [ordinals], |
9cb53f26 BP |
66 | [[[["ordinals", |
67 | {"op": "insert", | |
8fcf509e BP |
68 | "table": "ordinals", |
69 | "row": {"number": 0, "name": "zero"}}]]]], | |
70 | [[row,action,name,number,_version | |
71 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
e5125481 | 72 | |
8fcf509e BP |
73 | row,action,name,number,_version |
74 | <2>,insert,"""zero""",0,"[""uuid"",""<3>""]" | |
75 | ]]) | |
76 | ||
77 | OVSDB_CHECK_MONITOR([monitor delete], | |
39ab07af | 78 | [ordinal_schema], |
9cb53f26 BP |
79 | [[[["ordinals", |
80 | {"op": "insert", | |
8fcf509e BP |
81 | "table": "ordinals", |
82 | "row": {"number": 10, "name": "ten"}}]]]], | |
7360012b | 83 | [ordinals], [ordinals], |
9cb53f26 BP |
84 | [[[["ordinals", |
85 | {"op": "delete", | |
8fcf509e BP |
86 | "table": "ordinals", |
87 | "where": [["number", "==", 10]]}]]]], | |
88 | [[row,action,name,number,_version | |
89 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
e5125481 | 90 | |
8fcf509e BP |
91 | row,action,name,number,_version |
92 | <0>,delete,"""ten""",10,"[""uuid"",""<1>""]" | |
93 | ]]) | |
94 | ||
95 | OVSDB_CHECK_MONITOR([monitor row update], | |
39ab07af | 96 | [ordinal_schema], |
9cb53f26 BP |
97 | [[[["ordinals", |
98 | {"op": "insert", | |
8fcf509e BP |
99 | "table": "ordinals", |
100 | "row": {"number": 10, "name": "ten"}}]]]], | |
7360012b | 101 | [ordinals], [ordinals], |
9cb53f26 BP |
102 | [[[["ordinals", |
103 | {"op": "update", | |
8fcf509e BP |
104 | "table": "ordinals", |
105 | "where": [["number", "==", 10]], | |
106 | "row": {"name": "five plus five"}}]]]], | |
107 | [[row,action,name,number,_version | |
108 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
e5125481 | 109 | |
8fcf509e BP |
110 | row,action,name,number,_version |
111 | <0>,old,"""ten""",,"[""uuid"",""<1>""]" | |
112 | ,new,"""five plus five""",10,"[""uuid"",""<2>""]" | |
113 | ]]) | |
114 | ||
115 | OVSDB_CHECK_MONITOR([monitor no-op row updates], | |
39ab07af | 116 | [ordinal_schema], |
9cb53f26 BP |
117 | [[[["ordinals", |
118 | {"op": "insert", | |
8fcf509e BP |
119 | "table": "ordinals", |
120 | "row": {"number": 10, "name": "ten"}}]]]], | |
7360012b | 121 | [ordinals], [ordinals], |
9cb53f26 BP |
122 | [[[["ordinals", |
123 | {"op": "update", | |
8fcf509e BP |
124 | "table": "ordinals", |
125 | "where": [["number", "==", 10]], | |
126 | "row": {"number": 10, "name": "ten"}}]]], | |
9cb53f26 BP |
127 | [[["ordinals", |
128 | {"op": "insert", | |
8fcf509e BP |
129 | "table": "ordinals", |
130 | "row": {"number": 9, "name": "nine"}}]]]], | |
131 | [[row,action,name,number,_version | |
132 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
e5125481 | 133 | |
8fcf509e BP |
134 | row,action,name,number,_version |
135 | <2>,insert,"""nine""",9,"[""uuid"",""<3>""]" | |
136 | ]]) | |
137 | ||
138 | OVSDB_CHECK_MONITOR([monitor insert-and-update transaction], | |
39ab07af | 139 | [ordinal_schema], |
9cb53f26 BP |
140 | [[[["ordinals", |
141 | {"op": "insert", | |
8fcf509e BP |
142 | "table": "ordinals", |
143 | "row": {"number": 10, "name": "ten"}}]]]], | |
7360012b | 144 | [ordinals], [ordinals], |
9cb53f26 BP |
145 | [[[["ordinals", |
146 | {"op": "insert", | |
8fcf509e BP |
147 | "table": "ordinals", |
148 | "row": {"number": 9, "name": "nine"}, | |
149 | "uuid-name": "nine"}, | |
150 | {"op": "update", | |
151 | "table": "ordinals", | |
152 | "where": [["_uuid", "==", ["named-uuid", "nine"]]], | |
153 | "row": {"name": "three squared"}}]]]], | |
154 | [[row,action,name,number,_version | |
155 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
e5125481 | 156 | |
8fcf509e BP |
157 | row,action,name,number,_version |
158 | <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]" | |
159 | ]]) | |
160 | ||
8fcf509e | 161 | OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction], |
39ab07af | 162 | [ordinal_schema], |
9cb53f26 BP |
163 | [[[["ordinals", |
164 | {"op": "insert", | |
8fcf509e BP |
165 | "table": "ordinals", |
166 | "row": {"number": 10, "name": "ten"}}]]]], | |
7360012b | 167 | [ordinals], [ordinals], |
9cb53f26 BP |
168 | [[[["ordinals", |
169 | {"op": "insert", | |
8fcf509e BP |
170 | "table": "ordinals", |
171 | "row": {"number": 9, "name": "nine"}, | |
172 | "uuid-name": "nine"}, | |
173 | {"op": "update", | |
174 | "table": "ordinals", | |
175 | "where": [["_uuid", "==", ["named-uuid", "nine"]]], | |
176 | "row": {"name": "three squared"}}, | |
177 | {"op": "delete", | |
178 | "table": "ordinals", | |
179 | "where": [["_uuid", "==", ["named-uuid", "nine"]]]}, | |
180 | {"op": "insert", | |
181 | "table": "ordinals", | |
182 | "row": {"number": 7, "name": "seven"}}]]]], | |
183 | [[row,action,name,number,_version | |
184 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
e5125481 | 185 | |
8fcf509e BP |
186 | row,action,name,number,_version |
187 | <2>,insert,"""seven""",7,"[""uuid"",""<3>""]" | |
188 | ]]) | |
189 | ||
7360012b | 190 | OVSDB_CHECK_MONITOR([monitor weak reference change], |
39ab07af | 191 | [weak_schema], |
7360012b BP |
192 | [[[["weak", |
193 | {"op": "insert", | |
194 | "table": "a", | |
195 | "row": {"a": 0, | |
196 | "a2a1": ["named-uuid", "a0"], | |
197 | "a2b": ["named-uuid", "b2"]}, | |
198 | "uuid-name": "a0"}, | |
199 | {"op": "insert", | |
200 | "table": "a", | |
201 | "row": {"a": 1, | |
202 | "a2a": ["named-uuid", "a0"], | |
203 | "a2a1": ["named-uuid", "a1"], | |
204 | "a2b": ["named-uuid", "b2"]}, | |
205 | "uuid-name": "a1"}, | |
206 | {"op": "insert", | |
207 | "table": "b", | |
208 | "row": {"b": 2}, | |
209 | "uuid-name": "b2"}]]]], | |
210 | [weak], [a], | |
211 | [[[["weak", | |
212 | {"op": "delete", | |
213 | "table": "a", | |
214 | "where": [["a", "==", 0]]}]]]], | |
a1ae5dc8 BP |
215 | [[row,action,a,a2a,a2a1,a2b,_version |
216 | <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]" | |
217 | <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]" | |
7360012b | 218 | |
a1ae5dc8 BP |
219 | row,action,a,a2a,a2a1,a2b,_version |
220 | <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]" | |
5cd9f691 | 221 | <3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]" |
a1ae5dc8 | 222 | ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]" |
7360012b BP |
223 | ]]) |
224 | ||
fd193af4 | 225 | OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction], |
39ab07af | 226 | [ordinal_schema], |
fd193af4 BP |
227 | [[[["ordinals", |
228 | {"op": "insert", | |
229 | "table": "ordinals", | |
230 | "row": {"number": 10, "name": "ten"}}]]]], | |
231 | [ordinals], [ordinals], | |
232 | [[[["ordinals", | |
233 | {"op": "insert", | |
234 | "table": "ordinals", | |
235 | "row": {"number": 9, "name": "nine"}, | |
236 | "uuid-name": "nine"}, | |
237 | {"op": "update", | |
238 | "table": "ordinals", | |
239 | "where": [["_uuid", "==", ["named-uuid", "nine"]]], | |
240 | "row": {"name": "three squared"}}, | |
241 | {"op": "delete", | |
242 | "table": "ordinals", | |
243 | "where": [["_uuid", "==", ["named-uuid", "nine"]]]}, | |
244 | {"op": "insert", | |
245 | "table": "ordinals", | |
246 | "row": {"number": 7, "name": "seven"}}]]]], | |
247 | [[row,action,name,number,_version | |
248 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
249 | ||
250 | row,action,name,number,_version | |
251 | <2>,insert,"""seven""",7,"[""uuid"",""<3>""]" | |
252 | ]]) | |
253 | \f | |
254 | AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations]) | |
255 | ||
256 | m4_define([OVSDB_MONITOR_INITIAL], | |
257 | [[[["ordinals", | |
258 | {"op": "insert", | |
259 | "table": "ordinals", | |
260 | "row": {"number": 10, "name": "ten"}}]]]]) | |
261 | m4_define([OVSDB_MONITOR_TXNS], | |
262 | [[[["ordinals", | |
263 | {"op": "insert", | |
264 | "table": "ordinals", | |
265 | "row": {"number": 5, "name": "five"}}]]], | |
266 | [[["ordinals", | |
267 | {"op": "update", | |
268 | "table": "ordinals", | |
269 | "where": [["name", "==", "five"]], | |
270 | "row": {"name": "FIVE"}}]]], | |
271 | [[["ordinals", | |
272 | {"op": "delete", | |
273 | "table": "ordinals", | |
274 | "where": []}]]]]) | |
275 | ||
276 | OVSDB_CHECK_MONITOR([monitor all operations], | |
39ab07af | 277 | [ordinal_schema], [OVSDB_MONITOR_INITIAL], |
fd193af4 BP |
278 | [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], |
279 | [[row,action,name,number,_version | |
280 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
281 | ||
282 | row,action,name,number,_version | |
283 | <2>,insert,"""five""",5,"[""uuid"",""<3>""]" | |
284 | ||
285 | row,action,name,number,_version | |
286 | <2>,old,"""five""",,"[""uuid"",""<3>""]" | |
287 | ,new,"""FIVE""",5,"[""uuid"",""<4>""]" | |
288 | ||
289 | row,action,name,number,_version | |
290 | <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]" | |
291 | <0>,delete,"""ten""",10,"[""uuid"",""<1>""]" | |
292 | ]]) | |
293 | ||
294 | dnl A monitor with "initial" only doesn't really make sense, | |
295 | dnl but it's still allowed and should work. | |
296 | OVSDB_CHECK_MONITOR([monitor initial only], | |
39ab07af | 297 | [ordinal_schema], [OVSDB_MONITOR_INITIAL], |
fd193af4 BP |
298 | [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], |
299 | [[row,action,name,number,_version | |
300 | <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" | |
20aa445d | 301 | ]], [!insert,!delete,!modify]) |
fd193af4 BP |
302 | |
303 | OVSDB_CHECK_MONITOR([monitor insert only], | |
39ab07af | 304 | [ordinal_schema], [OVSDB_MONITOR_INITIAL], |
fd193af4 BP |
305 | [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], |
306 | [[row,action,name,number,_version | |
307 | <0>,insert,"""five""",5,"[""uuid"",""<1>""]" | |
20aa445d | 308 | ]], [!initial,!delete,!modify]) |
fd193af4 BP |
309 | |
310 | OVSDB_CHECK_MONITOR([monitor delete only], | |
39ab07af | 311 | [ordinal_schema], [OVSDB_MONITOR_INITIAL], |
fd193af4 BP |
312 | [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], |
313 | [[row,action,name,number,_version | |
314 | <0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]" | |
315 | <2>,delete,"""ten""",10,"[""uuid"",""<3>""]" | |
20aa445d | 316 | ]], [!initial,!insert,!modify]) |
fd193af4 BP |
317 | |
318 | OVSDB_CHECK_MONITOR([monitor modify only], | |
39ab07af | 319 | [ordinal_schema], [OVSDB_MONITOR_INITIAL], |
fd193af4 BP |
320 | [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], |
321 | [[row,action,name,number,_version | |
322 | <0>,old,"""five""",,"[""uuid"",""<1>""]" | |
323 | ,new,"""FIVE""",5,"[""uuid"",""<2>""]" | |
20aa445d | 324 | ]], [!initial,!insert,!delete]) |