diff mbox

[ovs-dev] ovsdb-idl: [v2] Test case for Python register_columns function

Message ID 8CA204A851B7B14E86E75054661E41750F97EFFD@G9W0717.americas.hpqcorp.net
State Superseded
Headers show

Commit Message

Ansari, Shad Oct. 6, 2015, 7:30 a.m. UTC
ovsdb-idl: Test script for Python register_columns function

Add test scripts to exercise the register_columns() function of the
Python IDL. Add ability to specify columns in the "idl" command of
test-ovsdb.py. All columns of all tables are monitored by default.
The new "?" option can be used to monitor specific Table:Column(s).
The table and their columns are listed as a string of the form starting
with "?":
          ?<table-name>:<column-name>,<column-name>,...
      e.g.:
          ?simple:b - Monitor column "b" in table "simple"
      Entries for multiple tables are seperated by "?":
          ?<table-name>:<column-name>,...?<table-name>:<column-name>,...
      e.g.:
          ?simple:b?link1:i,k - Monitor column "b" in table "simple",
                                and column "i", "k" in table "link1"

Signed-off-by: Shad Ansari shad.ansari@hp.com<mailto:shad.ansari@hp.com>
---
tests/ovsdb-idl.at  | 17 +++++++++++++++++
tests/test-ovsdb.py | 23 +++++++++++++++++++++--
2 files changed, 38 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index f4d03f8..d3d2aeb 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -48,6 +48,22 @@  m4_define([OVSDB_CHECK_IDL_PY],
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])

+m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY],
+  [AT_SETUP([$1 - Python register_columns])
+   AT_SKIP_IF([test $HAVE_PYTHON = no])
+   AT_KEYWORDS([ovsdb server idl positive Python register_columns $5])
+   AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
+                  [0], [stdout], [ignore])
+   AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
+   m4_if([$2], [], [],
+     [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
+   AT_CHECK([$PYTHON $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 $3],
+            [0], [stdout], [ignore], [kill `cat pid`])
+   AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
+            [0], [$4], [], [kill `cat pid`])
+   OVSDB_SERVER_SHUTDOWN
+   AT_CLEANUP])
+
# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
m4_define([OVSDB_CHECK_IDL_TCP_PY],
   [AT_SETUP([$1 - Python tcp])
@@ -91,6 +107,7 @@  m4_define([OVSDB_CHECK_IDL_TCP6_PY],
m4_define([OVSDB_CHECK_IDL],
   [OVSDB_CHECK_IDL_C($@)
    OVSDB_CHECK_IDL_PY($@)
+   OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY($@)
    OVSDB_CHECK_IDL_TCP_PY($@)
    OVSDB_CHECK_IDL_TCP6_PY($@)])

diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index 4f8d7ca..ab951f9 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -364,7 +364,15 @@  def idl_set(idl, commands, step):

def do_idl(schema_file, remote, *commands):
     schema_helper = ovs.db.idl.SchemaHelper(schema_file)
-    schema_helper.register_all()
+    if commands and commands[0].startswith("?"):
+        monitor = {}
+        for x in commands[0][1:].split("?"):
+            table, columns = x.split(":")
+            monitor[table] = columns.split(",")
+            schema_helper.register_columns(table, monitor[table])
+        commands = commands[1:]
+    else:
+        schema_helper.register_all()
     idl = ovs.db.idl.Idl(remote, schema_helper)

     if commands:
@@ -475,11 +483,22 @@  parse-table NAME OBJECT [DEFAULT-IS-ROOT]
   parse table NAME with info OBJECT
parse-schema JSON
   parse JSON as an OVSDB schema, and re-serialize
-idl SCHEMA SERVER [TRANSACTION...]
+idl SCHEMA SERVER [?T1:C1,C2...[?T2:C1,C2,...]...] [TRANSACTION...]
   connect to SERVER (which has the specified SCHEMA) and dump the
   contents of the database as seen initially by the IDL implementation
   and after executing each TRANSACTION.  (Each TRANSACTION must modify
   the database or this command will hang.)
+  By default, all columns of all tables are monitored. The "?" option
+  can be used to monitor specific Table:Column(s). The table and their
+  columns are listed as a string of the form starting with "?":
+      ?<table-name>:<column-name>,<column-name>,...
+  e.g.:
+      ?simple:b - Monitor column "b" in table "simple"
+  Entries for multiple tables are seperated by "?":
+      ?<table-name>:<column-name>,...?<table-name>:<column-name>,...
+  e.g.:
+      ?simple:b?link1:i,k - Monitor column "b" in table "simple",
+                            and column "i", "k" in table "link1"

The following options are also available:
   -t, --timeout=SECS          give up after SECS seconds