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([database multiplexing implementation])
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])
48 [[ovsdb-client list-dbs unix:socket]],
50 ], [ignore], [test ! -e pid || kill `cat pid`])
52 [[ovsdb-client get-schema unix:socket nonexistent]],
53 [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.
54 ]], [test ! -e pid || kill `cat pid`])
58 AT_SETUP([--remote=db: implementation])
59 AT_KEYWORDS([ovsdb server positive])
65 "manager": {"type": "string"}}}}}
67 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
69 [[ovsdb-tool transact db \
73 "row": {"manager": "punix:socket"}}]']], [0], [ignore], [ignore])
74 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --remote=db:Manager,manager --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
76 [[ovsdb-client transact unix:socket \
81 "columns": ["manager"]}]']],
82 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
84 [perl $srcdir/uuidfilt.pl stdout],
86 [[[{"rows":[{"manager":"punix:socket"}]}]
89 [test ! -e pid || kill `cat pid`])
93 AT_SETUP([SSL db: implementation])
94 AT_KEYWORDS([ovsdb server positive ssl $5])
95 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
96 AT_SKIP_IF([test "x$RANDOM" = x])
97 SSL_PORT=`expr 32767 + \( $RANDOM % 32767 \)`
98 PKIDIR=$abs_top_srcdir/tests
99 AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\"
106 "private_key": {"type": "string"},
107 "certificate": {"type": "string"},
108 "ca_cert": {"type": "string"}}}}}
110 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
112 [[ovsdb-tool transact db \
116 "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
117 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
118 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
119 [0], [ignore], [ignore])
121 [ovsdb-server --detach --pidfile=$PWD/pid \
122 --private-key=db:SSL,private_key \
123 --certificate=db:SSL,certificate \
124 --ca-cert=db:SSL,ca_cert \
125 --remote=pssl:$SSL_PORT:127.0.0.1 --unixctl=$PWD/unixctl db],
126 [0], [ignore], [ignore])
129 --private-key=$PKIDIR/testpki-privkey.pem \
130 --certificate=$PKIDIR/testpki-cert.pem \
131 --ca-cert=$PKIDIR/testpki-cacert.pem \
132 transact ssl:127.0.0.1:$SSL_PORT \
137 "columns": ["private_key"]}]']],
138 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
141 [perl $srcdir/uuidfilt.pl output], [0],
142 [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}]
143 ]], [ignore], [test ! -e pid || kill `cat pid`])
144 OVSDB_SERVER_SHUTDOWN
147 AT_SETUP([compacting online])
148 AT_KEYWORDS([ovsdb server compact])
149 AT_DATA([schema], [ORDINAL_SCHEMA
152 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
153 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --unixctl=$PWD/unixctl --remote=punix:socket --log-file=$PWD/ovsdb-server.log db], [0], [ignore], [ignore])
154 AT_CAPTURE_FILE([ovsdb-server.log])
155 dnl Do a bunch of random transactions that put crap in the database log.
157 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
159 ovsdb-client transact unix:socket '
163 "row": {"name": "'$1'", "number": '$2'}},
165 "comment": "add row for '"$pair"'"}]'
166 ovsdb-client transact unix:socket '
170 "where": [["number", "==", '$2']]},
172 "comment": "delete row for '"$2"'"}]'
173 ovsdb-client transact unix:socket '
177 "row": {"name": "'$1'", "number": '$2'}},
179 "comment": "add back row for '"$pair"'"}]'
181 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
182 dnl Check that all the crap is in fact in the database log.
183 AT_CHECK([[perl $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | test-json --multiple -]], [0],
184 [[{"name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}}}}}
185 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
186 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
187 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
188 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
189 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
190 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
191 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
192 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
193 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
194 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
195 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
196 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
197 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
198 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
199 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
200 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
201 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
202 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
203 ]], [], [test ! -e pid || kill `cat pid`])
204 dnl Dump out and check the actual database contents.
205 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
206 [0], [stdout], [ignore])
207 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0],
209 ------------------------------------ ----- ------
216 ], [], [test ! -e pid || kill `cat pid`])
217 dnl Now compact the database in-place.
218 AT_CHECK([[ovs-appctl -t $PWD/unixctl ovsdb-server/compact]],
219 [0], [], [ignore], [test ! -e pid || kill `cat pid`])
220 dnl We can't fully re-check the contents of the database log, because the
221 dnl order of the records is not predictable, but there should only be 4 lines
223 AT_CAPTURE_FILE([db])
224 AT_CHECK([wc -l < db], [0], [4
225 ], [], [test ! -e pid || kill `cat pid`])
226 dnl And check that the dumped data is the same too:
227 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
228 [test ! -e pid || kill `cat pid`])
229 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0],
231 ------------------------------------ ----- ------
238 ], [], [test ! -e pid || kill `cat pid`])
239 dnl Now do some more transactions.
241 [[ovsdb-client transact unix:socket '
245 "where": [["number", "<", 3]]}]']],
247 ]], [ignore], [test ! -e pid || kill `cat pid`])
248 dnl There should be 6 lines in the log now.
249 AT_CHECK([wc -l < db], [0], [6
250 ], [], [test ! -e pid || kill `cat pid`])
251 dnl Then check that the dumped data is correct.
252 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
253 [test ! -e pid || kill `cat pid`])
254 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0],
256 ------------------------------------ ----- ------
260 ], [], [test ! -e pid || kill `cat pid`])
261 OVSDB_SERVER_SHUTDOWN
264 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)])
266 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
268 # Creates a database with the given SCHEMA, starts an ovsdb-server on
269 # that database, and runs each of the TRANSACTIONS (which should be a
270 # quoted list of quoted strings) against it with ovsdb-client one at a
273 # Checks that the overall output is OUTPUT, but UUIDs in the output
274 # are replaced by markers of the form <N> where N is a number. The
275 # first unique UUID is replaced by <0>, the next by <1>, and so on.
276 # If a given UUID appears more than once it is always replaced by the
279 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
280 m4_define([OVSDB_CHECK_EXECUTION],
282 AT_KEYWORDS([ovsdb server positive ssl $5])
283 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
284 AT_SKIP_IF([test "x$RANDOM" = x])
285 AT_DATA([schema], [$2
287 SSL_PORT=`expr 32767 + \( $RANDOM % 32767 \)`
288 PKIDIR=$abs_top_srcdir/tests
289 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
290 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])
291 m4_foreach([txn], [$3],
292 [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],
293 [test ! -e pid || kill `cat pid`])
296 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
297 [test ! -e pid || kill `cat pid`])
298 OVSDB_SERVER_SHUTDOWN
303 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
305 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
307 # Creates a database with the given SCHEMA and runs each of the
308 # TRANSACTIONS (which should be a quoted list of quoted strings)
309 # against it with ovsdb-client one at a time. Each ovsdb-client
310 # is run against a separately started ovsdb-server that executes
311 # only that single transaction. (The idea is that this should
312 # help to ferret out any differences between what ovsdb-server has
313 # in memory and what actually gets committed to disk.)
315 # Checks that the overall output is OUTPUT, but UUIDs in the output
316 # are replaced by markers of the form <N> where N is a number. The
317 # first unique UUID is replaced by <0>, the next by <1>, and so on.
318 # If a given UUID appears more than once it is always replaced by the
321 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
322 m4_define([OVSDB_CHECK_EXECUTION],
324 AT_KEYWORDS([ovsdb server positive transient $5])
325 AT_DATA([schema], [$2
327 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
328 m4_foreach([txn], [$3],
329 [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
331 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
334 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore])