ovsdb-client: Serialize columns in predictable order on "monitor" command.
[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, [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.
10 #
11 # Checks that the overall output is OUTPUT, but UUIDs in the output
12 # are replaced by markers of the form <N> where N is a number.  The
13 # first unique UUID is replaced by <0>, the next by <1>, and so on.
14 # If a given UUID appears more than once it is always replaced by the
15 # same marker.
16 #
17 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
18 m4_define([OVSDB_CHECK_MONITOR], 
19   [AT_SETUP([$1])
20    AT_KEYWORDS([ovsdb server monitor positive $8])
21    AT_DATA([schema], [$2
22 ])
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_CHECK([ovsdb-server --detach --pidfile=$PWD/server-pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
27    AT_CHECK([ovsdb-client --detach --pidfile=$PWD/client-pid -d json monitor --format=csv unix:socket $4 $5 > output], 
28             [0], [ignore], [ignore], [kill `cat server-pid`])
29    m4_foreach([txn], [$6],
30      [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
31                      [ignore], [ignore], [kill `cat server-pid client-pid`])])
32    AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
33             [ignore], [ignore], [kill `cat server-pid client-pid`])
34    AT_CHECK([ovs-appctl -t $PWD/unixctl -e exit], [0], [ignore], [ignore])
35    OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
36    AT_CHECK([perl $srcdir/ovsdb-monitor-sort.pl < output | perl $srcdir/uuidfilt.pl], [0], [$7], [ignore])
37    AT_CLEANUP])
38
39 OVSDB_CHECK_MONITOR([monitor insert into empty table],
40   [ORDINAL_SCHEMA],
41   [],
42   [ordinals], [ordinals],
43   [[[["ordinals",
44       {"op": "insert",
45        "table": "ordinals",
46        "row": {"number": 0, "name": "zero"}}]]]],
47   [[row,action,name,number,_version
48 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
49 ]])
50
51 OVSDB_CHECK_MONITOR([monitor insert into populated table],
52   [ORDINAL_SCHEMA],
53   [[[["ordinals",
54       {"op": "insert",
55        "table": "ordinals",
56        "row": {"number": 10, "name": "ten"}}]]]],
57   [ordinals], [ordinals],
58   [[[["ordinals",
59       {"op": "insert",
60        "table": "ordinals",
61        "row": {"number": 0, "name": "zero"}}]]]],
62   [[row,action,name,number,_version
63 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
64
65 row,action,name,number,_version
66 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
67 ]])
68
69 OVSDB_CHECK_MONITOR([monitor delete],
70   [ORDINAL_SCHEMA],
71   [[[["ordinals",
72       {"op": "insert",
73        "table": "ordinals",
74        "row": {"number": 10, "name": "ten"}}]]]],
75   [ordinals], [ordinals],
76   [[[["ordinals",
77       {"op": "delete",
78        "table": "ordinals",
79        "where": [["number", "==", 10]]}]]]],
80   [[row,action,name,number,_version
81 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
82
83 row,action,name,number,_version
84 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
85 ]])
86
87 OVSDB_CHECK_MONITOR([monitor row update],
88   [ORDINAL_SCHEMA],
89   [[[["ordinals",
90       {"op": "insert",
91        "table": "ordinals",
92        "row": {"number": 10, "name": "ten"}}]]]],
93   [ordinals], [ordinals],
94   [[[["ordinals",
95       {"op": "update",
96        "table": "ordinals",
97        "where": [["number", "==", 10]],
98        "row": {"name": "five plus five"}}]]]],
99   [[row,action,name,number,_version
100 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
101
102 row,action,name,number,_version
103 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
104 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
105 ]])
106
107 OVSDB_CHECK_MONITOR([monitor no-op row updates],
108   [ORDINAL_SCHEMA],
109   [[[["ordinals",
110       {"op": "insert",
111        "table": "ordinals",
112        "row": {"number": 10, "name": "ten"}}]]]],
113   [ordinals], [ordinals],
114   [[[["ordinals",
115       {"op": "update",
116        "table": "ordinals",
117        "where": [["number", "==", 10]],
118        "row": {"number": 10, "name": "ten"}}]]],
119    [[["ordinals",
120       {"op": "insert",
121        "table": "ordinals",
122        "row": {"number": 9, "name": "nine"}}]]]],
123   [[row,action,name,number,_version
124 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
125
126 row,action,name,number,_version
127 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
128 ]])
129
130 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
131   [ORDINAL_SCHEMA],
132   [[[["ordinals",
133       {"op": "insert",
134        "table": "ordinals",
135        "row": {"number": 10, "name": "ten"}}]]]],
136   [ordinals], [ordinals],
137   [[[["ordinals",
138       {"op": "insert",
139        "table": "ordinals",
140        "row": {"number": 9, "name": "nine"},
141        "uuid-name": "nine"},
142       {"op": "update",
143        "table": "ordinals",
144        "where": [["_uuid", "==", ["named-uuid", "nine"]]],
145        "row": {"name": "three squared"}}]]]],
146   [[row,action,name,number,_version
147 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
148
149 row,action,name,number,_version
150 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
151 ]])
152
153 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
154   [ORDINAL_SCHEMA],
155   [[[["ordinals",
156       {"op": "insert",
157        "table": "ordinals",
158        "row": {"number": 10, "name": "ten"}}]]]],
159   [ordinals], [ordinals],
160   [[[["ordinals",
161       {"op": "insert",
162        "table": "ordinals",
163        "row": {"number": 9, "name": "nine"},
164        "uuid-name": "nine"},
165       {"op": "update",
166        "table": "ordinals",
167        "where": [["_uuid", "==", ["named-uuid", "nine"]]],
168        "row": {"name": "three squared"}},
169       {"op": "delete",
170        "table": "ordinals",
171        "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
172       {"op": "insert",
173        "table": "ordinals",
174        "row": {"number": 7, "name": "seven"}}]]]],
175   [[row,action,name,number,_version
176 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
177
178 row,action,name,number,_version
179 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
180 ]])
181
182 OVSDB_CHECK_MONITOR([monitor weak reference change],
183   [WEAK_SCHEMA],
184   [[[["weak",
185       {"op": "insert",
186        "table": "a",
187        "row": {"a": 0,
188                "a2a1": ["named-uuid", "a0"],
189                "a2b": ["named-uuid", "b2"]},
190        "uuid-name": "a0"},
191       {"op": "insert",
192        "table": "a",
193        "row": {"a": 1,
194                "a2a": ["named-uuid", "a0"],
195                "a2a1": ["named-uuid", "a1"],
196                "a2b": ["named-uuid", "b2"]},
197        "uuid-name": "a1"},
198       {"op": "insert",
199        "table": "b",
200        "row": {"b": 2},
201        "uuid-name": "b2"}]]]],
202   [weak], [a],
203   [[[["weak",
204       {"op": "delete",
205        "table": "a",
206        "where": [["a", "==", 0]]}]]]],
207   [[row,action,a,a2a,a2a1,a2b,_version
208 <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
209 <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
210
211 row,action,a,a2a,a2a1,a2b,_version
212 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
213 <3>,old,,"[""uuid"",""<0>""]",,,
214 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
215 ]])
216