From: Shad Ansari <shad.ans...@hp.com> 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.ans...@hp.com> Signed-off-by: Ben Pfaff <b...@nicira.com> --- This was posted as a pull request at: https://github.com/openvswitch/ovs/pull/79 I reviewed it and applied it to master. I'm posting it now so that all of the changes appear on the mailing list. AUTHORS | 1 + tests/ovsdb-idl.at | 17 +++++++++++++++++ tests/test-ovsdb.py | 23 +++++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6537ce3..f4e1ca9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -168,6 +168,7 @@ Saurabh Shah ssaur...@nicira.com Scott Lowe scott.l...@scottlowe.org Scott Mann sdm...@gmail.com Selvamuthukumar smku...@merunetworks.com +Shad Ansari shad.ans...@hpe.com Shan Wei davids...@tencent.com Shih-Hao Li s...@nicira.com Shu Shen shu.s...@radisys.com 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 -- 2.1.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev