2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 13:58:14 +00:00

ovsdb: Add tests for file storage and for ovsdb-server.

This commit is contained in:
Ben Pfaff 2009-11-16 15:13:00 -08:00
parent 6d65eee8b1
commit 21ff1aee1b
6 changed files with 179 additions and 86 deletions

View File

@ -28,6 +28,8 @@ TESTSUITE_AT = \
tests/ovsdb-transaction.at \ tests/ovsdb-transaction.at \
tests/ovsdb-execution.at \ tests/ovsdb-execution.at \
tests/ovsdb-trigger.at \ tests/ovsdb-trigger.at \
tests/ovsdb-file.at \
tests/ovsdb-server.at \
tests/stp.at \ tests/stp.at \
tests/ovs-vsctl.at \ tests/ovs-vsctl.at \
tests/lcov-post.at tests/lcov-post.at
@ -35,7 +37,7 @@ TESTSUITE = $(srcdir)/tests/testsuite
DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE) DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE)
check-local: tests/atconfig tests/atlocal $(TESTSUITE) check-local: tests/atconfig tests/atlocal $(TESTSUITE)
$(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH='utilities:vswitchd:tests' $(TESTSUITEFLAGS) $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH='utilities:vswitchd:ovsdb:tests' $(TESTSUITEFLAGS)
clean-local: clean-local:
test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean

View File

@ -1,51 +1,60 @@
AT_BANNER([OVSDB -- execution]) AT_BANNER([OVSDB -- execution])
m4_define([ORDINAL_SCHEMA], m4_define([ORDINAL_SCHEMA],
[['{"name": "mydb", [[{"name": "mydb",
"tables": { "tables": {
"ordinals": { "ordinals": {
"columns": { "columns": {
"number": {"type": "integer"}, "number": {"type": "integer"},
"name": {"type": "string"}}}}}']]) "name": {"type": "string"}}}}}]])
# This is like OVSDB_CHECK_POSITIVE, except that UUIDs in the output # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
#
# Runs "test-ovsdb execute" with the given SCHEMA and each of the
# TRANSACTIONS (which should be a quoted list of quoted strings).
#
# Checks that the overall output is OUTPUT, but UUIDs in the output
# are replaced by markers of the form <N> where N is a number. The # are replaced by markers of the form <N> where N is a number. The
# first unique UUID is replaced by <0>, the next by <1>, and so on. # first unique UUID is replaced by <0>, the next by <1>, and so on.
# If a given UUID appears more than once it is always replaced by the # If a given UUID appears more than once it is always replaced by the
# same marker. # same marker.
#
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
m4_define([OVSDB_CHECK_EXECUTION], m4_define([OVSDB_CHECK_EXECUTION],
[AT_SETUP([$1]) [AT_SETUP([$1])
AT_KEYWORDS([ovsdb execute execution positive $4]) AT_KEYWORDS([ovsdb execute execution positive $5])
OVS_CHECK_LCOV([test-ovsdb execute $2], [0], [stdout], []) OVS_CHECK_LCOV([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$3]) [0], [stdout], [])
AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
AT_CLEANUP]) AT_CLEANUP])
m4_define([EXECUTION_EXAMPLES], [
OVSDB_CHECK_EXECUTION([insert row, query table], OVSDB_CHECK_EXECUTION([insert row, query table],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}]' \ "row": {"number": 0, "name": "zero"}}]]],
'[{"op": "select", [[[{"op": "select",
"table": "ordinals", "table": "ordinals",
"where": []}]']], "where": []}]]]],
[[[{"uuid":["uuid","<0>"]}] [[[{"uuid":["uuid","<0>"]}]
[{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}] [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
]]) ]])
OVSDB_CHECK_EXECUTION([insert rows, query by value], OVSDB_CHECK_EXECUTION([insert rows, query by value],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}]' \ "row": {"number": 0, "name": "zero"}}]]],
'[{"op": "insert", [[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 1, "name": "one"}}]' \ "row": {"number": 1, "name": "one"}}]]],
'[{"op": "select", [[[{"op": "select",
"table": "ordinals", "table": "ordinals",
"where": [["name", "==", "zero"]]}]'\ "where": [["name", "==", "zero"]]}]]],
'[{"op": "select", [[[{"op": "select",
"table": "ordinals", "table": "ordinals",
"where": [["name", "==", "one"]]}]']], "where": [["name", "==", "one"]]}]]]],
[[[{"uuid":["uuid","<0>"]}] [[[{"uuid":["uuid","<0>"]}]
[{"uuid":["uuid","<1>"]}] [{"uuid":["uuid","<1>"]}]
[{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}] [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
@ -53,8 +62,8 @@ OVSDB_CHECK_EXECUTION([insert rows, query by value],
]]) ]])
OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid], OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}, "row": {"number": 0, "name": "zero"},
"uuid-name": "first"}, "uuid-name": "first"},
@ -67,28 +76,28 @@ OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
"where": [["_uuid", "==", ["named-uuid", "first"]]]}, "where": [["_uuid", "==", ["named-uuid", "first"]]]},
{"op": "select", {"op": "select",
"table": "ordinals", "table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "second"]]]}]']], "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]},{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]},{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
]]) ]])
OVSDB_CHECK_EXECUTION([insert rows, update rows by value], OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}, "row": {"number": 0, "name": "zero"},
"uuid-name": "first"}]' \ "uuid-name": "first"}]]],
'[{"op": "insert", [[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 1, "name": "one"}, "row": {"number": 1, "name": "one"},
"uuid-name": "first"}]' \ "uuid-name": "first"}]]],
'[{"op": "update", [[[{"op": "update",
"table": "ordinals", "table": "ordinals",
"where": [["name", "==", "zero"]], "where": [["name", "==", "zero"]],
"row": {"name": "nought"}}]' \ "row": {"name": "nought"}}]]],
'[{"op": "select", [[[{"op": "select",
"table": "ordinals", "table": "ordinals",
"where": [], "where": [],
"sort": ["number"]}]']], "sort": ["number"]}]]]],
[[[{"uuid":["uuid","<0>"]}] [[[{"uuid":["uuid","<0>"]}]
[{"uuid":["uuid","<1>"]}] [{"uuid":["uuid","<1>"]}]
[{"count":1}] [{"count":1}]
@ -96,8 +105,8 @@ OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
]]) ]])
OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid], OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}, "row": {"number": 0, "name": "zero"},
"uuid-name": "first"}, "uuid-name": "first"},
@ -111,26 +120,26 @@ OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
{"op": "select", {"op": "select",
"table": "ordinals", "table": "ordinals",
"where": [], "where": [],
"columns": ["name","number"]}]']], "columns": ["name","number"]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
]]) ]])
OVSDB_CHECK_EXECUTION([insert rows, delete rows by value], OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}, "row": {"number": 0, "name": "zero"},
"uuid-name": "first"}]' \ "uuid-name": "first"}]]],
'[{"op": "insert", [[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 1, "name": "one"}, "row": {"number": 1, "name": "one"},
"uuid-name": "first"}]' \ "uuid-name": "first"}]]],
'[{"op": "delete", [[[{"op": "delete",
"table": "ordinals", "table": "ordinals",
"where": [["name", "==", "zero"]]}]' \ "where": [["name", "==", "zero"]]}]]],
'[{"op": "select", [[[{"op": "select",
"table": "ordinals", "table": "ordinals",
"where": []}]']], "where": []}]]]],
[[[{"uuid":["uuid","<0>"]}] [[[{"uuid":["uuid","<0>"]}]
[{"uuid":["uuid","<1>"]}] [{"uuid":["uuid","<1>"]}]
[{"count":1}] [{"count":1}]
@ -138,22 +147,22 @@ OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
]]) ]])
OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value], OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}, "row": {"number": 0, "name": "zero"},
"uuid-name": "first"}]' \ "uuid-name": "first"}]]],
'[{"op": "insert", [[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 1, "name": "one"}, "row": {"number": 1, "name": "one"},
"uuid-name": "first"}]' \ "uuid-name": "first"}]]],
'[{"op": "delete", [[[{"op": "delete",
"table": "ordinals", "table": "ordinals",
"where": [["name", "==", "nought"]]}]' \ "where": [["name", "==", "nought"]]}]]],
'[{"op": "select", [[[{"op": "select",
"table": "ordinals", "table": "ordinals",
"where": [], "where": [],
"sort": ["number"]}]']], "sort": ["number"]}]]]],
[[[{"uuid":["uuid","<0>"]}] [[[{"uuid":["uuid","<0>"]}]
[{"uuid":["uuid","<1>"]}] [{"uuid":["uuid","<1>"]}]
[{"count":0}] [{"count":0}]
@ -161,8 +170,8 @@ OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
]]) ]])
OVSDB_CHECK_EXECUTION([insert rows, delete all], OVSDB_CHECK_EXECUTION([insert rows, delete all],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}, "row": {"number": 0, "name": "zero"},
"uuid-name": "first"}, "uuid-name": "first"},
@ -176,39 +185,39 @@ OVSDB_CHECK_EXECUTION([insert rows, delete all],
{"op": "select", {"op": "select",
"table": "ordinals", "table": "ordinals",
"where": [], "where": [],
"columns": ["name","number"]}]']], "columns": ["name","number"]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
]]) ]])
OVSDB_CHECK_EXECUTION([insert row, query table, commit], OVSDB_CHECK_EXECUTION([insert row, query table, commit],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
{"op": "select", {"op": "select",
"table": "ordinals", "table": "ordinals",
"where": []}, "where": []},
{"op": "commit", {"op": "commit",
"durable": false}]']], "durable": false}]]]],
[[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}] [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
]]) ]])
OVSDB_CHECK_EXECUTION([insert row, query table, commit durably], OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
{"op": "select", {"op": "select",
"table": "ordinals", "table": "ordinals",
"where": []}, "where": []},
{"op": "commit", {"op": "commit",
"durable": true}]']], "durable": true}]]]],
[[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}] [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
]]) ]])
OVSDB_CHECK_EXECUTION([equality wait with correct rows], OVSDB_CHECK_EXECUTION([equality wait with correct rows],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
{"op": "insert", {"op": "insert",
@ -221,13 +230,13 @@ OVSDB_CHECK_EXECUTION([equality wait with correct rows],
"columns": ["name", "number"], "columns": ["name", "number"],
"until": "==", "until": "==",
"rows": [{"name": "zero", "number": 0}, "rows": [{"name": "zero", "number": 0},
{"name": "one", "number": 1}]}]']], {"name": "one", "number": 1}]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
]]) ]])
OVSDB_CHECK_EXECUTION([equality wait with extra row], OVSDB_CHECK_EXECUTION([equality wait with extra row],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
{"op": "insert", {"op": "insert",
@ -241,13 +250,13 @@ OVSDB_CHECK_EXECUTION([equality wait with extra row],
"until": "==", "until": "==",
"rows": [{"name": "zero", "number": 0}, "rows": [{"name": "zero", "number": 0},
{"name": "one", "number": 1}, {"name": "one", "number": 1},
{"name": "two", "number": 2}]}]']], {"name": "two", "number": 2}]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
]]) ]])
OVSDB_CHECK_EXECUTION([equality wait with missing row], OVSDB_CHECK_EXECUTION([equality wait with missing row],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
{"op": "insert", {"op": "insert",
@ -259,13 +268,13 @@ OVSDB_CHECK_EXECUTION([equality wait with missing row],
"where": [], "where": [],
"columns": ["name", "number"], "columns": ["name", "number"],
"until": "==", "until": "==",
"rows": [{"name": "one", "number": 1}]}]']], "rows": [{"name": "one", "number": 1}]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
]]) ]])
OVSDB_CHECK_EXECUTION([inequality wait with correct rows], OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
{"op": "insert", {"op": "insert",
@ -278,13 +287,13 @@ OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
"columns": ["name", "number"], "columns": ["name", "number"],
"until": "!=", "until": "!=",
"rows": [{"name": "zero", "number": 0}, "rows": [{"name": "zero", "number": 0},
{"name": "one", "number": 1}]}]']], {"name": "one", "number": 1}]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
]]) ]])
OVSDB_CHECK_EXECUTION([inequality wait with extra row], OVSDB_CHECK_EXECUTION([inequality wait with extra row],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
{"op": "insert", {"op": "insert",
@ -298,13 +307,13 @@ OVSDB_CHECK_EXECUTION([inequality wait with extra row],
"until": "!=", "until": "!=",
"rows": [{"name": "zero", "number": 0}, "rows": [{"name": "zero", "number": 0},
{"name": "one", "number": 1}, {"name": "one", "number": 1},
{"name": "two", "number": 2}]}]']], {"name": "two", "number": 2}]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
]]) ]])
OVSDB_CHECK_EXECUTION([inequality wait with missing row], OVSDB_CHECK_EXECUTION([inequality wait with missing row],
[ORDINAL_SCHEMA [\ [ORDINAL_SCHEMA],
'[{"op": "insert", [[[[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
{"op": "insert", {"op": "insert",
@ -316,6 +325,9 @@ OVSDB_CHECK_EXECUTION([inequality wait with missing row],
"where": [], "where": [],
"columns": ["name", "number"], "columns": ["name", "number"],
"until": "!=", "until": "!=",
"rows": [{"name": "one", "number": 1}]}]']], "rows": [{"name": "one", "number": 1}]}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
]]) ]])
])
EXECUTION_EXAMPLES

