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