Skip to content

Commit

Permalink
tests: Add ovsdb execution cases for set size constraints.
Browse files Browse the repository at this point in the history
Adding an extra check to one of the ovsdb execution cases that will
verify that ovsdb-server is able to read back transactions previously
written to a database file.  And also adding new execution tests
that cover previously discovered issues with size checks on sets.

Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Jul 24, 2023
1 parent bf02a19 commit eb42e2c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 8 deletions.
54 changes: 47 additions & 7 deletions tests/ovsdb-execution.at
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,53 @@ dnl collide (only) with their previous values (succeeds).
[{"count":2},{"uuid":["uuid","<6>"]},{"uuid":["uuid","<7>"]},{"rows":[{"name":"new one","number":1},{"name":"new two","number":2},{"name":"old one","number":10},{"name":"old two","number":20}]}]
]])

OVSDB_CHECK_EXECUTION([size constraints on sets],
[constraint_schema],
[
[[["constraints",
{"op": "insert",
"table": "b",
"row": {"b": 1}
}]]],
[[["constraints",
{"op": "mutate",
"table": "b",
"where": [],
"mutations": [["x", "delete", 0]]
}]]],
[[["constraints",
{"op": "mutate",
"table": "b",
"where": [],
"mutations": [["x", "insert", 1]]
}]]],
[[["constraints",
{"op": "update",
"table": "b",
"where": [],
"row": {"x": ["set", [3, 4]]}
}]]],
[[["constraints",
{"op": "mutate",
"table": "b",
"where": [],
"mutations": [["x", "insert", 5]]
}]]],
[[["constraints",
{"op": "mutate",
"table": "b",
"where": [],
"mutations": [["x", "delete", 4], ["x", "insert", 5]]
}]]]
],
[[[{"uuid":["uuid","<0>"]}]
[{"details":"Attempted to store 0 elements in set of 1 to 2 integers.","error":"constraint violation"}]
[{"count":1}]
[{"count":1}]
[{"details":"Attempted to store 3 elements in set of 1 to 2 integers.","error":"constraint violation"}]
[{"count":1}]
]])

OVSDB_CHECK_EXECUTION([referential integrity -- simple],
[constraint_schema],
[[[["constraints",
Expand All @@ -751,12 +798,6 @@ OVSDB_CHECK_EXECUTION([referential integrity -- simple],
{"op": "delete",
"table": "b",
"where": []}]]],
dnl Check that "mutate" honors number-of-elements constraints on sets and maps.
[[["constraints",
{"op": "mutate",
"table": "b",
"where": [],
"mutations": [["x", "delete", 0]]}]]],
[[["constraints",
{"op": "delete",
"table": "a",
Expand All @@ -783,7 +824,6 @@ dnl Check that "mutate" honors number-of-elements constraints on sets and maps.
"where": []}]]]],
[[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
[{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
[{"details":"Attempted to store 0 elements in set of 1 to 2 integers.","error":"constraint violation"}]
[{"count":1}]
[{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
[{"count":1}]
Expand Down
15 changes: 14 additions & 1 deletion tests/ovsdb-server.at
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,32 @@ m4_define([OVSDB_SERVER_SHUTDOWN2],
# If a given UUID appears more than once it is always replaced by the
# same marker.
#
# Additionally, checks that records written to a database file can be
# read back producing the same in-memory database content.
#
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
m4_define([OVSDB_CHECK_EXECUTION],
[AT_SETUP([$1])
AT_KEYWORDS([ovsdb server positive unix $5])
$2 > schema
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
on_exit 'kill `cat *.pid`'
AT_CHECK([ovsdb-server --detach --no-chdir --log-file --pidfile --remote=punix:socket db], [0], [ignore], [ignore])
AT_CHECK([ovsdb-server --detach --no-chdir --log-file --pidfile \
--remote=punix:socket db], [0], [ignore], [ignore])
m4_foreach([txn], [$3],
[AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore])
cat stdout >> output
])
AT_CHECK([uuidfilt output], [0], [$4], [ignore])

AT_CHECK([ovsdb-client dump unix:socket], [0], [stdout], [ignore])

OVSDB_SERVER_SHUTDOWN

AT_CHECK([ovsdb-server --detach --no-chdir --log-file --pidfile \
--remote=punix:socket db], [0], [ignore], [ignore])
OVS_WAIT_UNTIL([ovsdb-client dump unix:socket > dump2; diff stdout dump2])

OVSDB_SERVER_SHUTDOWN
AT_CLEANUP])

Expand Down

0 comments on commit eb42e2c

Please sign in to comment.