[ovs-dev] [PATCH 1/2] ovsdb-idl.at: Make test outputs predictable.

Dumitru Ceara dceara at redhat.com
Tue Mar 2 12:44:43 UTC 2021


IDL tests need predictable output from test-ovsdb.

This used to be done by first sorting the output of test-ovsdb and then
applying uuidfilt to predictably translate UUIDs.  This was not
reliable enough in case test-ovsdb processes two or more insert/delete
operations in the same iteration because the order of lines in the
output depends on the automatically generated UUID values.

To fix this we now perform another sort operation after uuidfilt has
been applied.  This might not be the most efficient way of ensuring
predictable output but it seems to be the one that requires the least
code changes.

Assuming the following equivalent outputs:
  $ cat o1
  001: x=0 y=00000000-0000-0000-0000-000000000000
  001: x=1 y=10000000-0000-0000-0000-000000000000
  002: z=10000000-0000-0000-0000-000000000000
  002: z=00000000-0000-0000-0000-000000000000
  $ cat o2
  001: x=0 y=10000000-0000-0000-0000-000000000000
  001: x=1 y=00000000-0000-0000-0000-000000000000
  002: z=00000000-0000-0000-0000-000000000000
  002: z=10000000-0000-0000-0000-000000000000

Without the additional sort:
  $ sort o1 | tests/uuidfilt.py
  001: x=0 y=<0>
  001: x=1 y=<1>
  002: z=<0>
  002: z=<1>
  $ sort o2 | tests/uuidfilt.py
  001: x=0 y=<0>
  001: x=1 y=<1>
  002: z=<1>
  002: z=<0>

With the additional sort:
  $ sort o1 | tests/uuidfilt.py | sort
  001: x=0 y=<0>
  001: x=1 y=<1>
  002: z=<0>
  002: z=<1>
  $ sort o2 | tests/uuidfilt.py | sort
  001: x=0 y=<0>
  001: x=1 y=<1>
  002: z=<0>
  002: z=<1>

Signed-off-by: Dumitru Ceara <dceara at redhat.com>
---
Note: the old approach was enough for outputs of the existing tests but
the next patch in this series adds a new test that requires this
change.
---
 tests/ovsdb-idl.at |   40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index 4b4791a..44353cc 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -82,7 +82,7 @@ m4_define([OVSDB_CHECK_IDL_C],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -98,7 +98,7 @@ m4_define([OVSDB_CHECK_IDL_TCP_C],
      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl tcp:127.0.0.1:$TCP_PORT $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -116,7 +116,7 @@ m4_define([OVSDB_CHECK_IDL_TCP6_C],
      [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT $2], [0], [ignore], [ignore])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl tcp:[[::1]]:$TCP_PORT $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -130,7 +130,7 @@ m4_define([OVSDB_CHECK_IDL_PY],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -143,7 +143,7 @@ m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema unix:socket ?simple:b,ba,i,ia,r,ra,s,sa,u,ua?link1:i,k,ka,l2?link2:i,l1?singleton:name $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -159,7 +159,7 @@ m4_define([OVSDB_CHECK_IDL_TCP_PY],
      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -178,7 +178,7 @@ m4_define([OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY],
      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t20 idl $srcdir/idltest.ovsschema $remote $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -197,7 +197,7 @@ m4_define([OVSDB_CHECK_IDL_TCP6_PY],
      [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -216,7 +216,7 @@ m4_define([OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY],
      [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t20 idl $srcdir/idltest.ovsschema $remote $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -250,7 +250,7 @@ m4_define([OVSDB_CHECK_IDL_SSL_PY],
              ssl:127.0.0.1:$TCP_PORT $PKIDIR/testpki-privkey.pem \
              $PKIDIR/testpki-cert.pem $PKIDIR/testpki-cacert.pem $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -281,7 +281,7 @@ m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PY],
    AT_CHECK([ovsdb_start_idltest "tcp:127.0.0.1:$TCP_PORT"])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl_passive $srcdir/idltest.ovsschema ptcp:127.0.0.1:$TCP_PORT $3],
       [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP
@@ -464,7 +464,7 @@ m4_define([OVSDB_CHECK_IDL_PY_WITH_EXPOUT],
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
             [0], [stdout], [ignore])
    echo "$4" > expout
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [expout])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -943,7 +943,7 @@ AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl uni
        "where": [],
        "row": {"k": ["uuid", "#0#"]}}]']],
          [0], [stdout], [stderr])
-AT_CHECK([sort stdout | uuidfilt], [0],
+AT_CHECK([sort stdout | uuidfilt | sort], [0],
     [[000: empty
 001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
 002: i=0 k=0 ka=[] l2= uuid=<0>
@@ -994,7 +994,7 @@ m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PY],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema unix:socket [$3] $4],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$7],,, [[| $7]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$7],,, [[| $7]]),
             [0], [$5])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -1037,7 +1037,7 @@ m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PY],
    AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor-cond])
    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema unix:socket $2],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$5],,, [[| $5]]),
             [0], [$3])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -1131,7 +1131,7 @@ m4_define([OVSDB_CHECK_IDL_TRACK_C],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl unix:socket $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -1369,7 +1369,7 @@ m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-map-column unix:socket $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -1430,7 +1430,7 @@ m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-set-column unix:socket $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -1879,7 +1879,7 @@ m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index-with-ref unix:socket $3],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$6],,, [[| $6]]),
             [0], [$4])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
@@ -1958,7 +1958,7 @@ m4_define([OVSDB_CHECK_CLUSTER_IDL_C],
      [AT_CHECK([ovsdb-client transact $remotes $3], [0], [ignore], [ignore])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl tcp:LPBK:$TCP_PORT_1 $4],
             [0], [stdout], [ignore])
-   AT_CHECK([sort stdout | uuidfilt]m4_if([$7],,, [[| $7]]),
+   AT_CHECK([sort stdout | uuidfilt | sort]m4_if([$7],,, [[| $7]]),
             [0], [$5])
    AT_CLEANUP])
 



More information about the dev mailing list