X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Fovsdb-monitor.at;h=d24ae9179b53a59317ed28e8b88caf264fc468ed;hb=c5cf10598f8c9f4428291e9df3ecd72a05fb1ccf;hp=f0b20e155f9756a99f965d195e93d6d4e447436f;hpb=b12e3c41afaeb9faed1e3562954ec78fd595677d;p=sliver-openvswitch.git diff --git a/tests/ovsdb-monitor.at b/tests/ovsdb-monitor.at index f0b20e155..d24ae9179 100644 --- a/tests/ovsdb-monitor.at +++ b/tests/ovsdb-monitor.at @@ -1,12 +1,13 @@ AT_BANNER([OVSDB -- ovsdb-server monitors]) -# OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], MONITOR-ARGS, -# TRANSACTIONS, OUTPUT, [KEYWORDS]) +# OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE, +# TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS]) # # Creates a database with the given SCHEMA, starts an ovsdb-server on # that database, and runs each of the TRANSACTIONS (which should be a # quoted list of quoted strings) against it with ovsdb-client one at a -# time. +# time. COLUMNS, if specified, is passed to ovsdb-client as the set +# of columns and operations to select. # # Checks that the overall output is OUTPUT, but UUIDs in the output # are replaced by markers of the form where N is a number. The @@ -17,30 +18,33 @@ AT_BANNER([OVSDB -- ovsdb-server monitors]) # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. m4_define([OVSDB_CHECK_MONITOR], [AT_SETUP([$1]) - AT_KEYWORDS([ovsdb server monitor positive $7]) - AT_DATA([schema], [$2 -]) - OVS_CHECK_LCOV([ovsdb-tool create db schema], [0], [stdout], [ignore]) + AT_KEYWORDS([ovsdb server monitor positive $9]) + OVS_RUNDIR=`pwd`; export OVS_RUNDIR + $2 > schema + AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) m4_foreach([txn], [$3], - [OVS_CHECK_LCOV([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])]) - AT_CHECK([ovsdb-server --detach --pidfile=$PWD/server-pid --listen=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore]) - AT_CHECK([ovsdb-client --detach --pidfile=$PWD/client-pid monitor --format=csv unix:socket $4 > output], + [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])]) + AT_CAPTURE_FILE([ovsdb-server-log]) + AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/server-pid --remote=punix:socket --unixctl="`pwd`"/unixctl --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1], + [0], [], []) + AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output], [0], [ignore], [ignore], [kill `cat server-pid`]) - m4_foreach([txn], [$5], - [OVS_CHECK_LCOV([ovsdb-client transact unix:socket 'txn'], [0], + m4_foreach([txn], [$6], + [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [ignore], [ignore], [kill `cat server-pid client-pid`])]) - OVS_CHECK_LCOV([ovsdb-client transact unix:socket '[[]]'], [0], - [ignore], [ignore], [kill `cat server-pid client-pid`]) - AT_CHECK([ovs-appctl -t $PWD/unixctl -e exit], [0], [ignore], [ignore]) - OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid && exit 0]) - AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$6], [ignore]) + AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0], + [ignore], [ignore], [kill `cat server-pid client-pid`]) + AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore]) + OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid]) + AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore]) AT_CLEANUP]) OVSDB_CHECK_MONITOR([monitor insert into empty table], - [ORDINAL_SCHEMA], + [ordinal_schema], [], - [ordinals], - [[[[{"op": "insert", + [ordinals], [ordinals], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}]]]], [[row,action,name,number,_version @@ -48,78 +52,93 @@ OVSDB_CHECK_MONITOR([monitor insert into empty table], ]]) OVSDB_CHECK_MONITOR([monitor insert into populated table], - [ORDINAL_SCHEMA], - [[[[{"op": "insert", + [ordinal_schema], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 10, "name": "ten"}}]]]], - [ordinals], - [[[[{"op": "insert", + [ordinals], [ordinals], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}]]]], [[row,action,name,number,_version <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" + row,action,name,number,_version <2>,insert,"""zero""",0,"[""uuid"",""<3>""]" ]]) OVSDB_CHECK_MONITOR([monitor delete], - [ORDINAL_SCHEMA], - [[[[{"op": "insert", + [ordinal_schema], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 10, "name": "ten"}}]]]], - [ordinals], - [[[[{"op": "delete", + [ordinals], [ordinals], + [[[["ordinals", + {"op": "delete", "table": "ordinals", "where": [["number", "==", 10]]}]]]], [[row,action,name,number,_version <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" + row,action,name,number,_version <0>,delete,"""ten""",10,"[""uuid"",""<1>""]" ]]) OVSDB_CHECK_MONITOR([monitor row update], - [ORDINAL_SCHEMA], - [[[[{"op": "insert", + [ordinal_schema], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 10, "name": "ten"}}]]]], - [ordinals], - [[[[{"op": "update", + [ordinals], [ordinals], + [[[["ordinals", + {"op": "update", "table": "ordinals", "where": [["number", "==", 10]], "row": {"name": "five plus five"}}]]]], [[row,action,name,number,_version <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" + row,action,name,number,_version <0>,old,"""ten""",,"[""uuid"",""<1>""]" ,new,"""five plus five""",10,"[""uuid"",""<2>""]" ]]) OVSDB_CHECK_MONITOR([monitor no-op row updates], - [ORDINAL_SCHEMA], - [[[[{"op": "insert", + [ordinal_schema], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 10, "name": "ten"}}]]]], - [ordinals], - [[[[{"op": "update", + [ordinals], [ordinals], + [[[["ordinals", + {"op": "update", "table": "ordinals", "where": [["number", "==", 10]], "row": {"number": 10, "name": "ten"}}]]], - [[[{"op": "insert", + [[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 9, "name": "nine"}}]]]], [[row,action,name,number,_version <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" + row,action,name,number,_version <2>,insert,"""nine""",9,"[""uuid"",""<3>""]" ]]) OVSDB_CHECK_MONITOR([monitor insert-and-update transaction], - [ORDINAL_SCHEMA], - [[[[{"op": "insert", + [ordinal_schema], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 10, "name": "ten"}}]]]], - [ordinals], - [[[[{"op": "insert", + [ordinals], [ordinals], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 9, "name": "nine"}, "uuid-name": "nine"}, @@ -129,18 +148,84 @@ OVSDB_CHECK_MONITOR([monitor insert-and-update transaction], "row": {"name": "three squared"}}]]]], [[row,action,name,number,_version <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" + row,action,name,number,_version <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]" ]]) +OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction], + [ordinal_schema], + [[[["ordinals", + {"op": "insert", + "table": "ordinals", + "row": {"number": 10, "name": "ten"}}]]]], + [ordinals], [ordinals], + [[[["ordinals", + {"op": "insert", + "table": "ordinals", + "row": {"number": 9, "name": "nine"}, + "uuid-name": "nine"}, + {"op": "update", + "table": "ordinals", + "where": [["_uuid", "==", ["named-uuid", "nine"]]], + "row": {"name": "three squared"}}, + {"op": "delete", + "table": "ordinals", + "where": [["_uuid", "==", ["named-uuid", "nine"]]]}, + {"op": "insert", + "table": "ordinals", + "row": {"number": 7, "name": "seven"}}]]]], + [[row,action,name,number,_version +<0>,initial,"""ten""",10,"[""uuid"",""<1>""]" + +row,action,name,number,_version +<2>,insert,"""seven""",7,"[""uuid"",""<3>""]" +]]) + +OVSDB_CHECK_MONITOR([monitor weak reference change], + [weak_schema], + [[[["weak", + {"op": "insert", + "table": "a", + "row": {"a": 0, + "a2a1": ["named-uuid", "a0"], + "a2b": ["named-uuid", "b2"]}, + "uuid-name": "a0"}, + {"op": "insert", + "table": "a", + "row": {"a": 1, + "a2a": ["named-uuid", "a0"], + "a2a1": ["named-uuid", "a1"], + "a2b": ["named-uuid", "b2"]}, + "uuid-name": "a1"}, + {"op": "insert", + "table": "b", + "row": {"b": 2}, + "uuid-name": "b2"}]]]], + [weak], [a], + [[[["weak", + {"op": "delete", + "table": "a", + "where": [["a", "==", 0]]}]]]], + [[row,action,a,a2a,a2a1,a2b,_version +<0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]" +<3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]" + +row,action,a,a2a,a2a1,a2b,_version +<0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]" +<3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]" +,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]" +]]) OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction], - [ORDINAL_SCHEMA], - [[[[{"op": "insert", + [ordinal_schema], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 10, "name": "ten"}}]]]], - [ordinals], - [[[[{"op": "insert", + [ordinals], [ordinals], + [[[["ordinals", + {"op": "insert", "table": "ordinals", "row": {"number": 9, "name": "nine"}, "uuid-name": "nine"}, @@ -156,7 +241,79 @@ OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction], "row": {"number": 7, "name": "seven"}}]]]], [[row,action,name,number,_version <0>,initial,"""ten""",10,"[""uuid"",""<1>""]" + row,action,name,number,_version <2>,insert,"""seven""",7,"[""uuid"",""<3>""]" ]]) + +AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations]) + +m4_define([OVSDB_MONITOR_INITIAL], + [[[["ordinals", + {"op": "insert", + "table": "ordinals", + "row": {"number": 10, "name": "ten"}}]]]]) +m4_define([OVSDB_MONITOR_TXNS], + [[[["ordinals", + {"op": "insert", + "table": "ordinals", + "row": {"number": 5, "name": "five"}}]]], + [[["ordinals", + {"op": "update", + "table": "ordinals", + "where": [["name", "==", "five"]], + "row": {"name": "FIVE"}}]]], + [[["ordinals", + {"op": "delete", + "table": "ordinals", + "where": []}]]]]) +OVSDB_CHECK_MONITOR([monitor all operations], + [ordinal_schema], [OVSDB_MONITOR_INITIAL], + [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], + [[row,action,name,number,_version +<0>,initial,"""ten""",10,"[""uuid"",""<1>""]" + +row,action,name,number,_version +<2>,insert,"""five""",5,"[""uuid"",""<3>""]" + +row,action,name,number,_version +<2>,old,"""five""",,"[""uuid"",""<3>""]" +,new,"""FIVE""",5,"[""uuid"",""<4>""]" + +row,action,name,number,_version +<2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]" +<0>,delete,"""ten""",10,"[""uuid"",""<1>""]" +]]) + +dnl A monitor with "initial" only doesn't really make sense, +dnl but it's still allowed and should work. +OVSDB_CHECK_MONITOR([monitor initial only], + [ordinal_schema], [OVSDB_MONITOR_INITIAL], + [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], + [[row,action,name,number,_version +<0>,initial,"""ten""",10,"[""uuid"",""<1>""]" +]], [!insert,!delete,!modify]) + +OVSDB_CHECK_MONITOR([monitor insert only], + [ordinal_schema], [OVSDB_MONITOR_INITIAL], + [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], + [[row,action,name,number,_version +<0>,insert,"""five""",5,"[""uuid"",""<1>""]" +]], [!initial,!delete,!modify]) + +OVSDB_CHECK_MONITOR([monitor delete only], + [ordinal_schema], [OVSDB_MONITOR_INITIAL], + [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], + [[row,action,name,number,_version +<0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]" +<2>,delete,"""ten""",10,"[""uuid"",""<3>""]" +]], [!initial,!insert,!modify]) + +OVSDB_CHECK_MONITOR([monitor modify only], + [ordinal_schema], [OVSDB_MONITOR_INITIAL], + [ordinals], [ordinals], [OVSDB_MONITOR_TXNS], + [[row,action,name,number,_version +<0>,old,"""five""",,"[""uuid"",""<1>""]" +,new,"""FIVE""",5,"[""uuid"",""<2>""]" +]], [!initial,!insert,!delete])