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