Rework and simplify the "lcov" support for the testsuite.
[openvswitch] / tests / ovsdb-execution.at
1 AT_BANNER([OVSDB -- execution])
2
3 m4_define([ORDINAL_SCHEMA],
4   [[{"name": "mydb",
5      "tables": {
6        "ordinals": {
7          "columns": {
8            "number": {"type": "integer"},
9            "name": {"type": "string"}}}}}]])
10
11 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
12 #
13 # Runs "test-ovsdb execute" with the given SCHEMA and each of the
14 # TRANSACTIONS (which should be a quoted list of quoted strings).
15 #
16 # Checks that the overall output is OUTPUT, but UUIDs in the output
17 # are replaced by markers of the form <N> where N is a number.  The
18 # first unique UUID is replaced by <0>, the next by <1>, and so on.
19 # If a given UUID appears more than once it is always replaced by the
20 # same marker.
21 #
22 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
23 m4_define([OVSDB_CHECK_EXECUTION], 
24   [AT_SETUP([$1])
25    AT_KEYWORDS([ovsdb execute execution positive $5])
26    AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
27      [0], [stdout], [])
28    AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
29    AT_CLEANUP])
30
31 m4_define([EXECUTION_EXAMPLES], [
32 OVSDB_CHECK_EXECUTION([insert row, query table],
33   [ORDINAL_SCHEMA], 
34   [[[[{"op": "insert",
35        "table": "ordinals",
36        "row": {"number": 0, "name": "zero"}}]]],
37    [[[{"op": "select",
38        "table": "ordinals",
39        "where": []}]]]],
40   [[[{"uuid":["uuid","<0>"]}]
41 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
42 ]])
43
44 OVSDB_CHECK_EXECUTION([insert rows, query by value],
45   [ORDINAL_SCHEMA],
46   [[[[{"op": "insert",
47        "table": "ordinals",
48        "row": {"number": 0, "name": "zero"}}]]],
49    [[[{"op": "insert",
50        "table": "ordinals",
51        "row": {"number": 1, "name": "one"}}]]],
52    [[[{"op": "select",
53        "table": "ordinals",
54        "where": [["name", "==", "zero"]]}]]],
55    [[[{"op": "select",
56        "table": "ordinals",
57        "where": [["name", "==", "one"]]}]]]],
58   [[[{"uuid":["uuid","<0>"]}]
59 [{"uuid":["uuid","<1>"]}]
60 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
61 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
62 ]])
63
64 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
65   [ORDINAL_SCHEMA],
66   [[[[{"op": "insert",
67        "table": "ordinals",
68        "row": {"number": 0, "name": "zero"},
69        "uuid-name": "first"},
70       {"op": "insert",
71        "table": "ordinals",
72        "row": {"number": 1, "name": "one"},
73        "uuid-name": "second"},
74       {"op": "select",
75        "table": "ordinals",
76        "where": [["_uuid", "==", ["named-uuid", "first"]]]},
77       {"op": "select",
78        "table": "ordinals",
79        "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
80   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]},{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
81 ]])
82
83 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
84   [ORDINAL_SCHEMA],
85   [[[[{"op": "insert",
86        "table": "ordinals",
87        "row": {"number": 0, "name": "zero"},
88        "uuid-name": "first"}]]],
89    [[[{"op": "insert",
90        "table": "ordinals",
91        "row": {"number": 1, "name": "one"},
92        "uuid-name": "first"}]]],
93    [[[{"op": "update",
94        "table": "ordinals",
95        "where": [["name", "==", "zero"]],
96        "row": {"name": "nought"}}]]],
97    [[[{"op": "select",
98        "table": "ordinals",
99        "where": [],
100        "sort": ["number"]}]]]],
101   [[[{"uuid":["uuid","<0>"]}]
102 [{"uuid":["uuid","<1>"]}]
103 [{"count":1}]
104 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
105 ]])
106
107 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
108   [ORDINAL_SCHEMA],
109   [[[[{"op": "insert",
110        "table": "ordinals",
111        "row": {"number": 0, "name": "zero"},
112        "uuid-name": "first"}]]],
113    [[[{"op": "insert",
114        "table": "ordinals",
115        "row": {"number": 1, "name": "one"},
116        "uuid-name": "first"}]]],
117    [[[{"op": "mutate",
118        "table": "ordinals",
119        "where": [["name", "==", "zero"]],
120        "mutations": [["number", "+=", 2]]}]]],
121    [[[{"op": "select",
122        "table": "ordinals",
123        "where": [],
124        "sort": ["number"]}]]]],
125   [[[{"uuid":["uuid","<0>"]}]
126 [{"uuid":["uuid","<1>"]}]
127 [{"count":1}]
128 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
129 ]])
130
131 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
132   [ORDINAL_SCHEMA],
133   [[[[{"op": "insert",
134        "table": "ordinals",
135        "row": {"number": 0, "name": "zero"},
136        "uuid-name": "first"},
137       {"op": "insert",
138        "table": "ordinals",
139        "row": {"number": 1, "name": "one"},
140        "uuid-name": "second"},
141       {"op": "delete",
142        "table": "ordinals",
143        "where": [["_uuid", "==", ["named-uuid", "first"]]]},
144       {"op": "select",
145        "table": "ordinals",
146        "where": [],
147        "columns": ["name","number"]}]]]],
148   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
149 ]])
150
151 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
152   [ORDINAL_SCHEMA],
153   [[[[{"op": "insert",
154        "table": "ordinals",
155        "row": {"number": 0, "name": "zero"},
156        "uuid-name": "first"}]]],
157    [[[{"op": "insert",
158        "table": "ordinals",
159        "row": {"number": 1, "name": "one"},
160        "uuid-name": "first"}]]],
161    [[[{"op": "delete",
162        "table": "ordinals",
163        "where": [["name", "==", "zero"]]}]]],
164    [[[{"op": "select",
165        "table": "ordinals",
166        "where": []}]]]],
167   [[[{"uuid":["uuid","<0>"]}]
168 [{"uuid":["uuid","<1>"]}]
169 [{"count":1}]
170 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
171 ]])
172
173 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
174   [ORDINAL_SCHEMA],
175   [[[[{"op": "insert",
176        "table": "ordinals",
177        "row": {"number": 0, "name": "zero"},
178        "uuid-name": "first"}]]],
179    [[[{"op": "insert",
180        "table": "ordinals",
181        "row": {"number": 1, "name": "one"},
182        "uuid-name": "first"}]]],
183    [[[{"op": "delete",
184        "table": "ordinals",
185        "where": [["name", "==", "nought"]]}]]],
186    [[[{"op": "select",
187        "table": "ordinals",
188        "where": [],
189        "sort": ["number"]}]]]],
190   [[[{"uuid":["uuid","<0>"]}]
191 [{"uuid":["uuid","<1>"]}]
192 [{"count":0}]
193 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
194 ]])
195
196 OVSDB_CHECK_EXECUTION([insert rows, delete all],
197   [ORDINAL_SCHEMA],
198   [[[[{"op": "insert",
199        "table": "ordinals",
200        "row": {"number": 0, "name": "zero"},
201        "uuid-name": "first"},
202       {"op": "insert",
203        "table": "ordinals",
204        "row": {"number": 1, "name": "one"},
205        "uuid-name": "second"},
206       {"op": "delete",
207        "table": "ordinals",
208        "where": []},
209       {"op": "select",
210        "table": "ordinals",
211        "where": [],
212        "columns": ["name","number"]}]]]],
213   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
214 ]])
215
216 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
217   [ORDINAL_SCHEMA],
218   [[[[{"op": "insert",
219        "table": "ordinals",
220        "row": {"number": 0, "name": "zero"}},
221       {"op": "select",
222        "table": "ordinals",
223        "where": []},
224       {"op": "commit",
225        "durable": false}]]]],
226   [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
227 ]])
228
229 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
230   [ORDINAL_SCHEMA],
231   [[[[{"op": "insert",
232        "table": "ordinals",
233        "row": {"number": 0, "name": "zero"}},
234       {"op": "select",
235        "table": "ordinals",
236        "where": []},
237       {"op": "commit",
238        "durable": true}]]]],
239   [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
240 ]])
241
242 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
243   [ORDINAL_SCHEMA],
244   [[[[{"op": "insert",
245        "table": "ordinals",
246        "row": {"number": 0, "name": "zero"}},
247       {"op": "insert",
248        "table": "ordinals",
249        "row": {"number": 1, "name": "one"}},
250       {"op": "wait",
251        "timeout": 0,
252        "table": "ordinals",
253        "where": [],
254        "columns": ["name", "number"],
255        "until": "==",
256        "rows": [{"name": "zero", "number": 0},
257                 {"name": "one", "number": 1}]}]]]],
258   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
259 ]])
260
261 OVSDB_CHECK_EXECUTION([equality wait with extra row],
262   [ORDINAL_SCHEMA],
263   [[[[{"op": "insert",
264        "table": "ordinals",
265        "row": {"number": 0, "name": "zero"}},
266       {"op": "insert",
267        "table": "ordinals",
268        "row": {"number": 1, "name": "one"}},
269       {"op": "wait",
270        "timeout": 0,
271        "table": "ordinals",
272        "where": [],
273        "columns": ["name", "number"],
274        "until": "==",
275        "rows": [{"name": "zero", "number": 0},
276                 {"name": "one", "number": 1},
277                 {"name": "two", "number": 2}]}]]]],
278   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
279 ]])
280
281 OVSDB_CHECK_EXECUTION([equality wait with missing row],
282   [ORDINAL_SCHEMA],
283   [[[[{"op": "insert",
284        "table": "ordinals",
285        "row": {"number": 0, "name": "zero"}},
286       {"op": "insert",
287        "table": "ordinals",
288        "row": {"number": 1, "name": "one"}},
289       {"op": "wait",
290        "timeout": 0,
291        "table": "ordinals",
292        "where": [],
293        "columns": ["name", "number"],
294        "until": "==",
295        "rows": [{"name": "one", "number": 1}]}]]]],
296   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
297 ]])
298
299 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
300   [ORDINAL_SCHEMA],
301   [[[[{"op": "insert",
302        "table": "ordinals",
303        "row": {"number": 0, "name": "zero"}},
304       {"op": "insert",
305        "table": "ordinals",
306        "row": {"number": 1, "name": "one"}},
307       {"op": "wait",
308        "timeout": 0,
309        "table": "ordinals",
310        "where": [],
311        "columns": ["name", "number"],
312        "until": "!=",
313        "rows": [{"name": "zero", "number": 0},
314                 {"name": "one", "number": 1}]}]]]],
315   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
316 ]])
317
318 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
319   [ORDINAL_SCHEMA],
320   [[[[{"op": "insert",
321        "table": "ordinals",
322        "row": {"number": 0, "name": "zero"}},
323       {"op": "insert",
324        "table": "ordinals",
325        "row": {"number": 1, "name": "one"}},
326       {"op": "wait",
327        "timeout": 0,
328        "table": "ordinals",
329        "where": [],
330        "columns": ["name", "number"],
331        "until": "!=",
332        "rows": [{"name": "zero", "number": 0},
333                 {"name": "one", "number": 1},
334                 {"name": "two", "number": 2}]}]]]],
335   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
336 ]])
337
338 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
339   [ORDINAL_SCHEMA],
340   [[[[{"op": "insert",
341        "table": "ordinals",
342        "row": {"number": 0, "name": "zero"}},
343       {"op": "insert",
344        "table": "ordinals",
345        "row": {"number": 1, "name": "one"}},
346       {"op": "wait",
347        "timeout": 0,
348        "table": "ordinals",
349        "where": [],
350        "columns": ["name", "number"],
351        "until": "!=",
352        "rows": [{"name": "one", "number": 1}]}]]]],
353   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
354 ]])
355 ])
356
357 EXECUTION_EXAMPLES