From patchwork Wed Oct 7 20:57:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 527413 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 4D1FD14010F for ; Thu, 8 Oct 2015 07:57:34 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 523DF109A4; Wed, 7 Oct 2015 13:57:29 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id CEBA61099F for ; Wed, 7 Oct 2015 13:57:27 -0700 (PDT) Received: from bar4.cudamail.com (bar2 [192.168.15.2]) by mx3v1.cudamail.com (Postfix) with ESMTP id 5AB57618D57 for ; Wed, 7 Oct 2015 14:57:27 -0600 (MDT) X-ASG-Debug-ID: 1444251446-03dc2149b43bad0001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar4.cudamail.com with ESMTP id HS6EBfj7GFJqb1pv (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 07 Oct 2015 14:57:26 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO mail-pa0-f49.google.com) (209.85.220.49) by mx3-pf2.cudamail.com with ESMTPS (RC4-SHA encrypted); 7 Oct 2015 20:57:24 -0000 Received-SPF: unknown (mx3-pf2.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.49 Received: by pacex6 with SMTP id ex6so31573102pac.0 for ; Wed, 07 Oct 2015 13:57:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9v+BsdjW7peECFTsnAB5bgl3Kij+dA8XBrnqNkCd8zM=; b=cSdJFedqVC7au6BOP6ud+MbR7CI36fH/IhwOmqEvUbcqzrkvmFgz+7UvmedyX/ZK58 aKnzF5cltp18y3lTnOqu0AtQrAqvRZcWZ+xsX+uYrv/PQ36bOdiVD5XulI/5f4VZsYd2 Okn/TYsWab9WcxbktGjpvS3ORh+YaGkD9KlQBy1rJq7unquihTli6ZXKaEKXwhnPeHSP ngC1L+XC5A3myJ0aiaKCa2v0v9wtqNhk+a+1eey5I1EkJYuk2nf8S/EVTgj3GJGP0xLb LRbT7SKvot8RjcMKaSjYtwCJdNmGN8ReggOpb7N0qMqTEo+859vzYvoGPwtqfy6pIExn 7g3g== X-Gm-Message-State: ALoCoQkSS1rCEJduuwACqpPOwuzYstCxDi0PBFy1ZIXW9idVnYwvcbHVmu3IYkCa6kcGmzmhxfqT X-Received: by 10.66.161.7 with SMTP id xo7mr3287138pab.57.1444251445835; Wed, 07 Oct 2015 13:57:25 -0700 (PDT) Received: from sigabrt.benpfaff.org ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id yh3sm11385375pbb.82.2015.10.07.13.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Oct 2015 13:57:24 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V2-1006061177 X-CudaMail-DTE: 100715 X-CudaMail-Originating-IP: 209.85.220.49 Date: Wed, 7 Oct 2015 13:57:16 -0700 X-ASG-Orig-Subj: [##CM-V2-1006061177##][PATCH 3/3] ovn-controller: Add test for setting up and tearing down patch ports. Message-Id: <1444251436-26967-3-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1444251436-26967-1-git-send-email-blp@nicira.com> References: <1444251436-26967-1-git-send-email-blp@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1444251446 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 3/3] ovn-controller: Add test for setting up and tearing down patch ports. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" The initial plan for OVN logical routers will make more extensive use of patch ports, so it seems like a good idea to add some tests to avoid regressions before messing with them. Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- tests/automake.mk | 1 + tests/ovn-controller.at | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 1 + 3 files changed, 77 insertions(+) create mode 100644 tests/ovn-controller.at diff --git a/tests/automake.mk b/tests/automake.mk index d183a1d..95edda3 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -89,6 +89,7 @@ TESTSUITE_AT = \ tests/ovn.at \ tests/ovn-nbctl.at \ tests/ovn-sbctl.at \ + tests/ovn-controller.at \ tests/ovn-controller-vtep.at SYSTEM_KMOD_TESTSUITE_AT = \ diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at new file mode 100644 index 0000000..8627e59 --- /dev/null +++ b/tests/ovn-controller.at @@ -0,0 +1,75 @@ +AT_BANNER([ovn-controller]) + +AT_SETUP([ovn-controller - ovn-bridge-mappings]) +ovn_init_db ovn-sb +net_add n1 +sim_add hv +as hv +ovs-vsctl \ + -- add-br br-phys \ + -- add-br br-eth0 \ + -- add-br br-eth1 \ + -- add-br br-eth2 +ovn_attach n1 br-phys 192.168.0.1 + +# Waits until the OVS database contains exactly the specified patch ports. +# Each argument should be of the form BRIDGE PORT PEER. +check_patches () { + # Generate code to check that the set of patch ports is exactly as + # specified. + printf > query 'ovs-vsctl -f csv -d bare --no-headings --columns=name find interface type=patch | sort +ovs-vsctl init' + for patch + do + echo $patch + done | cut -d' ' -f 2 | sort > expout + + # Generate code to verify that the configuration of each patch + # port is correct. + for patch + do + set $patch; bridge=$1 port=$2 peer=$3 + printf >>query ' \ + -- iface-to-br %s \ + -- get Interface %s type \ + -- get Interface %s options' $port $port $port + echo >>expout "$bridge +patch +{peer=$peer}" + done + + # Run the query until we get the expected result (or until a timeout). + # + # (We use sed to drop all "s from output because ovs-vsctl quotes some + # of the port names but not others.) + AT_CAPTURE_FILE([query]) + AT_CAPTURE_FILE([expout]) + AT_CAPTURE_FILE([stdout]) + OVS_WAIT_UNTIL([. ./query | sed 's/"//g' > stdout #" + diff -u stdout expout >/dev/null]) +} + +# Initially there should be no patch ports. +check_patches + +# Configure two ovn-bridge mappings to create two patch ports. +AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1]) +check_patches \ + 'br-eth0 patch-br-eth0-to-br-int patch-br-int-to-br-eth0' \ + 'br-int patch-br-int-to-br-eth0 patch-br-eth0-to-br-int' \ + 'br-eth1 patch-br-eth1-to-br-int patch-br-int-to-br-eth1' \ + 'br-int patch-br-int-to-br-eth1 patch-br-eth1-to-br-int' + +# Change the mapping and the patch ports should change. +AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth2,physnet2:br-eth1]) +check_patches \ + 'br-eth2 patch-br-eth2-to-br-int patch-br-int-to-br-eth2' \ + 'br-int patch-br-int-to-br-eth2 patch-br-eth2-to-br-int' \ + 'br-eth1 patch-br-eth1-to-br-int patch-br-int-to-br-eth1' \ + 'br-int patch-br-int-to-br-eth1 patch-br-eth1-to-br-int' + +# Delete the mapping and the patch ports should go away. +AT_CHECK([ovs-vsctl remove Open_vSwitch . external-ids ovn-bridge-mappings]) +check_patches + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index cb2e098..8f915fa 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -70,4 +70,5 @@ m4_include([tests/auto-attach.at]) m4_include([tests/ovn.at]) m4_include([tests/ovn-nbctl.at]) m4_include([tests/ovn-sbctl.at]) +m4_include([tests/ovn-controller.at]) m4_include([tests/ovn-controller-vtep.at])