ovsdb: Fix race conditions in test suite.
[cascardo/ovs.git] / tests / ovsdb-server.at
1 AT_BANNER([OVSDB -- ovsdb-server transactions])
2
3 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
4 #
5 # Creates a database with the given SCHEMA, starts an ovsdb-server on
6 # that database, and runs each of the TRANSACTIONS (which should be a
7 # quoted list of quoted strings) against it with ovsdb-client one at a
8 # time.
9 #
10 # Checks that the overall output is OUTPUT, but UUIDs in the output
11 # are replaced by markers of the form <N> where N is a number.  The
12 # first unique UUID is replaced by <0>, the next by <1>, and so on.
13 # If a given UUID appears more than once it is always replaced by the
14 # same marker.
15 #
16 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
17 m4_define([OVSDB_CHECK_EXECUTION], 
18   [AT_SETUP([$1])
19    AT_KEYWORDS([ovsdb server positive $5])
20    AT_DATA([schema], [$2
21 ])
22    OVS_CHECK_LCOV([ovsdb-tool create db schema], [0], [stdout], [ignore])
23    AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --listen=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
24    m4_foreach([txn], [$3], 
25      [OVS_CHECK_LCOV([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore],
26      [test ! -e pid || kill `cat pid`])
27 cat stdout >> output
28 ])
29    AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
30             [test ! -e pid || kill `cat pid`])
31    test ! -e pid || kill `cat pid`
32    AT_CLEANUP])
33
34 EXECUTION_EXAMPLES