30
tests/ovsdb-file.at Normal file
View File

@ -0,0 +1,30 @@
AT_BANNER([OVSDB -- file storage])
# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
#
# Creates a database with the given SCHEMA and runs each of the
# TRANSACTIONS (which should be a quoted list of quoted strings)
# against it with ovsdb-tool one at a time.
#
# Checks that the overall output is OUTPUT, but UUIDs in the output
# are replaced by markers of the form <N> where N is a number. The
# first unique UUID is replaced by <0>, the next by <1>, and so on.
# If a given UUID appears more than once it is always replaced by the
# same marker.
#
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
m4_define([OVSDB_CHECK_EXECUTION],
[AT_SETUP([$1])
AT_KEYWORDS([ovsdb file positive $5])
AT_DATA([schema], [$2
])
touch .db.~lock~
OVS_CHECK_LCOV([ovsdb-tool create db schema], [0], [stdout], [ignore])
m4_foreach([txn], [$3],
[OVS_CHECK_LCOV([ovsdb-tool transact db 'txn'], [0], [stdout], [ignore])
cat stdout >> output
])
AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4])
AT_CLEANUP])
EXECUTION_EXAMPLES

34
tests/ovsdb-server.at Normal file
View File

@ -0,0 +1,34 @@
AT_BANNER([OVSDB -- ovsdb-server transactions])
# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
#
# Creates a database with the given SCHEMA, starts an ovsdb-server on
# that database, and runs each of the TRANSACTIONS (which should be a
# quoted list of quoted strings) against it with ovsdb-client one at a
# time.
#
# Checks that the overall output is OUTPUT, but UUIDs in the output
# are replaced by markers of the form <N> where N is a number. The
# first unique UUID is replaced by <0>, the next by <1>, and so on.
# If a given UUID appears more than once it is always replaced by the
# same marker.
#
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
m4_define([OVSDB_CHECK_EXECUTION],
[AT_SETUP([$1])
AT_KEYWORDS([ovsdb server positive $5])
AT_DATA([schema], [$2
])
OVS_CHECK_LCOV([ovsdb-tool create db schema], [0], [stdout], [ignore])
AT_CHECK([ovsdb-server --verbose --detach --pidfile=$PWD/pid --listen=punix:socket db])
m4_foreach([txn], [$3],
[OVS_CHECK_LCOV([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore],
[test ! -e pid || kill `cat pid`])
cat stdout >> output
])
AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [],
[test ! -e pid || kill `cat pid`])
test ! -e pid || kill `cat pid`
AT_CLEANUP])
EXECUTION_EXAMPLES

