2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-27 15:18:06 +00:00

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>
This commit is contained in:
Shad Ansari
2015-10-07 13:52:11 -07:00
committed by Ben Pfaff
parent c2926d6d1c
commit 01dc151684
3 changed files with 39 additions and 2 deletions

View File

@@ -168,6 +168,7 @@ Saurabh Shah ssaurabh@nicira.com
Scott Lowe scott.lowe@scottlowe.org
Scott Mann sdmnix@gmail.com
Selvamuthukumar smkumar@merunetworks.com
Shad Ansari shad.ansari@hpe.com
Shan Wei davidshan@tencent.com
Shih-Hao Li shli@nicira.com
Shu Shen shu.shen@radisys.com

View File

@@ -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($@)])

View File

@@ -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