From patchwork Fri Sep 27 16:42:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1168709 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46g2Sq0VD3z9sN1 for ; Sat, 28 Sep 2019 05:50:03 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AB13FCC1; Fri, 27 Sep 2019 19:50:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 20586BBC for ; Fri, 27 Sep 2019 19:50:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 047F68D9 for ; Fri, 27 Sep 2019 19:49:58 +0000 (UTC) Received: from sigfpe.attlocal.net (75-54-222-30.lightspeed.rdcyca.sbcglobal.net [75.54.222.30]) (Authenticated sender: blp@ovn.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 63777100004; Fri, 27 Sep 2019 19:49:56 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 27 Sep 2019 09:42:38 -0700 Message-Id: <20190927164239.17468-1-blp@ovn.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 1/2] ovsdb-cluster: Use ovs-vsctl instead of ovn-nbctl and ovn-sbctl. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This removes a dependency on OVN from the tests. This adds some options to ovs-vsctl to allow it to be used for testing the clustering feature. The new options are undocumented because they're really just useful for testing clustering. Signed-off-by: Ben Pfaff Acked-by: Han Zhou --- tests/ovsdb-cluster.at | 37 ++++++++++++++++++------------------- utilities/ovs-vsctl.c | 27 ++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/tests/ovsdb-cluster.at b/tests/ovsdb-cluster.at index de4295a7e60c..24601c887ff0 100644 --- a/tests/ovsdb-cluster.at +++ b/tests/ovsdb-cluster.at @@ -249,10 +249,10 @@ ovsdb_cluster_failure_test () { new_leader=$5 fi - cp $top_srcdir/ovn/ovn-nb.ovsschema schema + cp $top_srcdir/vswitchd/vswitch.ovsschema schema schema=`ovsdb-tool schema-name schema` AT_CHECK([ovsdb-tool '-vPATTERN:console:%c|%p|%m' create-cluster s1.db schema unix:s1.raft], [0], [], [dnl -ovsdb|WARN|schema: changed 2 columns in 'OVN_Northbound' database from ephemeral to persistent, including 'status' column in 'Connection' table, because clusters do not support ephemeral columns +ovsdb|WARN|schema: changed 30 columns in 'Open_vSwitch' database from ephemeral to persistent, including 'status' column in 'Manager' table, because clusters do not support ephemeral columns ]) n=3 @@ -283,7 +283,7 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Northbound' database from ephemeral for i in `seq $n`; do start_server $i; done for i in `seq $n`; do connect_server $i; done - export OVN_NB_DB=unix:s$remote_1.ovsdb,unix:s$remote_2.ovsdb + db=unix:s$remote_1.ovsdb,unix:s$remote_2.ovsdb # To ensure $new_leader node the new leader, we delay election timer for # the other follower. @@ -296,15 +296,15 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Northbound' database from ephemeral AT_CHECK([ovs-appctl -t "`pwd`"/s$delay_election_node cluster/failure-test delay-election], [0], [ignore]) fi AT_CHECK([ovs-appctl -t "`pwd`"/s$crash_node cluster/failure-test $crash_command], [0], [ignore]) - AT_CHECK([ovn-nbctl -v --timeout=10 --no-leader-only --no-shuffle-remotes create logical_switch name=ls1], [0], [ignore], [ignore]) + AT_CHECK([ovs-vsctl -v --timeout=10 --db="$db" --no-leader-only --no-shuffle-remotes --no-wait create QoS type=x], [0], [ignore], [ignore]) # Make sure that the node really crashed. AT_CHECK([ls s$crash_node.ovsdb], [2], [ignore], [ignore]) # XXX: Client will fail if remotes contains unix socket that doesn't exist (killed). - if test "$remote_1" == "$crash_node"; then - export OVN_NB_DB=unix:s$remote_2.ovsdb + if test "$remote_1" = "$crash_node"; then + db=unix:s$remote_2.ovsdb fi - AT_CHECK([ovn-nbctl --no-leader-only ls-list | awk '{ print $2 }'], [0], [(ls1) + AT_CHECK([ovs-vsctl --db="$db" --no-leader-only --no-wait --columns=type --bare list QoS], [0], [x ]) } OVS_END_SHELL_HELPERS @@ -407,10 +407,10 @@ ovsdb_torture_test () { local n=$1 # Number of cluster members local victim=$2 # Cluster member to kill or remove local variant=$3 # 'kill' and restart or 'remove' and add - cp $top_srcdir/ovn/ovn-sb.ovsschema schema + cp $top_srcdir/vswitchd/vswitch.ovsschema schema schema=`ovsdb-tool schema-name schema` AT_CHECK([ovsdb-tool '-vPATTERN:console:%c|%p|%m' create-cluster s1.db schema unix:s1.raft], [0], [], [dnl -ovsdb|WARN|schema: changed 2 columns in 'OVN_Southbound' database from ephemeral to persistent, including 'status' column in 'Connection' table, because clusters do not support ephemeral columns +ovsdb|WARN|schema: changed 30 columns in 'Open_vSwitch' database from ephemeral to persistent, including 'status' column in 'Manager' table, because clusters do not support ephemeral columns ]) join_cluster() { @@ -442,7 +442,7 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Southbound' database from ephemeral remove_server() { local i=$1 printf "\ns$i: removing from cluster\n" - AT_CHECK([ovs-appctl --timeout=30 -t "`pwd`"/s$i cluster/leave OVN_Southbound]) + AT_CHECK([ovs-appctl --timeout=30 -t "`pwd`"/s$i cluster/leave Open_vSwitch]) printf "\ns$i: waiting for removal to complete\n" AT_CHECK([ovsdb_client_wait --log-file=remove$i.log unix:s$i.ovsdb $schema removed]) stop_server $i @@ -462,22 +462,21 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Southbound' database from ephemeral for i in `seq $n`; do start_server $i; done for i in `seq $n`; do connect_server $i; done - OVN_SB_DB=unix:s1.ovsdb + db=unix:s1.ovsdb for i in `seq 2 $n`; do - OVN_SB_DB=$OVN_SB_DB,unix:s$i.ovsdb + db=$db,unix:s$i.ovsdb done - export OVN_SB_DB n1=10 n2=5 n3=50 - echo "starting $n1*$n2 ovn-sbctl processes..." + echo "starting $n1*$n2 ovs-vsctl processes..." for i in $(seq 0 $(expr $n1 - 1) ); do (for j in $(seq $n2); do : > $i-$j.running - txn="add SB_Global . external_ids $i-$j=$i-$j" + txn="add Open_vSwitch . external_ids $i-$j=$i-$j" for k in $(seq $n3); do - txn="$txn -- add SB_Global . external_ids $i-$j-$k=$i-$j-$k" + txn="$txn -- add Open_vSwitch . external_ids $i-$j-$k=$i-$j-$k" done - run_as "ovn-sbctl($i-$j)" ovn-sbctl "-vPATTERN:console:ovn-sbctl($i-$j)|%D{%H:%M:%S}|%05N|%c|%p|%m" --log-file=$i-$j.log -vfile -vsyslog:off -vtimeval:off --timeout=120 --no-leader-only $txn + run_as "ovs-vsctl($i-$j)" ovs-vsctl "-vPATTERN:console:ovs-vsctl($i-$j)|%D{%H:%M:%S}|%05N|%c|%p|%m" --log-file=$i-$j.log -vfile -vsyslog:off -vtimeval:off --timeout=120 --db="$db" --no-leader-only --no-wait $txn status=$? if test $status != 0; then echo "$i-$j exited with status $status" > $i-$j:$status @@ -488,7 +487,7 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Southbound' database from ephemeral done echo "...done" - echo "waiting for ovn-sbctl processes to exit..." + echo "waiting for ovs-vsctl processes to exit..." # Use file instead of var because code inside "while" runs in a subshell. echo 0 > phase i=0 @@ -544,7 +543,7 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Southbound' database from ephemeral done done done | sort > expout - AT_CHECK([ovn-sbctl --timeout=30 --log-file=finalize.log -vtimeval:off -vfile -vsyslog:off --bare get SB_Global . external-ids | tr ',' '\n' | sed 's/[[{}"" ]]//g' | sort], [0], [expout]) + AT_CHECK([ovs-vsctl --timeout=30 --db="$db" --no-wait --log-file=finalize.log -vtimeval:off -vfile -vsyslog:off --bare get Open_vSwitch . external-ids | tr ',' '\n' | sed 's/[[{}"" ]]//g' | sort], [0], [expout]) for i in `seq $n`; do if test $i != $victim || test $(cat phase) != 1; then diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 43f64d4711f9..7232471e68b9 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -83,6 +83,21 @@ static unsigned int timeout; * wait. */ static bool retry; +/* --leader-only, --no-leader-only: Only accept the leader in a cluster. + * + * In a real Open vSwitch environment, it doesn't make much sense to cluster + * the Open vSwitch database. This option exists to enable using ovs-vsctl to + * test OVSDB's clustering feature. */ +static int leader_only = true; + +/* --shuffle-remotes, --no-shuffle-remotes: Shuffle the order of remotes that + * are specified in the connetion method string. + * + * In a real Open vSwitch environment, it doesn't make much sense to cluster + * the Open vSwitch database. This option exists to enable using ovs-vsctl to + * test OVSDB's clustering feature. */ +static int shuffle_remotes = true; + /* Format for table output. */ static struct table_style table_style = TABLE_STYLE_DEFAULT; @@ -161,7 +176,10 @@ main(int argc, char *argv[]) ctl_timeout_setup(timeout); /* Initialize IDL. */ - idl = the_idl = ovsdb_idl_create(db, &ovsrec_idl_class, false, retry); + idl = the_idl = ovsdb_idl_create_unconnected(&ovsrec_idl_class, false); + ovsdb_idl_set_shuffle_remotes(idl, shuffle_remotes); + ovsdb_idl_set_remote(idl, db, retry); + ovsdb_idl_set_leader_only(idl, leader_only); run_prerequisites(commands, n_commands, idl); /* Execute the commands. @@ -225,6 +243,10 @@ parse_options(int argc, char *argv[], struct shash *local_options) {"help", no_argument, NULL, 'h'}, {"commands", no_argument, NULL, OPT_COMMANDS}, {"options", no_argument, NULL, OPT_OPTIONS}, + {"leader-only", no_argument, &leader_only, true}, + {"no-leader-only", no_argument, &leader_only, false}, + {"shuffle-remotes", no_argument, &shuffle_remotes, true}, + {"no-shuffle-remotes", no_argument, &shuffle_remotes, false}, {"version", no_argument, NULL, 'V'}, VLOG_LONG_OPTIONS, TABLE_LONG_OPTIONS, @@ -336,6 +358,9 @@ parse_options(int argc, char *argv[], struct shash *local_options) case '?': exit(EXIT_FAILURE); + case 0: + break; + default: abort(); }