View File

@ -13,7 +13,7 @@ m4_define([OVSDB_CHECK_TRIGGER],
AT_CLEANUP]) AT_CLEANUP])
OVSDB_CHECK_TRIGGER([trigger fires immediately], OVSDB_CHECK_TRIGGER([trigger fires immediately],
[ORDINAL_SCHEMA [\ ['ORDINAL_SCHEMA' [\
'[{"op": "insert", '[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
@ -35,7 +35,7 @@ OVSDB_CHECK_TRIGGER([trigger fires immediately],
]]) ]])
OVSDB_CHECK_TRIGGER([trigger times out], OVSDB_CHECK_TRIGGER([trigger times out],
[ORDINAL_SCHEMA [\ ['ORDINAL_SCHEMA' [\
'[{"op": "insert", '[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
@ -57,7 +57,7 @@ t=10: trigger 0 (delayed): [{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"de
]]) ]])
OVSDB_CHECK_TRIGGER([trigger fires after delay], OVSDB_CHECK_TRIGGER([trigger fires after delay],
[ORDINAL_SCHEMA [\ ['ORDINAL_SCHEMA' [\
'[{"op": "insert", '[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
@ -85,7 +85,7 @@ t=10: trigger 1 (delayed): [{}]
]]) ]])
OVSDB_CHECK_TRIGGER([delayed trigger modifies database], OVSDB_CHECK_TRIGGER([delayed trigger modifies database],
[ORDINAL_SCHEMA [\ ['ORDINAL_SCHEMA' [\
'[{"op": "insert", '[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},
@ -121,7 +121,7 @@ t=15: trigger 3 (immediate): [{"rows":[{"_uuid":["uuid","<2>"],"_version":["uuid
]]) ]])
OVSDB_CHECK_TRIGGER([one delayed trigger wakes up another], OVSDB_CHECK_TRIGGER([one delayed trigger wakes up another],
[ORDINAL_SCHEMA [\ ['ORDINAL_SCHEMA' [\
'[{"op": "insert", '[{"op": "insert",
"table": "ordinals", "table": "ordinals",
"row": {"number": 0, "name": "zero"}}, "row": {"number": 0, "name": "zero"}},

View File

@ -1,3 +1,11 @@
# OVSDB_CHECK_POSITIVE(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS], [PREREQ])
#
# Runs "test-ovsdb TEST-OVSDB-ARGS" and checks that it exits with
# status 0 and prints OUTPUT on stdout.
#
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. If
# PREREQ is specified then the test is skipped if the Autoconf version
# is less than PREREQ.
m4_define([OVSDB_CHECK_POSITIVE], m4_define([OVSDB_CHECK_POSITIVE],
[AT_SETUP([$1]) [AT_SETUP([$1])
m4_if([$5], [], [], m4_if([$5], [], [],
@ -7,6 +15,11 @@ m4_define([OVSDB_CHECK_POSITIVE],
], []) ], [])
AT_CLEANUP]) AT_CLEANUP])
# OVSDB_CHECK_NEGATIVE(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS], [PREREQ])
#
# Runs "test-ovsdb TEST-OVSDB-ARGS" and checks that it exits with
# status 1 and that its output on stdout contains substring OUTPUT.
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
m4_define([OVSDB_CHECK_NEGATIVE], m4_define([OVSDB_CHECK_NEGATIVE],
[AT_SETUP([$1]) [AT_SETUP([$1])
AT_KEYWORDS([ovsdb negative $4]) AT_KEYWORDS([ovsdb negative $4])
@ -33,3 +46,5 @@ m4_include([tests/ovsdb-query.at])
m4_include([tests/ovsdb-transaction.at]) m4_include([tests/ovsdb-transaction.at])
m4_include([tests/ovsdb-execution.at]) m4_include([tests/ovsdb-execution.at])
m4_include([tests/ovsdb-trigger.at]) m4_include([tests/ovsdb-trigger.at])
m4_include([tests/ovsdb-file.at])
m4_include([tests/ovsdb-server.at])