X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Fovsdb-execution.at;h=90f20ff6caa79bba68e3075706d2905a13513ebe;hb=dfbf7f354416264a0b84b09bf882ac0932e78c8b;hp=ebf11867214ae8f39541e8a4dcae4687a72a2f47;hpb=c5f341ab193b9126dffef8c77bf8ed35e91290fd;p=openvswitch diff --git a/tests/ovsdb-execution.at b/tests/ovsdb-execution.at index ebf11867..90f20ff6 100644 --- a/tests/ovsdb-execution.at +++ b/tests/ovsdb-execution.at @@ -6,7 +6,8 @@ m4_define([ORDINAL_SCHEMA], "ordinals": { "columns": { "number": {"type": "integer"}, - "name": {"type": "string"}}}}, + "name": {"type": "string"}}, + "indexes": [["number"]]}}, "version": "5.1.3", "cksum": "12345678 9"}]]) @@ -26,7 +27,8 @@ m4_define([CONSTRAINT_SCHEMA], "b2a": {"type": {"key": {"type": "uuid", "refTable": "a"}, "min": 0, "max": "unlimited"}}, "b2b": {"type": {"key": {"type": "uuid", "refTable": "b"}, - "min": 0, "max": "unlimited"}}}}, + "min": 0, "max": "unlimited"}}, + "x": {"type": {"key": "integer", "min": 1, "max": 2}}}}, "constrained": { "columns": { "positive": {"type": {"key": {"type": "integer", @@ -552,6 +554,88 @@ OVSDB_CHECK_EXECUTION([insert and update constraints], [{"uuid":["uuid","<1>"]},{"details":"transaction causes \"constrained\" table to contain 2 rows, greater than the schema-defined limit of 1 row(s)","error":"constraint violation"}] ]]) +OVSDB_CHECK_EXECUTION([index uniqueness checking], + [ORDINAL_SCHEMA], +dnl Insert initial row. + [[[["ordinals", + {"op": "insert", + "table": "ordinals", + "row": {"number": 1, "name": "one"}}]]], +dnl Try to insert row with identical value (fails). + [[["ordinals", + {"op": "insert", + "table": "ordinals", + "row": {"number": 1, "name": "another one"}}]]], +dnl Remove initial row and insert new row with identical value in a single +dnl transaction (succeeds). + [[["ordinals", + {"op": "insert", + "table": "ordinals", + "row": {"number": 1, "name": "another one"}}, + {"op": "delete", + "table": "ordinals", + "where": [["name", "==", "one"]]}]]], +dnl Remove row and insert two new rows with identical value in a single +dnl transaction (fails). + [[["ordinals", + {"op": "delete", + "table": "ordinals", + "where": []}, + {"op": "insert", + "table": "ordinals", + "row": {"number": 1, "name": "one"}}, + {"op": "insert", + "table": "ordinals", + "row": {"number": 1, "name": "still another one"}}]]], +dnl Add new row with different value (succeeds). + [[["ordinals", + {"op": "insert", + "table": "ordinals", + "row": {"number": 2, "name": "two"}}]]], +dnl Change rows so values collide (fails). + [[["ordinals", + {"op": "update", + "table": "ordinals", + "where": [], + "row": {"number": 3}}]]], +dnl Swap rows' values (succeeds). + [[["ordinals", + {"op": "update", + "table": "ordinals", + "where": [["number", "==", 1]], + "row": {"number": 2, "name": "old two"}}, + {"op": "update", + "table": "ordinals", + "where": [["name", "==", "two"]], + "row": {"number": 1, "name": "old one"}}]]], +dnl Change all rows' values to values not used before and insert values that +dnl collide (only) with their previous values (succeeds). + [[["ordinals", + {"op": "mutate", + "table": "ordinals", + "where": [], + "mutations": [["number", "*=", 10]]}, + {"op": "insert", + "table": "ordinals", + "row": {"number": 1, "name": "new one"}}, + {"op": "insert", + "table": "ordinals", + "row": {"number": 2, "name": "new two"}}, + {"op": "select", + "table": "ordinals", + "where": [], + "columns": ["number", "name"], + "sort": ["number"]}]]]], + [[[{"uuid":["uuid","<0>"]}] +[{"uuid":["uuid","<1>"]},{"details":"Transaction causes multiple rows in \"ordinals\" table to have identical values (1) for index on column \"number\". First row, with UUID <0>, existed in the database before this transaction and was not modified by the transaction. Second row, with UUID <1>, was inserted by this transaction.","error":"constraint violation"}] +[{"uuid":["uuid","<2>"]},{"count":1}] +[{"count":1},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]},{"details":"Transaction causes multiple rows in \"ordinals\" table to have identical values (1) for index on column \"number\". First row, with UUID <4>, was inserted by this transaction. Second row, with UUID <3>, was inserted by this transaction.","error":"constraint violation"}] +[{"uuid":["uuid","<5>"]}] +[{"count":2},{"details":"Transaction causes multiple rows in \"ordinals\" table to have identical values (3) for index on column \"number\". First row, with UUID <5>, had the following index values before the transaction: 2. Second row, with UUID <2>, had the following index values before the transaction: 1.","error":"constraint violation"}] +[{"count":1},{"count":1}] +[{"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([referential integrity -- simple], [CONSTRAINT_SCHEMA], [[[["constraints", @@ -575,6 +659,12 @@ 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", @@ -601,6 +691,7 @@ OVSDB_CHECK_EXECUTION([referential integrity -- simple], "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}]