]> git.proxmox.com Git - ovs.git/blob - tests/ovsdb-server.at
ovsdb: Add tests for OVSDB protocol over SSL.
[ovs.git] / tests / ovsdb-server.at
1 AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
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 --remote=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
35 \f
36 AT_SETUP([--remote=db: implementation])
37 AT_KEYWORDS([ovsdb server positive])
38 AT_DATA([schema],
39 [[{"name": "mydb",
40 "tables": {
41 "Manager": {
42 "columns": {
43 "manager": {"type": "string"}}}}}
44 ]])
45 OVS_CHECK_LCOV([ovsdb-tool create db schema], [0], [ignore], [ignore])
46 OVS_CHECK_LCOV(
47 [[ovsdb-tool transact db \
48 '[{"op": "insert",
49 "table": "Manager",
50 "row": {"manager": "punix:socket"}}]']], [0], [ignore], [ignore])
51 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --remote=db:Manager,manager --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
52 OVS_CHECK_LCOV(
53 [[ovsdb-client transact unix:socket \
54 '[{"op": "select",
55 "table": "Manager",
56 "where": [],
57 "columns": ["manager"]}]']],
58 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
59 AT_CHECK(
60 [perl $srcdir/uuidfilt.pl stdout],
61 [0],
62 [[[{"rows":[{"manager":"punix:socket"}]}]
63 ]],
64 [ignore],
65 [test ! -e pid || kill `cat pid`])
66 test ! -e pid || kill `cat pid`
67 AT_CLEANUP
68 \f
69 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)])
70
71 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
72 #
73 # Creates a database with the given SCHEMA, starts an ovsdb-server on
74 # that database, and runs each of the TRANSACTIONS (which should be a
75 # quoted list of quoted strings) against it with ovsdb-client one at a
76 # time.
77 #
78 # Checks that the overall output is OUTPUT, but UUIDs in the output
79 # are replaced by markers of the form <N> where N is a number. The
80 # first unique UUID is replaced by <0>, the next by <1>, and so on.
81 # If a given UUID appears more than once it is always replaced by the
82 # same marker.
83 #
84 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
85 m4_define([OVSDB_CHECK_EXECUTION],
86 [AT_SETUP([$1])
87 AT_KEYWORDS([ovsdb server positive ssl $5])
88 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
89 AT_SKIP_IF([test "x$RANDOM" = x])
90 AT_DATA([schema], [$2
91 ])
92 SSL_PORT=`expr 32767 + \( $RANDOM % 32767 \)`
93 PKIDIR=$abs_top_srcdir/tests
94 OVS_CHECK_LCOV([ovsdb-tool create db schema], [0], [stdout], [ignore])
95 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])
96 m4_foreach([txn], [$3],
97 [OVS_CHECK_LCOV([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],
98 [test ! -e pid || kill `cat pid`])
99 cat stdout >> output
100 ])
101 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
102 [test ! -e pid || kill `cat pid`])
103 test ! -e pid || kill `cat pid`
104 AT_CLEANUP])
105
106 EXECUTION_EXAMPLES