Merge branch 'master' into next
[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     '[{"op": "insert",
18        "table": "ordinals",
19        "row": {"number": 0, "name": "zero"}},
20       {"op": "insert",
21        "table": "ordinals",
22        "row": {"number": 1, "name": "one"}},
23       {"op": "wait",
24        "timeout": 10,
25        "table": "ordinals",
26        "where": [],
27        "columns": ["name", "number"],
28        "until": "==",
29        "rows": [{"name": "zero", "number": 0},
30                 {"name": "one", "number": 1}]},
31       {"op": "insert",
32        "table": "ordinals",
33        "row": {"number": 2, "name": "two"}}]']],
34   [[t=0: trigger 0 (immediate): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{},{"uuid":["uuid","<2>"]}]
35 ]])
36
37 OVSDB_CHECK_TRIGGER([trigger times out],
38   ['ORDINAL_SCHEMA' [\
39     '[{"op": "insert",
40        "table": "ordinals",
41        "row": {"number": 0, "name": "zero"}},
42       {"op": "insert",
43        "table": "ordinals",
44        "row": {"number": 1, "name": "one"}},
45       {"op": "wait",
46        "timeout": 10,
47        "table": "ordinals",
48        "where": [],
49        "columns": ["name", "number"],
50        "until": "==",
51        "rows": [{"name": "zero", "number": 0},
52                 {"name": "one", "number": 1},
53                 {"name": "two", "number": 2}]}]' \
54     '["advance", 10]']],
55   [[t=0: new trigger 0
56 t=10: trigger 0 (delayed): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out after 10 ms","error":"timed out"}]
57 ]])
58
59 OVSDB_CHECK_TRIGGER([trigger fires after delay],
60   ['ORDINAL_SCHEMA' [\
61     '[{"op": "insert",
62        "table": "ordinals",
63        "row": {"number": 0, "name": "zero"}},
64       {"op": "insert",
65        "table": "ordinals",
66        "row": {"number": 1, "name": "one"}}]' \
67     '["advance", 5]' \
68     '[{"op": "wait",
69        "timeout": 10,
70        "table": "ordinals",
71        "where": [],
72        "columns": ["name", "number"],
73        "until": "==",
74        "rows": [{"name": "zero", "number": 0},
75                 {"name": "one", "number": 1},
76                 {"name": "two", "number": 2}]}]' \
77     '["advance", 5]' \
78     '[{"op": "insert",
79        "table": "ordinals",
80        "row": {"number": 2, "name": "two"}}]']],
81   [[t=0: trigger 0 (immediate): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
82 t=5: new trigger 1
83 t=10: trigger 2 (immediate): [{"uuid":["uuid","<2>"]}]
84 t=10: trigger 1 (delayed): [{}]
85 ]])
86
87 OVSDB_CHECK_TRIGGER([delayed trigger modifies database],
88   ['ORDINAL_SCHEMA' [\
89     '[{"op": "insert",
90        "table": "ordinals",
91        "row": {"number": 0, "name": "zero"}},
92       {"op": "insert",
93        "table": "ordinals",
94        "row": {"number": 1, "name": "one"}}]' \
95     '["advance", 5]' \
96     '[{"op": "wait",
97        "timeout": 10,
98        "table": "ordinals",
99        "where": [],
100        "columns": ["name", "number"],
101        "until": "==",
102        "rows": [{"name": "zero", "number": 0},
103                 {"name": "one", "number": 1},
104                 {"name": "two", "number": 2}]},
105       {"op": "delete",
106        "table": "ordinals",
107        "where": [["number", "<", 2]]}]' \
108     '["advance", 5]' \
109     '[{"op": "insert",
110        "table": "ordinals",
111        "row": {"number": 2, "name": "two"}}]' \
112     '["advance", 5]' \
113     '[{"op": "select",
114        "table": "ordinals",
115        "where": []}]']],
116   [[t=0: trigger 0 (immediate): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
117 t=5: new trigger 1
118 t=10: trigger 2 (immediate): [{"uuid":["uuid","<2>"]}]
119 t=10: trigger 1 (delayed): [{},{"count":2}]
120 t=15: trigger 3 (immediate): [{"rows":[{"_uuid":["uuid","<2>"],"_version":["uuid","<3>"],"name":"two","number":2}]}]
121 ]])
122
123 OVSDB_CHECK_TRIGGER([one delayed trigger wakes up another],
124   ['ORDINAL_SCHEMA' [\
125     '[{"op": "insert",
126        "table": "ordinals",
127        "row": {"number": 0, "name": "zero"}},
128       {"op": "insert",
129        "table": "ordinals",
130        "row": {"number": 1, "name": "one"}}]' \
131     '["advance", 5]' \
132     '[{"op": "wait",
133        "timeout": 10,
134        "table": "ordinals",
135        "where": [],
136        "columns": ["name", "number"],
137        "until": "==",
138        "rows": [{"name": "two", "number": 2}]},
139       {"op": "delete",
140        "table": "ordinals",
141        "where": [["number", "==", 2]]},
142       {"op": "insert",
143        "table": "ordinals",
144        "row": {"number": 3, "name": "three"}}]' \
145     '[{"op": "wait",
146        "timeout": 10,
147        "table": "ordinals",
148        "where": [],
149        "columns": ["name", "number"],
150        "until": "==",
151        "rows": [{"name": "zero", "number": 0},
152                 {"name": "one", "number": 1},
153                 {"name": "two", "number": 2}]},
154       {"op": "delete",
155        "table": "ordinals",
156        "where": [["number", "<", 2]]}]' \
157     '["advance", 5]' \
158     '[{"op": "insert",
159        "table": "ordinals",
160        "row": {"number": 2, "name": "two"}}]' \
161     '["advance", 5]' \
162     '[{"op": "select",
163        "table": "ordinals",
164        "where": []}]']],
165   [[t=0: trigger 0 (immediate): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
166 t=5: new trigger 1
167 t=5: new trigger 2
168 t=10: trigger 3 (immediate): [{"uuid":["uuid","<2>"]}]
169 t=10: trigger 2 (delayed): [{},{"count":2}]
170 t=15: trigger 1 (delayed): [{},{"count":1},{"uuid":["uuid","<3>"]}]
171 t=15: trigger 4 (immediate): [{"rows":[{"_uuid":["uuid","<3>"],"_version":["uuid","<4>"],"name":"three","number":3}]}]
172 ]])
173