X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=tests%2Fovsdb-idl.at;h=d3d2aeb5f2ace644cd725c7bbe9e0107702eaf42;hb=5f8c05ad9da5a6e2cbadd0b1ae74a4b2f24e62ea;hp=a8ce3ca54944b52554ea219cf4aa28845244640a;hpb=4fdfe5ccf84c473ad98300cb9050889b033768df;p=cascardo%2Fovs.git diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at index a8ce3ca54..d3d2aeb5f 100644 --- a/tests/ovsdb-idl.at +++ b/tests/ovsdb-idl.at @@ -21,12 +21,12 @@ m4_define([OVSDB_CHECK_IDL_C], AT_KEYWORDS([ovsdb server idl positive $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 --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [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([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3], [0], [stdout], [ignore], [kill `cat pid`]) - AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), [0], [$4], [], [kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -38,19 +38,78 @@ m4_define([OVSDB_CHECK_IDL_PY], AT_KEYWORDS([ovsdb server idl positive Python $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 --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [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 $3], [0], [stdout], [ignore], [kill `cat pid`]) - AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + [0], [$4], [], [kill `cat pid`]) + 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]) + AT_SKIP_IF([test $HAVE_PYTHON = no]) + AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5]) + AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema], + [0], [stdout], [ignore]) + AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) + TCP_PORT=`parse_listening_port < ovsdb-server.log` + + m4_if([$2], [], [], + [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore], [kill `cat pid`])]) + AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $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 tcp6 +m4_define([OVSDB_CHECK_IDL_TCP6_PY], + [AT_SETUP([$1 - Python tcp6]) + AT_SKIP_IF([test $HAVE_PYTHON = no]) + AT_SKIP_IF([test $HAVE_IPV6 = no]) + AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5]) + AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema], + [0], [stdout], [ignore]) + AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) + TCP_PORT=`parse_listening_port < ovsdb-server.log` + echo "TCP_PORT=$TCP_PORT" + + m4_if([$2], [], [], + [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore], [kill `cat pid`])]) + AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $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]) m4_define([OVSDB_CHECK_IDL], [OVSDB_CHECK_IDL_C($@) - OVSDB_CHECK_IDL_PY($@)]) + OVSDB_CHECK_IDL_PY($@) + OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY($@) + OVSDB_CHECK_IDL_TCP_PY($@) + OVSDB_CHECK_IDL_TCP6_PY($@)]) OVSDB_CHECK_IDL([simple idl, initially empty, no ops], [], @@ -221,7 +280,7 @@ OVSDB_CHECK_IDL([simple idl, handling verification failure], 000: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2> 001: commit, status=success 002: {"error":null,"result":[{"count":1}]} -003: commit, status=try again now +003: commit, status=try again 004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1> 004: i=1 r=5 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2> 005: commit, status=success @@ -235,7 +294,7 @@ OVSDB_CHECK_IDL([simple idl, increment operation], {"op": "insert", "table": "simple", "row": {}}]']], - [['set 0 r 2.0, increment simple i']], + [['set 0 r 2.0, increment 0']], [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1> 001: commit, status=success, increment=1 002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1> @@ -429,3 +488,113 @@ OVSDB_CHECK_IDL([external-linking idl, consistent ops], 002: i=1 k=1 ka=[] l2=0 uuid=<1> 003: done ]]) + +OVSDB_CHECK_IDL_PY([external-linking idl, insert ops], + [], + [['linktest']], + [[000: empty +001: commit, status=success +002: i=1 k=1 ka=[1] l2= uuid=<0> +002: i=2 k=1 ka=[1 2] l2= uuid=<1> +003: done +]]) + +OVSDB_CHECK_IDL_PY([getattr idl, insert ops], + [], + [['getattrtest']], + [[000: empty +001: commit, status=success +002: i=2 k=2 ka=[] l2= uuid=<0> +003: done +]]) + +OVSDB_CHECK_IDL_PY([row-from-json idl, whats this], + [['["idltest", + {"op": "insert", + "table": "simple", + "row": {"i": 1}}, + {"op": "insert", + "table": "simple", + "row": {}}]']], + [['notifytest insert 2, notifytest set 1 b 1, notifytest delete 0']], + [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1> +000: i=1 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2> +001: commit, status=success, events=create|2|None, delete|0|None, update|1|b +002: i=1 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2> +002: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3> +003: done +]]) + +AT_SETUP([idl handling of missing tables and columns - C]) +AT_KEYWORDS([ovsdb server idl positive]) + +# idltest2.ovsschema is the same as idltest.ovsschema, except that +# table link2 and column l2 have been deleted. But the IDL still +# expects them to be there, so this test checks that it properly +# tolerates them being missing. +AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest2.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]) +AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket ['["idltest", + {"op": "insert", + "table": "link1", + "row": {"i": 0, "k": ["named-uuid", "self"]}, + "uuid-name": "self"}]' \ + '["idltest", + {"op": "insert", + "table": "link1", + "row": {"i": 1, "k": ["named-uuid", "row2"]}, + "uuid-name": "row1"}, + {"op": "insert", + "table": "link1", + "row": {"i": 2, "k": ["named-uuid", "row1"]}, + "uuid-name": "row2"}]' \ + '["idltest", + {"op": "update", + "table": "link1", + "where": [["i", "==", 1]], + "row": {"k": ["uuid", "#1#"]}}]' \ + '["idltest", + {"op": "update", + "table": "link1", + "where": [], + "row": {"k": ["uuid", "#0#"]}}]']], + [0], [stdout], [stderr], [kill `cat pid`]) +AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl], [0], + [[000: empty +001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]} +002: i=0 k=0 ka=[] l2= uuid=<0> +003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]} +004: i=0 k=0 ka=[] l2= uuid=<0> +004: i=1 k=2 ka=[] l2= uuid=<1> +004: i=2 k=1 ka=[] l2= uuid=<2> +005: {"error":null,"result":[{"count":1}]} +006: i=0 k=0 ka=[] l2= uuid=<0> +006: i=1 k=1 ka=[] l2= uuid=<1> +006: i=2 k=1 ka=[] l2= uuid=<2> +007: {"error":null,"result":[{"count":3}]} +008: i=0 k=0 ka=[] l2= uuid=<0> +008: i=1 k=0 ka=[] l2= uuid=<1> +008: i=2 k=0 ka=[] l2= uuid=<2> +009: done +]], [], [kill `cat pid`]) + +# Check that ovsdb-idl figured out that table link2 and column l2 are missing. +AT_CHECK([grep ovsdb_idl stderr | sort], [0], [dnl +test-ovsdb|ovsdb_idl|idltest database lacks link2 table (database needs upgrade?) +test-ovsdb|ovsdb_idl|link1 table in idltest database lacks l2 column (database needs upgrade?) +]) + +# Check that ovsdb-idl sent on "monitor" request and that it didn't +# mention that table or column, and (for paranoia) that it did mention another +# table and column. +AT_CHECK([grep -c '"monitor"' stderr], [0], [1 +]) +AT_CHECK([grep '"monitor"' stderr | grep link2], [1]) +AT_CHECK([grep '"monitor"' stderr | grep l2], [1]) +AT_CHECK([grep '"monitor"' stderr | grep -c '"link1"'], [0], [1 +]) +AT_CHECK([grep '"monitor"' stderr | grep -c '"ua"'], [0], [1 +]) +OVSDB_SERVER_SHUTDOWN +AT_CLEANUP