From patchwork Tue Oct 13 23:12:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 529945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 8826F140F99 for ; Wed, 14 Oct 2015 10:12:15 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 6385A1089F; Tue, 13 Oct 2015 16:12:14 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 09C001089D for ; Tue, 13 Oct 2015 16:12:14 -0700 (PDT) Received: from bar4.cudamail.com (bar2 [192.168.15.2]) by mx3v1.cudamail.com (Postfix) with ESMTP id 6C599618579 for ; Tue, 13 Oct 2015 17:12:13 -0600 (MDT) X-ASG-Debug-ID: 1444777932-03dc21430b21260001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar4.cudamail.com with ESMTP id RvhWV41FIHysBgaE (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 13 Oct 2015 17:12:12 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mail-pa0-f48.google.com) (209.85.220.48) by mx3-pf3.cudamail.com with ESMTPS (RC4-SHA encrypted); 13 Oct 2015 23:12:11 -0000 Received-SPF: unknown (mx3-pf3.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.48 Received: by pabrc13 with SMTP id rc13so34427387pab.0 for ; Tue, 13 Oct 2015 16:12:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xhO62SDuvGi41pNQqxH3qgsZQzll8Dc47BkMzzOLjEE=; b=dbcR2lXJ6pNYqLNQyKXi/HstWiugi41ZfzNbnSfyU80O72/Y5qQS3mVbh27SMkC2rh Nx6v0LgVQ6kGzD76Nm5C0Eghj9vR2Tc9qMdSKCU0+5JpSJoVxKUNBLzDlORhEYi348AH a2AlrCmTFBu7CgcCNziTWZ4PMEv854ZMGx+muN08AxxGBQSn+nzCwGXn8ltMgVb+fju2 o+Tqv/9vMhIR6TfqAbHXI7Mo/yoZE3kwSVePAnvR/+G/FEXCiSTSHtbBkw/In53N1XMU aSvTM8TQMYFXWes83N31kKOJgpPDSVs1Eo+TxlEIZ+pxc60u8skovRonkmp4eJQXGWaV Tdjw== X-Gm-Message-State: ALoCoQmFOxIILoMe/H98LGyRjA8SCcPSnNZc2BFRW1hGevpSjlQp6lNdQoEjRGmsrQouxrE1vax1 X-Received: by 10.66.131.81 with SMTP id ok17mr3053pab.150.1444777931518; Tue, 13 Oct 2015 16:12:11 -0700 (PDT) Received: from sigabrt.benpfaff.org ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id pq1sm5799010pbb.91.2015.10.13.16.12.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Oct 2015 16:12:10 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1012074657 X-CudaMail-DTE: 101315 X-CudaMail-Originating-IP: 209.85.220.48 Date: Tue, 13 Oct 2015 16:12:07 -0700 X-ASG-Orig-Subj: [##CM-V3-1012074657##][PATCH] ovsdb-idl: Test script for Python register_columns function Message-Id: <1444777927-26649-1-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1444777932 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH] ovsdb-idl: Test script for Python register_columns function X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" From: Shad Ansari 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 "?": ?:,,... e.g.: ?simple:b - Monitor column "b" in table "simple" Entries for multiple tables are seperated by "?": ?:,...?:,... 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 Signed-off-by: Ben Pfaff --- 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 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 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 "?": + ?:,,... + e.g.: + ?simple:b - Monitor column "b" in table "simple" + Entries for multiple tables are seperated by "?": + ?:,...?:,... + 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