diff mbox series

[ovs-dev,4/4] tests: Add ovsdb execution cases for set size constraints.

Message ID 20230725093220.1408301-5-i.maximets@ovn.org
State Accepted
Commit d6fd6e5917dc9579f50fd271f848361c6e11a693
Headers show
Series ovsdb: Fixes for a set size constraints. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Ilya Maximets July 25, 2023, 9:32 a.m. UTC
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 <i.maximets@ovn.org>
---
 tests/ovsdb-execution.at | 54 ++++++++++++++++++++++++++++++++++------
 tests/ovsdb-server.at    | 15 ++++++++++-
 2 files changed, 61 insertions(+), 8 deletions(-)

Comments

Dumitru Ceara Aug. 2, 2023, 8:19 p.m. UTC | #1
On 7/25/23 11:32, Ilya Maximets wrote:
> 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 <i.maximets@ovn.org>
> ---
>  tests/ovsdb-execution.at | 54 ++++++++++++++++++++++++++++++++++------
>  tests/ovsdb-server.at    | 15 ++++++++++-

tests++

Looks good to me, thanks!

Acked-by: Dumitru Ceara <dceara@redhat.com>
Ilya Maximets Aug. 3, 2023, 2:43 p.m. UTC | #2
On 8/2/23 22:19, Dumitru Ceara wrote:
> On 7/25/23 11:32, Ilya Maximets wrote:
>> 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 <i.maximets@ovn.org>
>> ---
>>  tests/ovsdb-execution.at | 54 ++++++++++++++++++++++++++++++++++------
>>  tests/ovsdb-server.at    | 15 ++++++++++-
> 
> tests++
> 
> Looks good to me, thanks!
> 
> Acked-by: Dumitru Ceara <dceara@redhat.com>
> 

Thanks, Dumitru!

I fixed the typos and applied the set.  Backported down to 2.17.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/tests/ovsdb-execution.at b/tests/ovsdb-execution.at
index e72bf0606..fd1c7a239 100644
--- a/tests/ovsdb-execution.at
+++ b/tests/ovsdb-execution.at
@@ -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",
@@ -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",
@@ -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}]
diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at
index 8ccec80bc..d36c3c117 100644
--- a/tests/ovsdb-server.at
+++ b/tests/ovsdb-server.at
@@ -26,6 +26,9 @@  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])
@@ -33,12 +36,22 @@  m4_define([OVSDB_CHECK_EXECUTION],
    $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])