summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorShad Ansari <shad.ansari@hp.com>2015-10-07 13:52:11 -0700
committerBen Pfaff <blp@nicira.com>2015-10-13 16:10:43 -0700
commit01dc151684a2deca7aa7bcd43c7b21da84140bf7 (patch)
treee68bd4643fbea9a9da41306f02026da537421ccc /tests
parentc2926d6d1cfd62b6d1fbab5497f61de98144f205 (diff)
downloadopenvswitch-01dc151684a2deca7aa7bcd43c7b21da84140bf7.tar.gz
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> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ovsdb-idl.at17
-rw-r--r--tests/test-ovsdb.py23
2 files changed, 38 insertions, 2 deletions
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index f4d03f8bd..d3d2aeb5f 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 4f8d7cac5..ab951f9d4 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