netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / tests / ovsdb-monitor.at
1 AT_BANNER([OVSDB -- ovsdb-server monitors])
2
3 # OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
4 #                     TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS])
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
9 # time.  COLUMNS, if specified, is passed to ovsdb-client as the set
10 # of columns and operations to select.
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])
21    AT_KEYWORDS([ovsdb server monitor positive $9])
22    $2 > schema
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],
28             [0], [], [])
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],
35             [0], [ignore], [ignore], [kill `cat server-pid`])
36    fi
37    m4_foreach([txn], [$6],
38      [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
39                      [ignore], [ignore], [kill `cat server-pid client-pid`])])
40    AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
41             [ignore], [ignore], [kill `cat server-pid client-pid`])
42    AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore])
43    OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
44    AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore])
45    AT_CLEANUP])
46
47 OVSDB_CHECK_MONITOR([monitor insert into empty table],
48   [ordinal_schema],
49   [],
50   [ordinals], [ordinals],
51   [[[["ordinals",
52       {"op": "insert",
53        "table": "ordinals",
54        "row": {"number": 0, "name": "zero"}}]]]],
55   [[row,action,name,number,_version
56 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
57 ]])
58
59 OVSDB_CHECK_MONITOR([monitor insert into populated table],
60   [ordinal_schema],
61   [[[["ordinals",
62       {"op": "insert",
63        "table": "ordinals",
64        "row": {"number": 10, "name": "ten"}}]]]],
65   [ordinals], [ordinals],
66   [[[["ordinals",
67       {"op": "insert",
68        "table": "ordinals",
69        "row": {"number": 0, "name": "zero"}}]]]],
70   [[row,action,name,number,_version
71 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
72
73 row,action,name,number,_version
74 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
75 ]])
76
77 OVSDB_CHECK_MONITOR([monitor delete],
78   [ordinal_schema],
79   [[[["ordinals",
80       {"op": "insert",
81        "table": "ordinals",
82        "row": {"number": 10, "name": "ten"}}]]]],
83   [ordinals], [ordinals],
84   [[[["ordinals",
85       {"op": "delete",
86        "table": "ordinals",
87        "where": [["number", "==", 10]]}]]]],
88   [[row,action,name,number,_version
89 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
90
91 row,action,name,number,_version
92 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
93 ]])
94
95 OVSDB_CHECK_MONITOR([monitor row update],
96   [ordinal_schema],
97   [[[["ordinals",
98       {"op": "insert",
99        "table": "ordinals",
100        "row": {"number": 10, "name": "ten"}}]]]],
101   [ordinals], [ordinals],
102   [[[["ordinals",
103       {"op": "update",
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>""]"
109
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],
116   [ordinal_schema],
117   [[[["ordinals",
118       {"op": "insert",
119        "table": "ordinals",
120        "row": {"number": 10, "name": "ten"}}]]]],
121   [ordinals], [ordinals],
122   [[[["ordinals",
123       {"op": "update",
124        "table": "ordinals",
125        "where": [["number", "==", 10]],
126        "row": {"number": 10, "name": "ten"}}]]],
127    [[["ordinals",
128       {"op": "insert",
129        "table": "ordinals",
130        "row": {"number": 9, "name": "nine"}}]]]],
131   [[row,action,name,number,_version
132 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
133
134 row,action,name,number,_version
135 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
136 ]])
137
138 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
139   [ordinal_schema],
140   [[[["ordinals",
141       {"op": "insert",
142        "table": "ordinals",
143        "row": {"number": 10, "name": "ten"}}]]]],
144   [ordinals], [ordinals],
145   [[[["ordinals",
146       {"op": "insert",
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>""]"
156
157 row,action,name,number,_version
158 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
159 ]])
160
161 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
162   [ordinal_schema],
163   [[[["ordinals",
164       {"op": "insert",
165        "table": "ordinals",
166        "row": {"number": 10, "name": "ten"}}]]]],
167   [ordinals], [ordinals],
168   [[[["ordinals",
169       {"op": "insert",
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>""]"
185
186 row,action,name,number,_version
187 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
188 ]])
189
190 OVSDB_CHECK_MONITOR([monitor weak reference change],
191   [weak_schema],
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]]}]]]],
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>""]"
218
219 row,action,a,a2a,a2a1,a2b,_version
220 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
221 <3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
222 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
223 ]])
224
225 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
226   [ordinal_schema],
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],
277   [ordinal_schema], [OVSDB_MONITOR_INITIAL],
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],
297   [ordinal_schema], [OVSDB_MONITOR_INITIAL],
298   [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
299   [[row,action,name,number,_version
300 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
301 ]], [!insert,!delete,!modify])
302
303 OVSDB_CHECK_MONITOR([monitor insert only],
304   [ordinal_schema], [OVSDB_MONITOR_INITIAL],
305   [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
306   [[row,action,name,number,_version
307 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
308 ]], [!initial,!delete,!modify])
309
310 OVSDB_CHECK_MONITOR([monitor delete only],
311   [ordinal_schema], [OVSDB_MONITOR_INITIAL],
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>""]"
316 ]], [!initial,!insert,!modify])
317
318 OVSDB_CHECK_MONITOR([monitor modify only],
319   [ordinal_schema], [OVSDB_MONITOR_INITIAL],
320   [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
321   [[row,action,name,number,_version
322 <0>,old,"""five""",,"[""uuid"",""<1>""]"
323 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"
324 ]], [!initial,!insert,!delete])