summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNuman Siddique <nusiddiq@redhat.com>2018-08-07 17:08:11 +0530
committerBen Pfaff <blp@ovn.org>2018-08-14 11:49:28 -0700
commit31e434fc985c682708f5d92bde2ceae452bdaa4f (patch)
treec27c9a59219edbdd81a893090825ef5c292061d3 /tests
parentc1aa16d191d267d76ce1d1459fe9ed6ab93e1f54 (diff)
downloadopenvswitch-31e434fc985c682708f5d92bde2ceae452bdaa4f.tar.gz
python jsonrpc: Allow jsonrpc_session to have more than one remote.
Python IDL implementation doesn't have the support to connect to the cluster dbs. This patch adds this support. We are still missing the support in python idl class to connect to the cluster master. That support will be added in an upcoming patch. This patch is similar to the commit 8cf6bbb184 which added multiple remote support in the C jsonrpc implementation. Acked-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/ovsdb-idl.at54
-rw-r--r--tests/test-ovsdb.py13
2 files changed, 64 insertions, 3 deletions
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index 8c5e9fe50..e9b4161f0 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -106,6 +106,32 @@ m4_define([OVSDB_CHECK_IDL_TCP_PY],
OVSDB_CHECK_IDL_TCP_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
[$HAVE_PYTHON3], [$PYTHON3])])
+# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
+# with multiple remotes with only one remote reachable
+m4_define([OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PYN],
+ [AT_SETUP([$1 - tcp])
+ AT_SKIP_IF([test $7 = no])
+ AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
+ AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
+ PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
+ WRONG_PORT_1=$((TCP_PORT + 1))
+ WRONG_PORT_2=$((TCP_PORT + 2))
+ remote=tcp:127.0.0.1:$WRONG_PORT_1,tcp:127.0.0.1:$TCP_PORT,tcp:127.0.0.1:$WRONG_PORT_2
+ m4_if([$2], [], [],
+ [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
+ AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema $remote $3],
+ [0], [stdout], [ignore])
+ AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+ [0], [$4])
+ OVSDB_SERVER_SHUTDOWN
+ AT_CLEANUP])
+
+m4_define([OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY],
+ [OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PYN([$1 - Python2 (multiple remotes)], [$2], [$3], [$4], [$5], [$6],
+ [$HAVE_PYTHON], [$PYTHON])
+ OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PYN([$1 - Python3 (multiple remotes)], [$2], [$3], [$4], [$5], [$6],
+ [$HAVE_PYTHON3], [$PYTHON3])])
+
# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6
m4_define([OVSDB_CHECK_IDL_TCP6_PYN],
[AT_SETUP([$1 - tcp6])
@@ -132,6 +158,32 @@ m4_define([OVSDB_CHECK_IDL_TCP6_PY],
OVSDB_CHECK_IDL_TCP6_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
[$HAVE_PYTHON3], [$PYTHON3])])
+m4_define([OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PYN],
+ [AT_SETUP([$1 - tcp6])
+ AT_SKIP_IF([test $7 = no])
+ AT_SKIP_IF([test "$IS_WIN32" = "yes"])
+ AT_SKIP_IF([test $HAVE_IPV6 = no])
+ AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
+ AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
+ PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
+ WRONG_PORT_1=$((TCP_PORT + 1))
+ WRONG_PORT_2=$((TCP_PORT + 2))
+ remote="tcp:[[::1]]:$WRONG_PORT_1,tcp:[[::1]]:$TCP_PORT,tcp:[[::1]]:$WRONG_PORT_2"
+ m4_if([$2], [], [],
+ [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
+ AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema $remote $3],
+ [0], [stdout], [ignore])
+ AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
+ [0], [$4])
+ OVSDB_SERVER_SHUTDOWN
+ AT_CLEANUP])
+
+m4_define([OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY],
+ [OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PYN([$1 - Python2 (multiple remotes)], [$2], [$3], [$4], [$5], [$6],
+ [$HAVE_PYTHON], [$PYTHON])
+ OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PYN([$1 - Python3 (multiple remotes)], [$2], [$3], [$4], [$5], [$6],
+ [$HAVE_PYTHON3], [$PYTHON3])])
+
# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with SSL
m4_define([OVSDB_CHECK_IDL_SSL_PYN],
[AT_SETUP([$1 - SSL])
@@ -178,7 +230,9 @@ m4_define([OVSDB_CHECK_IDL],
OVSDB_CHECK_IDL_PY($@)
OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY($@)
OVSDB_CHECK_IDL_TCP_PY($@)
+ OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY($@)
OVSDB_CHECK_IDL_TCP6_PY($@)
+ OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY($@)
OVSDB_CHECK_IDL_SSL_PY($@)])
# This test uses the Python IDL implementation with passive tcp
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index ec6035447..ed5d21b0c 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -595,9 +595,16 @@ def do_idl(schema_file, remote, *commands):
idl.index_create("simple3", "simple3_by_name")
if commands:
- error, stream = ovs.stream.Stream.open_block(
- ovs.stream.Stream.open(remote))
- if error:
+ remotes = remote.split(',')
+ stream = None
+ for r in remotes:
+ error, stream = ovs.stream.Stream.open_block(
+ ovs.stream.Stream.open(r))
+ if not error and stream:
+ break
+ stream = None
+
+ if not stream:
sys.stderr.write("failed to connect to \"%s\"" % remote)
sys.exit(1)
rpc = ovs.jsonrpc.Connection(stream)