tests: Skip "strings at least 2 characters long" test for narrow Python.
[openvswitch] / tests / ovsdb-trigger.at
1 AT_BANNER([OVSDB -- triggers])
2
3 # This is like OVSDB_CHECK_POSITIVE, except that UUIDs in the output
4 # are replaced by markers of the form <N> where N is a number.  The
5 # first unique UUID is replaced by <0>, the next by <1>, and so on.
6 # If a given UUID appears more than once it is always replaced by the
7 # same marker.
8 m4_define([OVSDB_CHECK_TRIGGER], 
9   [AT_SETUP([$1])
10    AT_KEYWORDS([ovsdb execute execution trigger positive $4])
11    AT_CHECK([test-ovsdb trigger $2], [0], [stdout], [])
12    AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$3])
13    AT_CLEANUP])
14
15 OVSDB_CHECK_TRIGGER([trigger fires immediately],
16   ["`ordinal_schema`" [\
17     '["ordinals",
18       {"op": "insert",
19        "table": "ordinals",
20        "row": {"number": 0, "name": "zero"}},
21       {"op": "insert",
22        "table": "ordinals",
23        "row": {"number": 1, "name": "one"}},
24       {"op": "wait",
25        "timeout": 10,
26        "table": "ordinals",
27        "where": [],
28        "columns": ["name", "number"],
29        "until": "==",
30        "rows": [{"name": "zero", "number": 0},
31                 {"name": "one", "number": 1}]},
32       {"op": "insert",
33        "table": "ordinals",
34        "row": {"number": 2, "name": "two"}}]']],
35   [[t=0: trigger 0 (immediate): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{},{"uuid":["uuid","<2>"]}]
36 ]])
37
38 OVSDB_CHECK_TRIGGER([trigger times out],
39   ["`ordinal_schema`" [\
40     '["ordinals",
41       {"op": "insert",
42        "table": "ordinals",
43        "row": {"number": 0, "name": "zero"}},
44       {"op": "insert",
45        "table": "ordinals",
46        "row": {"number": 1, "name": "one"}},
47       {"op": "wait",
48        "timeout": 10,
49        "table": "ordinals",
50        "where": [],
51        "columns": ["name", "number"],
52        "until": "==",
53        "rows": [{"name": "zero", "number": 0},
54                 {"name": "one", "number": 1},
55                 {"name": "two", "number": 2}]}]' \
56     '["advance", 10]']],
57   [[t=0: new trigger 0
58 t=10: trigger 0 (delayed): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out after 10 ms","error":"timed out"}]
59 ]])
60
61 OVSDB_CHECK_TRIGGER([trigger fires after delay],
62   ["`ordinal_schema`" [\
63     '["ordinals",
64       {"op": "insert",
65        "table": "ordinals",
66        "row": {"number": 0, "name": "zero"}},
67       {"op": "insert",
68        "table": "ordinals",
69        "row": {"number": 1, "name": "one"}}]' \
70     '["advance", 5]' \
71     '["ordinals",
72       {"op": "wait",
73        "timeout": 10,
74        "table": "ordinals",
75        "where": [],
76        "columns": ["name", "number"],
77        "until": "==",
78        "rows": [{"name": "zero", "number": 0},
79                 {"name": "one", "number": 1},
80                 {"name": "two", "number": 2}]}]' \
81     '["advance", 5]' \
82     '["ordinals",
83       {"op": "insert",
84        "table": "ordinals",
85        "row": {"number": 2, "name": "two"}}]']],
86   [[t=0: trigger 0 (immediate): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
87 t=5: new trigger 1
88 t=10: trigger 2 (immediate): [{"uuid":["uuid","<2>"]}]
89 t=10: trigger 1 (delayed): [{}]
90 ]])
91
92 OVSDB_CHECK_TRIGGER([delayed trigger modifies database],
93   ["`ordinal_schema`" [\
94     '["ordinals",
95       {"op": "insert",
96        "table": "ordinals",
97        "row": {"number": 0, "name": "zero"}},
98       {"op": "insert",
99        "table": "ordinals",
100        "row": {"number": 1, "name": "one"}}]' \
101     '["advance", 5]' \
102     '["ordinals",
103       {"op": "wait",
104        "timeout": 10,
105        "table": "ordinals",
106        "where": [],
107        "columns": ["name", "number"],
108        "until": "==",
109        "rows": [{"name": "zero", "number": 0},
110                 {"name": "one", "number": 1},
111                 {"name": "two", "number": 2}]},
112       {"op": "delete",
113        "table": "ordinals",
114        "where": [["number", "<", 2]]}]' \
115     '["advance", 5]' \
116     '["ordinals",
117       {"op": "insert",
118        "table": "ordinals",
119        "row": {"number": 2, "name": "two"}}]' \
120     '["advance", 5]' \
121     '["ordinals",
122       {"op": "select",
123        "table": "ordinals",
124        "where": []}]']],
125   [[t=0: trigger 0 (immediate): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
126 t=5: new trigger 1
127 t=10: trigger 2 (immediate): [{"uuid":["uuid","<2>"]}]
128 t=10: trigger 1 (delayed): [{},{"count":2}]
129 t=15: trigger 3 (immediate): [{"rows":[{"_uuid":["uuid","<2>"],"_version":["uuid","<3>"],"name":"two","number":2}]}]
130 ]])
131
132 OVSDB_CHECK_TRIGGER([one delayed trigger wakes up another],
133   ["`ordinal_schema`" [\
134     '["ordinals",
135       {"op": "insert",
136        "table": "ordinals",
137        "row": {"number": 0, "name": "zero"}},
138       {"op": "insert",
139        "table": "ordinals",
140        "row": {"number": 1, "name": "one"}}]' \
141     '["advance", 5]' \
142     '["ordinals",
143       {"op": "wait",
144        "timeout": 10,
145        "table": "ordinals",
146        "where": [],
147        "columns": ["name", "number"],
148        "until": "==",
149        "rows": [{"name": "two", "number": 2}]},
150       {"op": "delete",
151        "table": "ordinals",
152        "where": [["number", "==", 2]]},
153       {"op": "insert",
154        "table": "ordinals",
155        "row": {"number": 3, "name": "three"}}]' \
156     '["ordinals",
157       {"op": "wait",
158        "timeout": 10,
159        "table": "ordinals",
160        "where": [],
161        "columns": ["name", "number"],
162        "until": "==",
163        "rows": [{"name": "zero", "number": 0},
164                 {"name": "one", "number": 1},
165                 {"name": "two", "number": 2}]},
166       {"op": "delete",
167        "table": "ordinals",
168        "where": [["number", "<", 2]]}]' \
169     '["advance", 5]' \
170     '["ordinals",
171       {"op": "insert",
172        "table": "ordinals",
173        "row": {"number": 2, "name": "two"}}]' \
174     '["advance", 5]' \
175     '["ordinals",
176       {"op": "select",
177        "table": "ordinals",
178        "where": []}]']],
179   [[t=0: trigger 0 (immediate): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
180 t=5: new trigger 1
181 t=5: new trigger 2
182 t=10: trigger 3 (immediate): [{"uuid":["uuid","<2>"]}]
183 t=10: trigger 2 (delayed): [{},{"count":2}]
184 t=15: trigger 1 (delayed): [{},{"count":1},{"uuid":["uuid","<3>"]}]
185 t=15: trigger 4 (immediate): [{"rows":[{"_uuid":["uuid","<3>"],"_version":["uuid","<4>"],"name":"three","number":3}]}]
186 ]])
187