1 AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
3 m4_define([OVSDB_SERVER_SHUTDOWN],
5 AT_CHECK([ovs-appctl -t $PWD/unixctl -e exit], [0], [ignore], [ignore])
6 OVS_WAIT_WHILE([kill -0 `cat savepid`], [kill `cat savepid`])])
8 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
10 # Creates a database with the given SCHEMA, starts an ovsdb-server on
11 # that database, and runs each of the TRANSACTIONS (which should be a
12 # quoted list of quoted strings) against it with ovsdb-client one at a
15 # Checks that the overall output is OUTPUT, but UUIDs in the output
16 # are replaced by markers of the form <N> where N is a number. The
17 # first unique UUID is replaced by <0>, the next by <1>, and so on.
18 # If a given UUID appears more than once it is always replaced by the
21 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
22 m4_define([OVSDB_CHECK_EXECUTION],
24 AT_KEYWORDS([ovsdb server positive unix $5])
27 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
28 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
29 m4_foreach([txn], [$3],
30 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore],
31 [test ! -e pid || kill `cat pid`])
34 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
35 [test ! -e pid || kill `cat pid`])
41 AT_SETUP([ovsdb-client get-schema-version])
42 AT_KEYWORDS([ovsdb server positive])
43 AT_DATA([schema], [ORDINAL_SCHEMA
45 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
46 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --unixctl=$PWD/unixctl --remote=punix:socket db], [0], [ignore], [ignore])
47 AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3
52 AT_SETUP([database multiplexing implementation])
53 AT_KEYWORDS([ovsdb server positive])
54 AT_DATA([schema], [ORDINAL_SCHEMA
56 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
57 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --unixctl=$PWD/unixctl --remote=punix:socket db], [0], [ignore], [ignore])
59 [[ovsdb-client list-dbs unix:socket]],
61 ], [ignore], [test ! -e pid || kill `cat pid`])
63 [[ovsdb-client get-schema unix:socket nonexistent]],
64 [1], [], [[ovsdb-client: syntax "{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"}": syntax error: Parsing database schema failed: Required 'name' member is missing.
65 ]], [test ! -e pid || kill `cat pid`])
69 AT_SETUP([--remote=db: implementation])
70 AT_KEYWORDS([ovsdb server positive])
76 "manager": {"type": "string"}}}}}
78 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
80 [[ovsdb-tool transact db \
84 "row": {"manager": "punix:socket"}}]']], [0], [ignore], [ignore])
85 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --remote=db:Manager,manager --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
87 [[ovsdb-client transact unix:socket \
92 "columns": ["manager"]}]']],
93 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
95 [perl $srcdir/uuidfilt.pl stdout],
97 [[[{"rows":[{"manager":"punix:socket"}]}]
100 [test ! -e pid || kill `cat pid`])
101 OVSDB_SERVER_SHUTDOWN
104 AT_SETUP([SSL db: implementation])
105 AT_KEYWORDS([ovsdb server positive ssl $5])
106 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
107 AT_SKIP_IF([test "x$RANDOM" = x])
108 SSL_PORT=`expr 32767 + \( $RANDOM % 32767 \)`
109 PKIDIR=$abs_top_builddir/tests
110 AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\"
117 "private_key": {"type": "string"},
118 "certificate": {"type": "string"},
119 "ca_cert": {"type": "string"}}}}}
121 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
123 [[ovsdb-tool transact db \
127 "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
128 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
129 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
130 [0], [ignore], [ignore])
132 [ovsdb-server --detach --pidfile=$PWD/pid \
133 --private-key=db:SSL,private_key \
134 --certificate=db:SSL,certificate \
135 --ca-cert=db:SSL,ca_cert \
136 --remote=pssl:$SSL_PORT:127.0.0.1 --unixctl=$PWD/unixctl db],
137 [0], [ignore], [ignore])
140 --private-key=$PKIDIR/testpki-privkey.pem \
141 --certificate=$PKIDIR/testpki-cert.pem \
142 --ca-cert=$PKIDIR/testpki-cacert.pem \
143 transact ssl:127.0.0.1:$SSL_PORT \
148 "columns": ["private_key"]}]']],
149 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
152 [perl $srcdir/uuidfilt.pl output], [0],
153 [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}]
154 ]], [ignore], [test ! -e pid || kill `cat pid`])
155 OVSDB_SERVER_SHUTDOWN
158 AT_SETUP([compacting online])
159 AT_KEYWORDS([ovsdb server compact])
160 AT_DATA([schema], [ORDINAL_SCHEMA
163 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
164 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --unixctl=$PWD/unixctl --remote=punix:socket --log-file=$PWD/ovsdb-server.log db], [0], [ignore], [ignore])
165 AT_CAPTURE_FILE([ovsdb-server.log])
166 dnl Do a bunch of random transactions that put crap in the database log.
168 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
170 ovsdb-client transact unix:socket '
174 "row": {"name": "'$1'", "number": '$2'}},
176 "comment": "add row for '"$pair"'"}]'
177 ovsdb-client transact unix:socket '
181 "where": [["number", "==", '$2']]},
183 "comment": "delete row for '"$2"'"}]'
184 ovsdb-client transact unix:socket '
188 "row": {"name": "'$1'", "number": '$2'}},
190 "comment": "add back row for '"$pair"'"}]'
192 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
193 dnl Check that all the crap is in fact in the database log.
194 AT_CHECK([[perl $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | test-json --multiple -]], [0],
195 [[{"name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}}}},"version":"5.1.3"}
196 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
197 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
198 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
199 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
200 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
201 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
202 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
203 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
204 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
205 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
206 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
207 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
208 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
209 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
210 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
211 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
212 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
213 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
214 ]], [], [test ! -e pid || kill `cat pid`])
215 dnl Dump out and check the actual database contents.
216 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
217 [0], [stdout], [ignore])
218 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
221 ------------------------------------ ----- ------
228 ], [], [test ! -e pid || kill `cat pid`])
229 dnl Now compact the database in-place.
230 AT_CHECK([[ovs-appctl -t $PWD/unixctl ovsdb-server/compact]],
231 [0], [], [ignore], [test ! -e pid || kill `cat pid`])
232 dnl We can't fully re-check the contents of the database log, because the
233 dnl order of the records is not predictable, but there should only be 4 lines
235 AT_CAPTURE_FILE([db])
236 AT_CHECK([wc -l < db], [0], [4
237 ], [], [test ! -e pid || kill `cat pid`])
238 dnl And check that the dumped data is the same too:
239 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
240 [test ! -e pid || kill `cat pid`])
241 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
244 ------------------------------------ ----- ------
251 ], [], [test ! -e pid || kill `cat pid`])
252 dnl Now do some more transactions.
254 [[ovsdb-client transact unix:socket '
258 "where": [["number", "<", 3]]}]']],
260 ]], [ignore], [test ! -e pid || kill `cat pid`])
261 dnl There should be 6 lines in the log now.
262 AT_CHECK([wc -l < db], [0], [6
263 ], [], [test ! -e pid || kill `cat pid`])
264 dnl Then check that the dumped data is correct.
265 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
266 [test ! -e pid || kill `cat pid`])
267 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
270 ------------------------------------ ----- ------
274 ], [], [test ! -e pid || kill `cat pid`])
275 OVSDB_SERVER_SHUTDOWN
278 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)])
280 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
282 # Creates a database with the given SCHEMA, starts an ovsdb-server on
283 # that database, and runs each of the TRANSACTIONS (which should be a
284 # quoted list of quoted strings) against it with ovsdb-client one at a
287 # Checks that the overall output is OUTPUT, but UUIDs in the output
288 # are replaced by markers of the form <N> where N is a number. The
289 # first unique UUID is replaced by <0>, the next by <1>, and so on.
290 # If a given UUID appears more than once it is always replaced by the
293 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
294 m4_define([OVSDB_CHECK_EXECUTION],
296 AT_KEYWORDS([ovsdb server positive ssl $5])
297 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
298 AT_SKIP_IF([test "x$RANDOM" = x])
299 AT_DATA([schema], [$2
301 SSL_PORT=`expr 32767 + \( $RANDOM % 32767 \)`
302 PKIDIR=$abs_top_builddir/tests
303 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
304 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:$SSL_PORT:127.0.0.1 --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
305 m4_foreach([txn], [$3],
306 [AT_CHECK([ovsdb-client --private-key=$PKIDIR/testpki-privkey.pem --certificate=$PKIDIR/testpki-cert.pem --ca-cert=$PKIDIR/testpki-cacert.pem transact ssl:127.0.0.1:$SSL_PORT 'txn'], [0], [stdout], [ignore],
307 [test ! -e pid || kill `cat pid`])
310 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
311 [test ! -e pid || kill `cat pid`])
312 OVSDB_SERVER_SHUTDOWN
317 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
319 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
321 # Creates a database with the given SCHEMA and runs each of the
322 # TRANSACTIONS (which should be a quoted list of quoted strings)
323 # against it with ovsdb-client one at a time. Each ovsdb-client
324 # is run against a separately started ovsdb-server that executes
325 # only that single transaction. (The idea is that this should
326 # help to ferret out any differences between what ovsdb-server has
327 # in memory and what actually gets committed to disk.)
329 # Checks that the overall output is OUTPUT, but UUIDs in the output
330 # are replaced by markers of the form <N> where N is a number. The
331 # first unique UUID is replaced by <0>, the next by <1>, and so on.
332 # If a given UUID appears more than once it is always replaced by the
335 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
336 m4_define([OVSDB_CHECK_EXECUTION],
338 AT_KEYWORDS([ovsdb server positive transient $5])
339 AT_DATA([schema], [$2
341 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
342 m4_foreach([txn], [$3],
343 [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
345 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
348 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore])