2009-11-16 10:38:14 -08:00
|
|
|
|
AT_BANNER([OVSDB -- ovsdb-server monitors])
|
|
|
|
|
|
2017-12-31 21:15:58 -08:00
|
|
|
|
OVS_START_SHELL_HELPERS
|
|
|
|
|
# ovsdb_check_monitor SCHEMA_FUNC DB TABLE OUTPUT COLUMNS
|
|
|
|
|
# PRE-MONITOR-TXN... -- TRANSACTION...
|
|
|
|
|
ovsdb_check_monitor () {
|
|
|
|
|
local schema_func=$1 db=$2 table=$3 output=$4 columns=$5
|
|
|
|
|
shift; shift; shift; shift; shift
|
|
|
|
|
$schema_func > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
|
|
|
|
|
while test "$1" != "--"; do
|
2018-05-25 17:11:07 -07:00
|
|
|
|
AT_CHECK([ovsdb-tool transact db "$1"], [0], [ignore], [ignore])
|
|
|
|
|
shift
|
2017-12-31 21:15:58 -08:00
|
|
|
|
done
|
|
|
|
|
shift
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db > ovsdb-server.stdout 2> ovsdb-server.stderr],
|
2018-05-25 17:11:07 -07:00
|
|
|
|
[0], [], [])
|
2017-12-31 21:15:58 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
if test "$IS_WIN32" = "yes"; then
|
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --log-file -d json monitor --format=csv unix:socket $db $table $columns > output 2> ovsdb-client.stderr &],
|
2018-05-25 17:11:07 -07:00
|
|
|
|
[0], [ignore], [ignore])
|
2017-12-31 21:15:58 -08:00
|
|
|
|
sleep 1
|
|
|
|
|
else
|
2018-11-14 15:39:05 -08:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile --log-file -d json monitor --format=csv unix:socket $db $table $columns > output 2> ovsdb-client.stderr],
|
2018-05-25 17:11:07 -07:00
|
|
|
|
[0], [ignore], [ignore])
|
2017-12-31 21:15:58 -08:00
|
|
|
|
fi
|
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
|
|
|
|
for txn in ${1+"$@"} '[["'$db'"]]'; do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
2017-12-31 21:15:58 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid])
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK_UNQUOTED([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$output], [ignore])
|
2017-12-31 21:15:58 -08:00
|
|
|
|
}
|
|
|
|
|
OVS_END_SHELL_HELPERS
|
|
|
|
|
|
2010-03-15 15:41:54 -07:00
|
|
|
|
# OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
|
2010-07-01 09:47:46 -07:00
|
|
|
|
# TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS])
|
2009-11-16 10:38:14 -08:00
|
|
|
|
#
|
|
|
|
|
# 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
|
2010-07-01 09:47:46 -07:00
|
|
|
|
# time. COLUMNS, if specified, is passed to ovsdb-client as the set
|
|
|
|
|
# of columns and operations to select.
|
2009-11-16 10:38:14 -08:00
|
|
|
|
#
|
|
|
|
|
# Checks that the overall output is OUTPUT, but UUIDs in the output
|
|
|
|
|
# are replaced by markers of the form <N> where N is a number. The
|
|
|
|
|
# first unique UUID is replaced by <0>, the next by <1>, and so on.
|
|
|
|
|
# If a given UUID appears more than once it is always replaced by the
|
|
|
|
|
# same marker.
|
|
|
|
|
#
|
|
|
|
|
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
|
2017-12-31 21:15:58 -08:00
|
|
|
|
m4_define([OVSDB_CHECK_MONITOR],
|
2009-11-16 10:38:14 -08:00
|
|
|
|
[AT_SETUP([$1])
|
2010-06-30 12:44:17 -07:00
|
|
|
|
AT_KEYWORDS([ovsdb server monitor positive $9])
|
2017-12-31 21:15:58 -08:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.stdout])
|
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.stderr])
|
|
|
|
|
AT_CAPTURE_FILE([ovsdb-client.log])
|
|
|
|
|
AT_CAPTURE_FILE([ovsdb-client.stderr])
|
|
|
|
|
ovsdb_check_monitor '$2' '$4' '$5' '$7' '$8' \
|
|
|
|
|
m4_foreach([txn], [$3], ['txn' ]) -- \
|
|
|
|
|
m4_foreach([txn], [$6], ['txn' ])
|
2009-11-16 10:38:14 -08:00
|
|
|
|
AT_CLEANUP])
|
|
|
|
|
|
2016-07-18 11:45:55 +03:00
|
|
|
|
# OVSDB_CHECK_MONITOR_COND(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
|
|
|
|
|
# TRANSACTIONS, OUTPUT, CONDITIONS, [COLUMNS], [KEYWORDS],
|
|
|
|
|
# [CONDITIONS_CHANGE])
|
|
|
|
|
#
|
|
|
|
|
# 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. 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 <N> where N is a number. The
|
|
|
|
|
# first unique UUID is replaced by <0>, the next by <1>, and so on.
|
|
|
|
|
# If a given UUID appears more than once it is always replaced by the
|
|
|
|
|
# same marker.
|
|
|
|
|
#
|
|
|
|
|
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
|
|
|
|
|
m4_define([OVSDB_CHECK_MONITOR_COND],
|
|
|
|
|
[AT_SETUP([$1])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond positive $10])
|
|
|
|
|
$2 > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
|
2017-12-31 21:15:58 -08:00
|
|
|
|
for txn in m4_foreach([txn], [$3], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-tool transact db "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
tests: Get rid of overly specific --pidfile and --unixctl options.
At an early point in OVS development, OVS was built with fixed default
directories for pidfiles and sockets. This meant that it was necessary to
use lots of --pidfile and --unixctl options in the testsuite, to point the
daemons to where they should put these files (since the testsuite cannot
and generally should not touch the real system /var/run). Later on,
the environment variables OVS_RUNDIR, OVS_LOGDIR, etc. were introduced
to override these defaults, and even later the testsuite was changed to
always set these variables correctly in every test. Thus, these days it
isn't usually necessary to specify a filename on --pidfile or to specify
--unixctl at all. However, many of the tests are built by cut-and-paste,
so they tended to keep appearing anyhow. This commit drops most of them,
making the testsuite easier to read and understand.
This commit also sweeps away some other historical detritus. In
particular, in early days of the testsuite there was no way to
automatically kill daemons when a test failed (or otherwise ended). This
meant that some tests were littered with calls to "kill `cat pidfile`" on
almost every line (or m4 macros that expanded to the same thing) so that if
a test failed partway through the testsuite would not hang waiting for a
daemon to die that was never going to die without manual intervention.
However, a long time ago we introduced the "on_exit" mechanism that
obsoletes this. This commit eliminates a lot of the old litter of kill
invocations, which also makes those tests easier to read.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
2016-10-05 20:07:56 -07:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond --format=csv unix:socket $4 '[$8]' $5 $9 > output 2> ovsdb-client.stderr],
|
2018-05-25 17:11:07 -07:00
|
|
|
|
[0], [ignore], [ignore])
|
tests: Get rid of overly specific --pidfile and --unixctl options.
At an early point in OVS development, OVS was built with fixed default
directories for pidfiles and sockets. This meant that it was necessary to
use lots of --pidfile and --unixctl options in the testsuite, to point the
daemons to where they should put these files (since the testsuite cannot
and generally should not touch the real system /var/run). Later on,
the environment variables OVS_RUNDIR, OVS_LOGDIR, etc. were introduced
to override these defaults, and even later the testsuite was changed to
always set these variables correctly in every test. Thus, these days it
isn't usually necessary to specify a filename on --pidfile or to specify
--unixctl at all. However, many of the tests are built by cut-and-paste,
so they tended to keep appearing anyhow. This commit drops most of them,
making the testsuite easier to read and understand.
This commit also sweeps away some other historical detritus. In
particular, in early days of the testsuite there was no way to
automatically kill daemons when a test failed (or otherwise ended). This
meant that some tests were littered with calls to "kill `cat pidfile`" on
almost every line (or m4 macros that expanded to the same thing) so that if
a test failed partway through the testsuite would not hang waiting for a
daemon to die that was never going to die without manual intervention.
However, a long time ago we introduced the "on_exit" mechanism that
obsoletes this. This commit eliminates a lot of the old litter of kill
invocations, which also makes those tests easier to read.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
2016-10-05 20:07:56 -07:00
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
2017-12-31 21:15:58 -08:00
|
|
|
|
for txn in m4_foreach([txn], [$6], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
|
|
|
|
|
[ignore], [ignore], [kill `cat server-pid client-pid`])
|
|
|
|
|
done
|
|
|
|
|
for cond in m4_foreach([cond], [$10], ['cond' ]); do
|
|
|
|
|
AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change $5 "$cond"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
2016-07-18 11:45:55 +03:00
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
|
tests: Get rid of overly specific --pidfile and --unixctl options.
At an early point in OVS development, OVS was built with fixed default
directories for pidfiles and sockets. This meant that it was necessary to
use lots of --pidfile and --unixctl options in the testsuite, to point the
daemons to where they should put these files (since the testsuite cannot
and generally should not touch the real system /var/run). Later on,
the environment variables OVS_RUNDIR, OVS_LOGDIR, etc. were introduced
to override these defaults, and even later the testsuite was changed to
always set these variables correctly in every test. Thus, these days it
isn't usually necessary to specify a filename on --pidfile or to specify
--unixctl at all. However, many of the tests are built by cut-and-paste,
so they tended to keep appearing anyhow. This commit drops most of them,
making the testsuite easier to read and understand.
This commit also sweeps away some other historical detritus. In
particular, in early days of the testsuite there was no way to
automatically kill daemons when a test failed (or otherwise ended). This
meant that some tests were littered with calls to "kill `cat pidfile`" on
almost every line (or m4 macros that expanded to the same thing) so that if
a test failed partway through the testsuite would not hang waiting for a
daemon to die that was never going to die without manual intervention.
However, a long time ago we introduced the "on_exit" mechanism that
obsoletes this. This commit eliminates a lot of the old litter of kill
invocations, which also makes those tests easier to read.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
2016-10-05 20:07:56 -07:00
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
tests: Get rid of overly specific --pidfile and --unixctl options.
At an early point in OVS development, OVS was built with fixed default
directories for pidfiles and sockets. This meant that it was necessary to
use lots of --pidfile and --unixctl options in the testsuite, to point the
daemons to where they should put these files (since the testsuite cannot
and generally should not touch the real system /var/run). Later on,
the environment variables OVS_RUNDIR, OVS_LOGDIR, etc. were introduced
to override these defaults, and even later the testsuite was changed to
always set these variables correctly in every test. Thus, these days it
isn't usually necessary to specify a filename on --pidfile or to specify
--unixctl at all. However, many of the tests are built by cut-and-paste,
so they tended to keep appearing anyhow. This commit drops most of them,
making the testsuite easier to read and understand.
This commit also sweeps away some other historical detritus. In
particular, in early days of the testsuite there was no way to
automatically kill daemons when a test failed (or otherwise ended). This
meant that some tests were littered with calls to "kill `cat pidfile`" on
almost every line (or m4 macros that expanded to the same thing) so that if
a test failed partway through the testsuite would not hang waiting for a
daemon to die that was never going to die without manual intervention.
However, a long time ago we introduced the "on_exit" mechanism that
obsoletes this. This commit eliminates a lot of the old litter of kill
invocations, which also makes those tests easier to read.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
2016-10-05 20:07:56 -07:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$7], [ignore])
|
2016-07-18 11:45:55 +03:00
|
|
|
|
AT_CLEANUP])
|
|
|
|
|
|
2009-11-18 12:43:30 -08:00
|
|
|
|
OVSDB_CHECK_MONITOR([monitor insert into empty table],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema],
|
2009-11-16 10:38:14 -08:00
|
|
|
|
[],
|
2010-03-15 15:41:54 -07:00
|
|
|
|
[ordinals], [ordinals],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-16 10:38:14 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
|
|
|
|
|
]])
|
2009-11-18 12:43:30 -08:00
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR([monitor insert into populated table],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}}]]]],
|
2010-03-15 15:41:54 -07:00
|
|
|
|
[ordinals], [ordinals],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
|
2010-02-12 11:35:35 -08:00
|
|
|
|
|
2009-11-18 12:43:30 -08:00
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR([monitor delete],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}}]]]],
|
2010-03-15 15:41:54 -07:00
|
|
|
|
[ordinals], [ordinals],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "delete",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"where": [["number", "==", 10]]}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
|
2010-02-12 11:35:35 -08:00
|
|
|
|
|
2009-11-18 12:43:30 -08:00
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR([monitor row update],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}}]]]],
|
2010-03-15 15:41:54 -07:00
|
|
|
|
[ordinals], [ordinals],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "update",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"where": [["number", "==", 10]],
|
|
|
|
|
"row": {"name": "five plus five"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
|
2010-02-12 11:35:35 -08:00
|
|
|
|
|
2009-11-18 12:43:30 -08:00
|
|
|
|
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],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}}]]]],
|
2010-03-15 15:41:54 -07:00
|
|
|
|
[ordinals], [ordinals],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "update",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"where": [["number", "==", 10]],
|
|
|
|
|
"row": {"number": 10, "name": "ten"}}]]],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 9, "name": "nine"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
|
2010-02-12 11:35:35 -08:00
|
|
|
|
|
2009-11-18 12:43:30 -08:00
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}}]]]],
|
2010-03-15 15:41:54 -07:00
|
|
|
|
[ordinals], [ordinals],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 9, "name": "nine"},
|
|
|
|
|
"uuid-name": "nine"},
|
|
|
|
|
{"op": "update",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"where": [["_uuid", "==", ["named-uuid", "nine"]]],
|
|
|
|
|
"row": {"name": "three squared"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
|
2010-02-12 11:35:35 -08:00
|
|
|
|
|
2009-11-18 12:43:30 -08:00
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}}]]]],
|
2010-03-15 15:41:54 -07:00
|
|
|
|
[ordinals], [ordinals],
|
2010-02-09 10:17:58 -08:00
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
2009-11-18 12:43:30 -08:00
|
|
|
|
"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>""]"
|
2010-02-12 11:35:35 -08:00
|
|
|
|
|
2009-11-18 12:43:30 -08:00
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
|
|
|
|
|
]])
|
|
|
|
|
|
2010-03-15 15:41:54 -07:00
|
|
|
|
OVSDB_CHECK_MONITOR([monitor weak reference change],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[weak_schema],
|
2010-03-15 15:41:54 -07:00
|
|
|
|
[[[["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]]}]]]],
|
2010-05-07 10:44:01 -07:00
|
|
|
|
[[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>""]"
|
2010-03-15 15:41:54 -07:00
|
|
|
|
|
2010-05-07 10:44:01 -07:00
|
|
|
|
row,action,a,a2a,a2a1,a2b,_version
|
|
|
|
|
<0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
|
2014-04-01 14:33:24 -07:00
|
|
|
|
<3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
|
2010-05-07 10:44:01 -07:00
|
|
|
|
,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
|
2010-03-15 15:41:54 -07:00
|
|
|
|
]])
|
|
|
|
|
|
2010-06-30 12:44:17 -07:00
|
|
|
|
OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema],
|
2010-06-30 12:44:17 -07:00
|
|
|
|
[[[["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>""]"
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
|
|
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],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
|
2010-06-30 12:44:17 -07:00
|
|
|
|
[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],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
|
2010-06-30 12:44:17 -07:00
|
|
|
|
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
|
2010-07-01 09:47:46 -07:00
|
|
|
|
]], [!insert,!delete,!modify])
|
2010-06-30 12:44:17 -07:00
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR([monitor insert only],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
|
2010-06-30 12:44:17 -07:00
|
|
|
|
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,insert,"""five""",5,"[""uuid"",""<1>""]"
|
2010-07-01 09:47:46 -07:00
|
|
|
|
]], [!initial,!delete,!modify])
|
2010-06-30 12:44:17 -07:00
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR([monitor delete only],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
|
2010-06-30 12:44:17 -07:00
|
|
|
|
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
|
|
|
|
|
<2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
|
2010-07-01 09:47:46 -07:00
|
|
|
|
]], [!initial,!insert,!modify])
|
2010-06-30 12:44:17 -07:00
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR([monitor modify only],
|
2012-03-07 14:17:45 -08:00
|
|
|
|
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
|
2010-06-30 12:44:17 -07:00
|
|
|
|
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,old,"""five""",,"[""uuid"",""<1>""]"
|
|
|
|
|
,new,"""FIVE""",5,"[""uuid"",""<2>""]"
|
2010-07-01 09:47:46 -07:00
|
|
|
|
]], [!initial,!insert,!delete])
|
2016-07-18 11:45:55 +03:00
|
|
|
|
|
|
|
|
|
AT_BANNER([ovsdb -- ovsdb-monitor-cond conditional monitor only some operations])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR_COND([monitor-cond empty condition],
|
|
|
|
|
[ordinal_schema],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]],
|
|
|
|
|
[ordinals], [ordinals],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 11, "name": "eleven"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
|
|
|
|
|
<2>,initial,"""two""",2,"[""uuid"",""<3>""]"
|
|
|
|
|
<4>,initial,"""zero""",,"[""uuid"",""<5>""]"
|
|
|
|
|
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<6>,insert,"""eleven""",11,"[""uuid"",""<7>""]"
|
|
|
|
|
<8>,insert,"""ten""",10,"[""uuid"",""<9>""]"
|
|
|
|
|
]],
|
|
|
|
|
[[]])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR_COND([monitor-cond multiple conditions],
|
|
|
|
|
[ordinal_schema],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]],
|
|
|
|
|
[ordinals], [ordinals],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 11, "name": "eleven"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
|
|
|
|
|
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<2>,insert,"""ten""",10,"[""uuid"",""<3>""]"
|
|
|
|
|
]],
|
|
|
|
|
[[["name","==","one"],["name","==","ten"]]])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR_COND([monitor-cond delete from populated table],
|
|
|
|
|
[ordinal_schema],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]],
|
|
|
|
|
[ordinals], [ordinals],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "delete",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"where": []}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
|
|
|
|
|
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<0>,delete,,,
|
|
|
|
|
]],
|
|
|
|
|
[[["name","==","one"],["name","==","ten"]]])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR_COND([monitor-cond insert due to modify],
|
|
|
|
|
[ordinal_schema],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]],
|
|
|
|
|
[ordinals], [ordinals],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "update",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"where": [["name", "==", "one"]],
|
|
|
|
|
"row": {"name": "ONE"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,insert,"""ONE""",1,"[""uuid"",""<1>""]"
|
|
|
|
|
]],
|
|
|
|
|
[[["name","==","ONE"]]],
|
|
|
|
|
[!initial,!delete,!modify])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR_COND([monitor-cond delete due to modify],
|
|
|
|
|
[ordinal_schema],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]],
|
|
|
|
|
[ordinals], [ordinals],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "update",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"where": [["name", "==", "one"]],
|
|
|
|
|
"row": {"name": "ONE"}}]]]],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,delete,,,
|
|
|
|
|
]],
|
|
|
|
|
[[["name","==","one"]]],
|
|
|
|
|
[!initial,!insert,!modify])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR_COND([monitor-cond condition non-monitored columns],
|
|
|
|
|
[ordinal_schema],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]],
|
|
|
|
|
[ordinals], [ordinals],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 11, "name": "eleven"}}]]]],
|
|
|
|
|
[[row,action,number
|
|
|
|
|
<0>,initial,1
|
|
|
|
|
|
|
|
|
|
row,action,number
|
|
|
|
|
<1>,insert,10
|
|
|
|
|
]],
|
|
|
|
|
[[["name","==","one"],["name","==","ten"]]],
|
|
|
|
|
["number"])
|
|
|
|
|
|
|
|
|
|
OVSDB_CHECK_MONITOR_COND([monitor-cond-change],
|
|
|
|
|
[ordinal_schema],
|
|
|
|
|
[[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]],
|
|
|
|
|
[ordinals], [ordinals],
|
|
|
|
|
[],
|
|
|
|
|
[[row,action,name,number,_version
|
|
|
|
|
<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
|
|
|
|
|
<2>,initial,"""two""",2,"[""uuid"",""<3>""]"
|
|
|
|
|
<4>,initial,"""zero""",,"[""uuid"",""<5>""]"
|
|
|
|
|
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<4>,delete,,,
|
|
|
|
|
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<2>,delete,,,
|
|
|
|
|
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<0>,delete,,,
|
|
|
|
|
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<0>,insert,"""one""",1,"[""uuid"",""<1>""]"
|
|
|
|
|
<2>,insert,"""two""",2,"[""uuid"",""<3>""]"
|
|
|
|
|
<4>,insert,"""zero""",,"[""uuid"",""<5>""]"
|
|
|
|
|
]],
|
|
|
|
|
[[]],
|
|
|
|
|
[],
|
|
|
|
|
[[[[["name","==","one"],["name","==","two"]]]],
|
2023-09-22 15:18:23 +02:00
|
|
|
|
[[[["name","==","two"],["name","==","one"]]]],
|
2016-07-18 11:45:55 +03:00
|
|
|
|
[[[["name","==","one"]]]],
|
|
|
|
|
[[[false]]],
|
|
|
|
|
[[[true]]]])
|
monitor: Fix crash when monitor condition adds new columns.
The OVSDB conditional monitor implementation allows many clients
to share same copy of monitored data if the clients are sharing
same tables and columns being monitored, while they can have
different monitor conditions. In monitor conditions they can
have different columns which can be different from the columns
being monitored. So the struct ovsdb_monitor_table maintains the
union of the all the columns being used in any conditions.
The problem of the current implementation is that for each change
set generated, it doesn't maintain any metadata for the number of
columns for the data that has already populated in it. Instead, it
always rely on the n_columns field of the struct ovsdb_monitor_table
to manipulate the data. However, the n_columns in struct
ovsdb_monitor_table can increase (e.g. when a client changes its
condition which involves more columns). So it can result in that
the existing rows in a change set with N columns being later processed
as if it had more than N columns, typically, when the row is freed.
This causes the ovsdb-server crashing (see an example of the
backtrace).
The patch fixes the problem by maintaining n_columns for each
change set, and added a test case which fails without the fix.
(gdb) bt
at lib/ovsdb-data.c:1031
out>, mt=<optimized out>) at ovsdb/monitor.c:320
mt=0x1e7b940) at ovsdb/monitor.c:333
out>, transaction=<optimized out>) at ovsdb/monitor.c:527
initial=<optimized out>, cond_updated=cond_updated@entry=false,
unflushed_=unflushed_@entry=0x20dae70,
condition=<optimized out>, version=<optimized out>) at ovsdb/monitor.c:1156
(m=m@entry=0x20dae40, initial=initial@entry=false) at
ovsdb/jsonrpc-server.c:1655
at ovsdb/jsonrpc-server.c:1729
ovsdb/jsonrpc-server.c:551
ovsdb/jsonrpc-server.c:586
ovsdb/jsonrpc-server.c:401
exiting=0x7ffdb947f76f, run_process=0x0, remotes=0x7ffdb947f7c0,
unixctl=0x1e7a560, all_dbs=0x7ffdb947f800,
jsonrpc=<optimized out>, config=0x7ffdb947f820) at ovsdb/ovsdb-server.c:209
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-02-11 18:19:21 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AT_SETUP(monitor-cond-change with many sessions pending)
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond negative])
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
monitor: Fix crash when monitor condition adds new columns.
The OVSDB conditional monitor implementation allows many clients
to share same copy of monitored data if the clients are sharing
same tables and columns being monitored, while they can have
different monitor conditions. In monitor conditions they can
have different columns which can be different from the columns
being monitored. So the struct ovsdb_monitor_table maintains the
union of the all the columns being used in any conditions.
The problem of the current implementation is that for each change
set generated, it doesn't maintain any metadata for the number of
columns for the data that has already populated in it. Instead, it
always rely on the n_columns field of the struct ovsdb_monitor_table
to manipulate the data. However, the n_columns in struct
ovsdb_monitor_table can increase (e.g. when a client changes its
condition which involves more columns). So it can result in that
the existing rows in a change set with N columns being later processed
as if it had more than N columns, typically, when the row is freed.
This causes the ovsdb-server crashing (see an example of the
backtrace).
The patch fixes the problem by maintaining n_columns for each
change set, and added a test case which fails without the fix.
(gdb) bt
at lib/ovsdb-data.c:1031
out>, mt=<optimized out>) at ovsdb/monitor.c:320
mt=0x1e7b940) at ovsdb/monitor.c:333
out>, transaction=<optimized out>) at ovsdb/monitor.c:527
initial=<optimized out>, cond_updated=cond_updated@entry=false,
unflushed_=unflushed_@entry=0x20dae70,
condition=<optimized out>, version=<optimized out>) at ovsdb/monitor.c:1156
(m=m@entry=0x20dae40, initial=initial@entry=false) at
ovsdb/jsonrpc-server.c:1655
at ovsdb/jsonrpc-server.c:1729
ovsdb/jsonrpc-server.c:551
ovsdb/jsonrpc-server.c:586
ovsdb/jsonrpc-server.c:401
exiting=0x7ffdb947f76f, run_process=0x0, remotes=0x7ffdb947f7c0,
unixctl=0x1e7a560, all_dbs=0x7ffdb947f800,
jsonrpc=<optimized out>, config=0x7ffdb947f820) at ovsdb/ovsdb-server.c:209
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-02-11 18:19:21 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# 1001 clients monitoring column "name" and with condition for "name" only.
|
|
|
|
|
# The clients are created in a way that the 991th client will request condition
|
|
|
|
|
# change, so that the chance is high that the condition change will be handled
|
|
|
|
|
# before some pending changes are freed.
|
|
|
|
|
|
|
|
|
|
cond='[[["name","==","ten"]]]'
|
|
|
|
|
for i in `seq 1 990`; do
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile=ovsdb-client$i.pid --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"] >ovsdb-client$i.out 2>&1], [0], [ignore], [ignore])
|
monitor: Fix crash when monitor condition adds new columns.
The OVSDB conditional monitor implementation allows many clients
to share same copy of monitored data if the clients are sharing
same tables and columns being monitored, while they can have
different monitor conditions. In monitor conditions they can
have different columns which can be different from the columns
being monitored. So the struct ovsdb_monitor_table maintains the
union of the all the columns being used in any conditions.
The problem of the current implementation is that for each change
set generated, it doesn't maintain any metadata for the number of
columns for the data that has already populated in it. Instead, it
always rely on the n_columns field of the struct ovsdb_monitor_table
to manipulate the data. However, the n_columns in struct
ovsdb_monitor_table can increase (e.g. when a client changes its
condition which involves more columns). So it can result in that
the existing rows in a change set with N columns being later processed
as if it had more than N columns, typically, when the row is freed.
This causes the ovsdb-server crashing (see an example of the
backtrace).
The patch fixes the problem by maintaining n_columns for each
change set, and added a test case which fails without the fix.
(gdb) bt
at lib/ovsdb-data.c:1031
out>, mt=<optimized out>) at ovsdb/monitor.c:320
mt=0x1e7b940) at ovsdb/monitor.c:333
out>, transaction=<optimized out>) at ovsdb/monitor.c:527
initial=<optimized out>, cond_updated=cond_updated@entry=false,
unflushed_=unflushed_@entry=0x20dae70,
condition=<optimized out>, version=<optimized out>) at ovsdb/monitor.c:1156
(m=m@entry=0x20dae40, initial=initial@entry=false) at
ovsdb/jsonrpc-server.c:1655
at ovsdb/jsonrpc-server.c:1729
ovsdb/jsonrpc-server.c:551
ovsdb/jsonrpc-server.c:586
ovsdb/jsonrpc-server.c:401
exiting=0x7ffdb947f76f, run_process=0x0, remotes=0x7ffdb947f7c0,
unixctl=0x1e7a560, all_dbs=0x7ffdb947f800,
jsonrpc=<optimized out>, config=0x7ffdb947f820) at ovsdb/ovsdb-server.c:209
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-02-11 18:19:21 -08:00
|
|
|
|
done
|
|
|
|
|
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"] > output 2> ovsdb-client.stderr],
|
monitor: Fix crash when monitor condition adds new columns.
The OVSDB conditional monitor implementation allows many clients
to share same copy of monitored data if the clients are sharing
same tables and columns being monitored, while they can have
different monitor conditions. In monitor conditions they can
have different columns which can be different from the columns
being monitored. So the struct ovsdb_monitor_table maintains the
union of the all the columns being used in any conditions.
The problem of the current implementation is that for each change
set generated, it doesn't maintain any metadata for the number of
columns for the data that has already populated in it. Instead, it
always rely on the n_columns field of the struct ovsdb_monitor_table
to manipulate the data. However, the n_columns in struct
ovsdb_monitor_table can increase (e.g. when a client changes its
condition which involves more columns). So it can result in that
the existing rows in a change set with N columns being later processed
as if it had more than N columns, typically, when the row is freed.
This causes the ovsdb-server crashing (see an example of the
backtrace).
The patch fixes the problem by maintaining n_columns for each
change set, and added a test case which fails without the fix.
(gdb) bt
at lib/ovsdb-data.c:1031
out>, mt=<optimized out>) at ovsdb/monitor.c:320
mt=0x1e7b940) at ovsdb/monitor.c:333
out>, transaction=<optimized out>) at ovsdb/monitor.c:527
initial=<optimized out>, cond_updated=cond_updated@entry=false,
unflushed_=unflushed_@entry=0x20dae70,
condition=<optimized out>, version=<optimized out>) at ovsdb/monitor.c:1156
(m=m@entry=0x20dae40, initial=initial@entry=false) at
ovsdb/jsonrpc-server.c:1655
at ovsdb/jsonrpc-server.c:1729
ovsdb/jsonrpc-server.c:551
ovsdb/jsonrpc-server.c:586
ovsdb/jsonrpc-server.c:401
exiting=0x7ffdb947f76f, run_process=0x0, remotes=0x7ffdb947f7c0,
unixctl=0x1e7a560, all_dbs=0x7ffdb947f800,
jsonrpc=<optimized out>, config=0x7ffdb947f820) at ovsdb/ovsdb-server.c:209
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-02-11 18:19:21 -08:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
|
|
|
|
|
for i in `seq 991 1000`; do
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile=ovsdb-client$i.pid --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"] >ovsdb-client$i.out 2>&1 ], [0], [ignore], [ignore])
|
monitor: Fix crash when monitor condition adds new columns.
The OVSDB conditional monitor implementation allows many clients
to share same copy of monitored data if the clients are sharing
same tables and columns being monitored, while they can have
different monitor conditions. In monitor conditions they can
have different columns which can be different from the columns
being monitored. So the struct ovsdb_monitor_table maintains the
union of the all the columns being used in any conditions.
The problem of the current implementation is that for each change
set generated, it doesn't maintain any metadata for the number of
columns for the data that has already populated in it. Instead, it
always rely on the n_columns field of the struct ovsdb_monitor_table
to manipulate the data. However, the n_columns in struct
ovsdb_monitor_table can increase (e.g. when a client changes its
condition which involves more columns). So it can result in that
the existing rows in a change set with N columns being later processed
as if it had more than N columns, typically, when the row is freed.
This causes the ovsdb-server crashing (see an example of the
backtrace).
The patch fixes the problem by maintaining n_columns for each
change set, and added a test case which fails without the fix.
(gdb) bt
at lib/ovsdb-data.c:1031
out>, mt=<optimized out>) at ovsdb/monitor.c:320
mt=0x1e7b940) at ovsdb/monitor.c:333
out>, transaction=<optimized out>) at ovsdb/monitor.c:527
initial=<optimized out>, cond_updated=cond_updated@entry=false,
unflushed_=unflushed_@entry=0x20dae70,
condition=<optimized out>, version=<optimized out>) at ovsdb/monitor.c:1156
(m=m@entry=0x20dae40, initial=initial@entry=false) at
ovsdb/jsonrpc-server.c:1655
at ovsdb/jsonrpc-server.c:1729
ovsdb/jsonrpc-server.c:551
ovsdb/jsonrpc-server.c:586
ovsdb/jsonrpc-server.c:401
exiting=0x7ffdb947f76f, run_process=0x0, remotes=0x7ffdb947f7c0,
unixctl=0x1e7a560, all_dbs=0x7ffdb947f800,
jsonrpc=<optimized out>, config=0x7ffdb947f820) at ovsdb/ovsdb-server.c:209
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-02-11 18:19:21 -08:00
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
|
|
|
|
|
[ignore], [ignore], [kill `cat server-pid client-pid`])
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Change the condition so that a new column "number" is added to monitor table.
|
|
|
|
|
cond='[[["number","==",1]]]'
|
|
|
|
|
AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change ordinals $cond], [0], [ignore], [ignore])
|
|
|
|
|
|
|
|
|
|
# Give some time for the server to flush and free pending changes
|
|
|
|
|
# (to crash, when n_columns is not handled properly)
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
|
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN("/Too many open files/d")
|
monitor: Fix crash when monitor condition adds new columns.
The OVSDB conditional monitor implementation allows many clients
to share same copy of monitored data if the clients are sharing
same tables and columns being monitored, while they can have
different monitor conditions. In monitor conditions they can
have different columns which can be different from the columns
being monitored. So the struct ovsdb_monitor_table maintains the
union of the all the columns being used in any conditions.
The problem of the current implementation is that for each change
set generated, it doesn't maintain any metadata for the number of
columns for the data that has already populated in it. Instead, it
always rely on the n_columns field of the struct ovsdb_monitor_table
to manipulate the data. However, the n_columns in struct
ovsdb_monitor_table can increase (e.g. when a client changes its
condition which involves more columns). So it can result in that
the existing rows in a change set with N columns being later processed
as if it had more than N columns, typically, when the row is freed.
This causes the ovsdb-server crashing (see an example of the
backtrace).
The patch fixes the problem by maintaining n_columns for each
change set, and added a test case which fails without the fix.
(gdb) bt
at lib/ovsdb-data.c:1031
out>, mt=<optimized out>) at ovsdb/monitor.c:320
mt=0x1e7b940) at ovsdb/monitor.c:333
out>, transaction=<optimized out>) at ovsdb/monitor.c:527
initial=<optimized out>, cond_updated=cond_updated@entry=false,
unflushed_=unflushed_@entry=0x20dae70,
condition=<optimized out>, version=<optimized out>) at ovsdb/monitor.c:1156
(m=m@entry=0x20dae40, initial=initial@entry=false) at
ovsdb/jsonrpc-server.c:1655
at ovsdb/jsonrpc-server.c:1729
ovsdb/jsonrpc-server.c:551
ovsdb/jsonrpc-server.c:586
ovsdb/jsonrpc-server.c:401
exiting=0x7ffdb947f76f, run_process=0x0, remotes=0x7ffdb947f7c0,
unixctl=0x1e7a560, all_dbs=0x7ffdb947f800,
jsonrpc=<optimized out>, config=0x7ffdb947f820) at ovsdb/ovsdb-server.c:209
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-02-11 18:19:21 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [[row,action,name
|
monitor: Fix crash when monitor condition adds new columns.
The OVSDB conditional monitor implementation allows many clients
to share same copy of monitored data if the clients are sharing
same tables and columns being monitored, while they can have
different monitor conditions. In monitor conditions they can
have different columns which can be different from the columns
being monitored. So the struct ovsdb_monitor_table maintains the
union of the all the columns being used in any conditions.
The problem of the current implementation is that for each change
set generated, it doesn't maintain any metadata for the number of
columns for the data that has already populated in it. Instead, it
always rely on the n_columns field of the struct ovsdb_monitor_table
to manipulate the data. However, the n_columns in struct
ovsdb_monitor_table can increase (e.g. when a client changes its
condition which involves more columns). So it can result in that
the existing rows in a change set with N columns being later processed
as if it had more than N columns, typically, when the row is freed.
This causes the ovsdb-server crashing (see an example of the
backtrace).
The patch fixes the problem by maintaining n_columns for each
change set, and added a test case which fails without the fix.
(gdb) bt
at lib/ovsdb-data.c:1031
out>, mt=<optimized out>) at ovsdb/monitor.c:320
mt=0x1e7b940) at ovsdb/monitor.c:333
out>, transaction=<optimized out>) at ovsdb/monitor.c:527
initial=<optimized out>, cond_updated=cond_updated@entry=false,
unflushed_=unflushed_@entry=0x20dae70,
condition=<optimized out>, version=<optimized out>) at ovsdb/monitor.c:1156
(m=m@entry=0x20dae40, initial=initial@entry=false) at
ovsdb/jsonrpc-server.c:1655
at ovsdb/jsonrpc-server.c:1729
ovsdb/jsonrpc-server.c:551
ovsdb/jsonrpc-server.c:586
ovsdb/jsonrpc-server.c:401
exiting=0x7ffdb947f76f, run_process=0x0, remotes=0x7ffdb947f7c0,
unixctl=0x1e7a560, all_dbs=0x7ffdb947f800,
jsonrpc=<optimized out>, config=0x7ffdb947f820) at ovsdb/ovsdb-server.c:209
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-02-11 18:19:21 -08:00
|
|
|
|
<0>,insert,"""ten"""
|
|
|
|
|
|
|
|
|
|
row,action,name
|
|
|
|
|
<0>,delete,
|
|
|
|
|
<1>,insert,"""one"""
|
|
|
|
|
]], [ignore])
|
|
|
|
|
AT_CLEANUP
|
2019-02-28 09:15:18 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test monitor-cond-since with zero uuid, which shouldn't
|
|
|
|
|
# be found in server and server should send all rows
|
|
|
|
|
# as initial.
|
|
|
|
|
AT_SETUP([monitor-cond-since not found])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Omitting the last_id parameter in ovsdb-client monitor-cond-since command
|
|
|
|
|
# will by default using all zero uuid, which doesn't exist in any history txn.
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output 2> ovsdb-client.stderr],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 11, "name": "eleven"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
|
|
|
|
|
[ignore], [ignore], [kill `cat server-pid client-pid`])
|
|
|
|
|
done
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
|
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
2019-02-28 09:15:18 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[[found: false, last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<1>,initial,"""one""",1,"[""uuid"",""<2>""]"
|
|
|
|
|
|
|
|
|
|
last_id: <3>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<4>,insert,"""ten""",10,"[""uuid"",""<5>""]"
|
|
|
|
|
]], [ignore])
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test monitor-cond-since in ovsdb server restart scenario.
|
|
|
|
|
# ovsdb-client should receive only new changes after the
|
|
|
|
|
# specific transaction id.
|
|
|
|
|
AT_SETUP([monitor-cond-since db restart])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
|
|
|
|
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output 2> ovsdb-client.stderr],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
|
|
|
|
OVS_WAIT_UNTIL([grep last_id output])
|
|
|
|
|
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
2019-02-28 09:15:18 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
|
|
|
|
|
|
|
|
|
# Remember the last_id, which will be used for monitor-cond-since later.
|
|
|
|
|
last_id=`grep last_id output | awk '{print $4}'`
|
|
|
|
|
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
|
|
|
|
|
# Some new changes made to db after restarting the server.
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 11, "name": "eleven"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
|
|
|
|
|
[ignore], [ignore], [kill `cat server-pid client-pid`])
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Use last_id to monitor and get only the new changes.
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals $last_id '[[["name","==","one"],["name","==","ten"]]]' ordinals > output 2> ovsdb-client.stderr],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
|
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
2019-02-28 09:15:18 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[[found: true, last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<1>,insert,"""ten""",10,"[""uuid"",""<2>""]"
|
|
|
|
|
]], [ignore])
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test monitor-cond-since with last_id found in server
|
|
|
|
|
# but there is no new change after that transaction.
|
|
|
|
|
AT_SETUP([monitor-cond-since found but no new rows])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output 2> ovsdb-client.stderr],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
|
|
|
|
OVS_WAIT_UNTIL([grep last_id output])
|
|
|
|
|
|
|
|
|
|
kill `cat ovsdb-client.pid`
|
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid])
|
|
|
|
|
last_id=`grep last_id output | awk '{print $4}'`
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals $last_id '[[["name","==","one"],["name","==","ten"]]]' ordinals > output 2> ovsdb-client.stderr],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
|
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
2019-02-28 09:15:18 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[[found: true, last_id: <0>
|
|
|
|
|
]], [ignore])
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test monitor-cond-since against empty DB
|
|
|
|
|
AT_SETUP([monitor-cond-since empty db])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output 2> ovsdb-client.stderr],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
|
|
|
|
OVS_WAIT_UNTIL([grep last_id output])
|
|
|
|
|
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
|
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
2019-02-28 09:15:18 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[[found: false, last_id: <0>
|
|
|
|
|
]], [ignore])
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test monitor-cond-since with cond-change followed.
|
|
|
|
|
AT_SETUP([monitor-cond-since condition change])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file -vjsonrpc:file:dbg db], [0], [ignore], [ignore])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-client.log])
|
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --log-file --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[]]' ordinals > output 2> ovsdb-client.stderr])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
|
|
|
|
for cond in m4_foreach([cond],
|
|
|
|
|
[[[[["name","==","one"],["name","==","two"]]]],
|
|
|
|
|
[[[["name","==","one"]]]],
|
|
|
|
|
[[[false]]],
|
|
|
|
|
[[[true]]]], ['cond' ]); do
|
|
|
|
|
AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change ordinals "$cond"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
|
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
2019-02-28 09:15:18 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[[found: false, last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<1>,initial,"""one""",1,"[""uuid"",""<2>""]"
|
|
|
|
|
<3>,initial,"""two""",2,"[""uuid"",""<4>""]"
|
|
|
|
|
<5>,initial,"""zero""",,"[""uuid"",""<6>""]"
|
|
|
|
|
|
|
|
|
|
last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<5>,delete,,,
|
|
|
|
|
|
|
|
|
|
last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<3>,delete,,,
|
|
|
|
|
|
|
|
|
|
last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<1>,delete,,,
|
|
|
|
|
|
|
|
|
|
last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<1>,insert,"""one""",1,"[""uuid"",""<2>""]"
|
|
|
|
|
<3>,insert,"""two""",2,"[""uuid"",""<4>""]"
|
|
|
|
|
<5>,insert,"""zero""",,"[""uuid"",""<6>""]"
|
|
|
|
|
]], [ignore])
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test monitor-cond-since with non-cluster mode server
|
|
|
|
|
AT_SETUP([monitor-cond-since non-cluster])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
2019-02-28 09:15:18 -08:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
|
|
|
|
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output 2> ovsdb-client.stderr],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
ovsdb monitor: Fix crash when using non-zero last-id with standalone DB.
When a client uses monitor-cond-since with a non-zero last-id but the
server is not in cluster mode for the DB being monitored, it leads to
segmentation fault because the txn_history list is not initialized in
this case.
Program terminated with signal SIGSEGV, Segmentation fault.
1536 struct ovsdb_txn *txn = h_node->txn;
(gdb) bt
0 ovsdb_monitor_get_changes_after (txn_uuid=txn_uuid@entry=0x7ffe8605b7e0, dbmon=0x17c1b40, p_mcs=p_mcs@entry=0x17c4900) at ovsdb/monitor.c:1536
1 0x000000000040da2d in ovsdb_jsonrpc_monitor_create (request_id=0x1804630, version=<optimized out>, params=0x17ad330, db=0x18015b0, s=<optimized out>) at ovsdb/jsonrpc-server.c:1469
2 ovsdb_jsonrpc_session_got_request (request=0x17ad520, s=<optimized out>) at ovsdb/jsonrpc-server.c:1002
3 ovsdb_jsonrpc_session_run (s=<optimized out>) at ovsdb/jsonrpc-server.c:556
...
Although it doesn't happen in normal use cases, no one can prevent a
client to send this on purpose or in a corner case when a client firstly
connected to a clustered DB but later the server restarted with a
non-clustered DB.
This patch fixes it by always initialize the txn_history list to avoid
the undefined behavior in this case. It adds a test case to cover it, too.
Fixes: 695e815 ("ovsdb-server: Transaction history tracking.")
Reported-by: Aliasgar Ginwala <aginwala@ebay.com>
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-08-19 16:30:35 -07:00
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 11, "name": "eleven"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
|
|
|
|
|
[ignore], [ignore], [kill `cat server-pid client-pid`])
|
|
|
|
|
done
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
|
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
ovsdb monitor: Fix crash when using non-zero last-id with standalone DB.
When a client uses monitor-cond-since with a non-zero last-id but the
server is not in cluster mode for the DB being monitored, it leads to
segmentation fault because the txn_history list is not initialized in
this case.
Program terminated with signal SIGSEGV, Segmentation fault.
1536 struct ovsdb_txn *txn = h_node->txn;
(gdb) bt
0 ovsdb_monitor_get_changes_after (txn_uuid=txn_uuid@entry=0x7ffe8605b7e0, dbmon=0x17c1b40, p_mcs=p_mcs@entry=0x17c4900) at ovsdb/monitor.c:1536
1 0x000000000040da2d in ovsdb_jsonrpc_monitor_create (request_id=0x1804630, version=<optimized out>, params=0x17ad330, db=0x18015b0, s=<optimized out>) at ovsdb/jsonrpc-server.c:1469
2 ovsdb_jsonrpc_session_got_request (request=0x17ad520, s=<optimized out>) at ovsdb/jsonrpc-server.c:1002
3 ovsdb_jsonrpc_session_run (s=<optimized out>) at ovsdb/jsonrpc-server.c:556
...
Although it doesn't happen in normal use cases, no one can prevent a
client to send this on purpose or in a corner case when a client firstly
connected to a clustered DB but later the server restarted with a
non-clustered DB.
This patch fixes it by always initialize the txn_history list to avoid
the undefined behavior in this case. It adds a test case to cover it, too.
Fixes: 695e815 ("ovsdb-server: Transaction history tracking.")
Reported-by: Aliasgar Ginwala <aginwala@ebay.com>
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-08-19 16:30:35 -07:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
|
|
|
|
|
|
|
|
|
# Transaction shouldn't be found, and last_id returned should always
|
|
|
|
|
# be the same (all zero uuid)
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
|
ovsdb monitor: Fix crash when using non-zero last-id with standalone DB.
When a client uses monitor-cond-since with a non-zero last-id but the
server is not in cluster mode for the DB being monitored, it leads to
segmentation fault because the txn_history list is not initialized in
this case.
Program terminated with signal SIGSEGV, Segmentation fault.
1536 struct ovsdb_txn *txn = h_node->txn;
(gdb) bt
0 ovsdb_monitor_get_changes_after (txn_uuid=txn_uuid@entry=0x7ffe8605b7e0, dbmon=0x17c1b40, p_mcs=p_mcs@entry=0x17c4900) at ovsdb/monitor.c:1536
1 0x000000000040da2d in ovsdb_jsonrpc_monitor_create (request_id=0x1804630, version=<optimized out>, params=0x17ad330, db=0x18015b0, s=<optimized out>) at ovsdb/jsonrpc-server.c:1469
2 ovsdb_jsonrpc_session_got_request (request=0x17ad520, s=<optimized out>) at ovsdb/jsonrpc-server.c:1002
3 ovsdb_jsonrpc_session_run (s=<optimized out>) at ovsdb/jsonrpc-server.c:556
...
Although it doesn't happen in normal use cases, no one can prevent a
client to send this on purpose or in a corner case when a client firstly
connected to a clustered DB but later the server restarted with a
non-clustered DB.
This patch fixes it by always initialize the txn_history list to avoid
the undefined behavior in this case. It adds a test case to cover it, too.
Fixes: 695e815 ("ovsdb-server: Transaction history tracking.")
Reported-by: Aliasgar Ginwala <aginwala@ebay.com>
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-08-19 16:30:35 -07:00
|
|
|
|
[[found: false, last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<1>,initial,"""one""",1,"[""uuid"",""<2>""]"
|
|
|
|
|
|
|
|
|
|
last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<3>,insert,"""ten""",10,"[""uuid"",""<4>""]"
|
|
|
|
|
]], [ignore])
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test monitor-cond-since with non-cluster mode server with non-zero last_id
|
|
|
|
|
AT_SETUP([monitor-cond-since non-cluster non-zero last_id])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond-since negative])
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
ovsdb monitor: Fix crash when using non-zero last-id with standalone DB.
When a client uses monitor-cond-since with a non-zero last-id but the
server is not in cluster mode for the DB being monitored, it leads to
segmentation fault because the txn_history list is not initialized in
this case.
Program terminated with signal SIGSEGV, Segmentation fault.
1536 struct ovsdb_txn *txn = h_node->txn;
(gdb) bt
0 ovsdb_monitor_get_changes_after (txn_uuid=txn_uuid@entry=0x7ffe8605b7e0, dbmon=0x17c1b40, p_mcs=p_mcs@entry=0x17c4900) at ovsdb/monitor.c:1536
1 0x000000000040da2d in ovsdb_jsonrpc_monitor_create (request_id=0x1804630, version=<optimized out>, params=0x17ad330, db=0x18015b0, s=<optimized out>) at ovsdb/jsonrpc-server.c:1469
2 ovsdb_jsonrpc_session_got_request (request=0x17ad520, s=<optimized out>) at ovsdb/jsonrpc-server.c:1002
3 ovsdb_jsonrpc_session_run (s=<optimized out>) at ovsdb/jsonrpc-server.c:556
...
Although it doesn't happen in normal use cases, no one can prevent a
client to send this on purpose or in a corner case when a client firstly
connected to a clustered DB but later the server restarted with a
non-clustered DB.
This patch fixes it by always initialize the txn_history list to avoid
the undefined behavior in this case. It adds a test case to cover it, too.
Fixes: 695e815 ("ovsdb-server: Transaction history tracking.")
Reported-by: Aliasgar Ginwala <aginwala@ebay.com>
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-08-19 16:30:35 -07:00
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# A non-zero uuid
|
|
|
|
|
last_id=11111111-1111-1111-1111-111111111111
|
2023-05-17 18:51:05 +02:00
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals $last_id '[[["name","==","one"],["name","==","ten"]]]' ordinals > output 2> ovsdb-client.stderr],
|
ovsdb monitor: Fix crash when using non-zero last-id with standalone DB.
When a client uses monitor-cond-since with a non-zero last-id but the
server is not in cluster mode for the DB being monitored, it leads to
segmentation fault because the txn_history list is not initialized in
this case.
Program terminated with signal SIGSEGV, Segmentation fault.
1536 struct ovsdb_txn *txn = h_node->txn;
(gdb) bt
0 ovsdb_monitor_get_changes_after (txn_uuid=txn_uuid@entry=0x7ffe8605b7e0, dbmon=0x17c1b40, p_mcs=p_mcs@entry=0x17c4900) at ovsdb/monitor.c:1536
1 0x000000000040da2d in ovsdb_jsonrpc_monitor_create (request_id=0x1804630, version=<optimized out>, params=0x17ad330, db=0x18015b0, s=<optimized out>) at ovsdb/jsonrpc-server.c:1469
2 ovsdb_jsonrpc_session_got_request (request=0x17ad520, s=<optimized out>) at ovsdb/jsonrpc-server.c:1002
3 ovsdb_jsonrpc_session_run (s=<optimized out>) at ovsdb/jsonrpc-server.c:556
...
Although it doesn't happen in normal use cases, no one can prevent a
client to send this on purpose or in a corner case when a client firstly
connected to a clustered DB but later the server restarted with a
non-clustered DB.
This patch fixes it by always initialize the txn_history list to avoid
the undefined behavior in this case. It adds a test case to cover it, too.
Fixes: 695e815 ("ovsdb-server: Transaction history tracking.")
Reported-by: Aliasgar Ginwala <aginwala@ebay.com>
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-08-19 16:30:35 -07:00
|
|
|
|
[0], [ignore], [ignore])
|
|
|
|
|
on_exit 'kill `cat ovsdb-client.pid`'
|
2019-02-28 09:15:18 -08:00
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 10, "name": "ten"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 11, "name": "eleven"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
|
|
|
|
|
[ignore], [ignore], [kill `cat server-pid client-pid`])
|
|
|
|
|
done
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
|
|
|
|
|
[ignore], [ignore])
|
2023-05-17 18:51:05 +02:00
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
2019-02-28 09:15:18 -08:00
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
|
|
|
|
|
|
|
|
|
|
# Transaction shouldn't be found, and last_id returned should always
|
|
|
|
|
# be the same (all zero uuid)
|
2019-09-20 08:30:42 -07:00
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
|
2019-02-28 09:15:18 -08:00
|
|
|
|
[[found: false, last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<1>,initial,"""one""",1,"[""uuid"",""<2>""]"
|
|
|
|
|
|
|
|
|
|
last_id: <0>
|
|
|
|
|
row,action,name,number,_version
|
|
|
|
|
<3>,insert,"""ten""",10,"[""uuid"",""<4>""]"
|
|
|
|
|
]], [ignore])
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
2023-06-07 15:08:32 +02:00
|
|
|
|
AT_SETUP([monitor-cond initial reply with condition on non-monitored column])
|
|
|
|
|
AT_KEYWORDS([ovsdb server monitor monitor-cond positive initial non-monitored])
|
|
|
|
|
|
|
|
|
|
ordinal_schema > schema
|
|
|
|
|
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
|
|
|
|
|
on_exit 'kill `cat ovsdb-server.pid`'
|
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
|
|
|
|
|
--remote=punix:socket --log-file db], [0], [ignore], [ignore])
|
|
|
|
|
|
|
|
|
|
dnl Initialize the database content.
|
|
|
|
|
for txn in m4_foreach([txn], [[[["ordinals",
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 0, "name": "zero"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 1, "name": "one"}},
|
|
|
|
|
{"op": "insert",
|
|
|
|
|
"table": "ordinals",
|
|
|
|
|
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
|
|
|
|
|
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
dnl Start a first client that monitors only the column 'name'.
|
|
|
|
|
on_exit 'kill `cat client-1.pid`'
|
|
|
|
|
AT_CAPTURE_FILE([client-1.out])
|
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile=client-1.pid --detach --no-chdir \
|
|
|
|
|
-d json monitor-cond --format=csv unix:socket \
|
|
|
|
|
ordinals '[[true]]' ordinals ["name"] \
|
|
|
|
|
> client-1.out 2> client-1.err], [0], [ignore], [ignore])
|
|
|
|
|
dnl Wait for the initial monitor reply.
|
|
|
|
|
OVS_WAIT_UNTIL([grep -q 'initial' client-1.out])
|
|
|
|
|
|
|
|
|
|
dnl Start a second client that monitors the column 'name', but has a condition
|
|
|
|
|
dnl on column 'number'.
|
|
|
|
|
on_exit 'kill `cat client-2.pid`'
|
|
|
|
|
AT_CAPTURE_FILE([client-2.out])
|
|
|
|
|
AT_CHECK([ovsdb-client -vjsonrpc --pidfile=client-2.pid --detach --no-chdir \
|
|
|
|
|
-d json monitor-cond --format=csv unix:socket \
|
|
|
|
|
ordinals '[[["number", "!=", 1]]]' ordinals ["name"] \
|
|
|
|
|
> client-2.out 2> client-2.err], [0], [ignore], [ignore])
|
|
|
|
|
dnl Wait for the initial monitor reply.
|
|
|
|
|
OVS_WAIT_UNTIL([grep -q 'initial' client-2.out])
|
|
|
|
|
|
|
|
|
|
OVSDB_SERVER_SHUTDOWN
|
|
|
|
|
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && \
|
|
|
|
|
test ! -e client-1.pid && test ! -e client-2.pid])
|
|
|
|
|
|
|
|
|
|
dnl The first client should have all the names.
|
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < client-1.out | uuidfilt],
|
|
|
|
|
[0], [dnl
|
|
|
|
|
row,action,name
|
|
|
|
|
<0>,initial,"""one"""
|
|
|
|
|
<1>,initial,"""two"""
|
|
|
|
|
<2>,initial,"""zero"""
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
dnl The second client should not have the name 'one'.
|
|
|
|
|
AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < client-2.out | uuidfilt],
|
|
|
|
|
[0], [dnl
|
|
|
|
|
row,action,name
|
|
|
|
|
<0>,initial,"""two"""
|
|
|
|
|
<1>,initial,"""zero"""
|
|
|
|
|
])
|
|
|
|
|
AT_CLEANUP
|