From patchwork Mon Sep 18 16:47:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1836343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g1DJupxb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rq9jW0RPQz1ync for ; Tue, 19 Sep 2023 02:48:47 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0CE0E41A00; Mon, 18 Sep 2023 16:48:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0CE0E41A00 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g1DJupxb X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AA4_qb85w0Io; Mon, 18 Sep 2023 16:48:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 86AA941A09; Mon, 18 Sep 2023 16:48:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 86AA941A09 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 78DA0C0DFE; Mon, 18 Sep 2023 16:47:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0EED3C0DF8 for ; Mon, 18 Sep 2023 16:47:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3B87181E3A for ; Mon, 18 Sep 2023 16:47:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3B87181E3A Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g1DJupxb X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NE-h_fhbz1Ue for ; Mon, 18 Sep 2023 16:47:21 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7C0F582132 for ; Mon, 18 Sep 2023 16:47:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7C0F582132 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695055637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DRgAD2kh/kZfCaPEMRvc5b1KRpcO30kJjyUArMC/MiM=; b=g1DJupxbVj1kChK6pOdbPNutazO0RuHFwSFMpZY8VYnEiAvkEoAUvR1tJO8v6mjU2ODzLW oXQjBfJyLtyYyk36Wzy1O7lI164ksU4gdLkxGsUsfcVPcbIDJo6SiEGm6I0mKZQ+Nym6j2 tH+vItunqBc0cgKKComw8vn3SqyE8n8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-315-d5m5WUkCOFuaiYr0DPZkow-1; Mon, 18 Sep 2023 12:47:16 -0400 X-MC-Unique: d5m5WUkCOFuaiYr0DPZkow-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18BED858281 for ; Mon, 18 Sep 2023 16:47:15 +0000 (UTC) Received: from wsfd-netdev90.ntdv.lab.eng.bos.redhat.com (wsfd-netdev90.ntdv.lab.eng.bos.redhat.com [10.19.188.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2811C15BB8; Mon, 18 Sep 2023 16:47:14 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Mon, 18 Sep 2023 18:47:05 +0200 Message-Id: <20230918164714.3144984-7-xsimonar@redhat.com> In-Reply-To: <20230918164714.3144984-1-xsimonar@redhat.com> References: <20230918164714.3144984-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 06/15] tests: fixed multiple tests not properly waiting for packets to be received X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" - dhcpv4 : 1 HV, 2 LS, 2 LSPs/LS - dns lookup : 1 HV, 2 LS, 2 LSPs/LS - dhcpv6 : 1 HV, 2 LS, 5 LSPs - IPv6 ND Router Solicitation responder - 4 HV, 1 LS, 1 LR, packet test with HA distributed router gateway port - send gratuitous arp for NAT rules on distributed router - send gratuitous ARP for NAT rules on HA distributed router - external logical port Some of those tests were already "waiting" for packets but were either waiting for the expected number of packets (and hence failing if a garp was received), or were waiting just for a few more packets, to handle garp (but were failing if more garp were received, and were slower than expected as always waiting for a few additional packets). Signed-off-by: Xavier Simonart --- tests/ovn.at | 297 +++++++++++++++------------------------------------ 1 file changed, 88 insertions(+), 209 deletions(-) diff --git a/tests/ovn.at b/tests/ovn.at index 927c505df..eb0ca82b1 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -23,8 +23,11 @@ m4_divert_text([PREPARE_TESTS], diff -u $exp_text.sorted $rcv_text.sorted } ovn_check_packets__ () { - echo - echo "$3: checking packets in $1 against $2:" + if [[ -n "$4" ]]; then + echo "$3: checking packets in $1 against $2: using $4" + else + echo "$3: checking packets in $1 against $2:" + fi rcv_pcap=$1 rcv_text=`echo "$rcv_pcap.packets" | sed 's/\.pcap//'` exp_text=$2 @@ -35,7 +38,13 @@ m4_divert_text([PREPARE_TESTS], echo "rcv_n=$rcv_n exp_n=$exp_n" test $rcv_n -ge $exp_n], [dump_diff__ "$rcv_pcap" "$exp_text"]) - sort $exp_text > expout + if [[ -n "$4" ]]; then + sort $exp_text | $4 > expout + cat $rcv_text | $4 > rcv_tmp + mv rcv_tmp $rcv_text + else + sort $exp_text > expout + fi } ovn_check_packets_remove_broadcast__ () { echo "$3: checking packets in $1 against $2:" @@ -54,14 +63,26 @@ m4_divert_text([PREPARE_TESTS], } ovn_wait_packets__ () { echo "$3: waiting for packets from $2 at $1:" + if [[ -n "$4" ]]; then + echo "$3: checking packets from $2 at $1: using $4" + else + echo "$3: checking packets from $2 at $1:" + fi rcv_pcap=$1 rcv_text=`echo "$rcv_pcap.packets" | sed 's/\.pcap//'` exp_text=$2 + if [[ -n "$4" ]]; then + cmd=$4 + else + cmd=: + fi OVS_WAIT_UNTIL( [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text - sort $exp_text > expout - test x"$(sort $rcv_text | comm -2 -3 expout -)" = "x"], + sort $exp_text | $cmd > expout + test x"$(sort $rcv_text | $cmd | comm -2 -3 expout -)" = "x"], [dump_diff__ "$rcv_pcap" "$exp_text"]) + cat $rcv_text | $cmd > rcv_tmp + mv rcv_tmp $rcv_text } ovn_wait_packets_uniq__ () { echo "$3: waiting for packets from $2 at $1:" @@ -140,7 +161,7 @@ m4_divert_text([PREPARE_TESTS], m4_define([OVN_CHECK_PACKETS], [AT_CHECK([$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $1 ], [0], [ignore]) - ovn_check_packets__ "$1" "$2" "__file__:__line__" + ovn_check_packets__ "$1" "$2" "__file__:__line__" $3 AT_CHECK([sort $rcv_text], [0], [expout], [ignore], [dump_diff__ "$1" "$2"])]) m4_define([OVN_CHECK_PACKETS_REMOVE_BROADCAST], @@ -6771,13 +6792,7 @@ test_dhcp() { } compare_dhcp_packets() { - received=$($PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif$1-tx.pcap) - expected=$(cat $1.expected) - - if test "$received" != "$expected"; then - AT_CHECK_UNQUOTED([echo "$received"; tcpdump_hex "$received"], [0], - [$(echo "$expected"; tcpdump_hex "$expected")]) - fi + OVN_CHECK_PACKETS([hv1/vif$1-tx.pcap], [$1.expected]) } AT_CAPTURE_FILE([sbflows]) @@ -6975,8 +6990,9 @@ expected_dhcp_opts=0 test_dhcp 11 2 f00000000002 07 0 $ciaddr $offer_ip $request_ip 0 0 ff1000000001 # There is no reply for this. Check for the INFO log in ovn-controller.log -AT_CHECK([test 1 = $(cat hv1/ovn-controller.log | \ -grep "DHCPRELEASE f0:00:00:00:00:02 10.0.0.6" -c)]) +OVS_WAIT_UNTIL( + [test 1 = $(cat hv1/ovn-controller.log | grep "DHCPRELEASE f0:00:00:00:00:02 10.0.0.6" -c) +]) $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets AT_CHECK([cat 2.packets], [0], []) @@ -7133,7 +7149,9 @@ ciaddr=`ip_to_hex 0 0 0 0` request_ip=0 expected_dhcp_opts="" test_dhcp 18 1 f00000000001 04 0 $ciaddr $offer_ip $request_ip 0 0 ff1000000001 $server_ip 02 $expected_dhcp_opts -AT_CHECK([grep -F -iq 'DHCPDECLINE from f0:00:00:00:00:01, 10.0.0.4 duplicated' hv1/ovn-controller.log], [0], []) +OVS_WAIT_UNTIL( + [test 1 -le $(grep -F -i -c 'DHCPDECLINE from f0:00:00:00:00:01, 10.0.0.4 duplicated' hv1/ovn-controller.log) +]) # Send Etherboot. @@ -7413,12 +7431,8 @@ test_dhcpv6_release() { check_packets() { local port=$1 - $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif$port-tx.pcap | trim_zeros > $port.packets # Skipping UDP checksum - cat $port.expected | cut -c 1-120,125- > expout - AT_CHECK([cat $port.packets | cut -c 1-120,125- ], [0], [expout]) - - rm $port.packets + OVN_CHECK_PACKETS([hv1/vif$port-tx.pcap], [$port.expected], ["trim_zeros | cut -c 1-120,125-"]) rm $port.expected } @@ -11020,12 +11034,9 @@ test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 1. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets -cat 1.expected | cut -c -48 > expout -AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat 1.expected | cut -c 53- > expout -AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c 53-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11042,12 +11053,9 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets -cat 2.expected | cut -c -48 > expout -AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat 2.expected | cut -c 53- > expout -AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c 53-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11065,12 +11073,9 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 3. OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets -cat 2.expected | cut -c -48 > expout -AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat 2.expected | cut -c 53- > expout -AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c 53-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11147,12 +11152,9 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 5. OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets -cat 2.expected | cut -c -48 > expout -AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat 2.expected | cut -c 53- > expout -AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c 53-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11170,12 +11172,9 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 6. OVS_WAIT_UNTIL([test 6 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets -cat 2.expected | cut -c -48 > expout -AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat 2.expected | cut -c 53- > expout -AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c 53-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11237,12 +11236,9 @@ test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 9. OVS_WAIT_UNTIL([test 9 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets -cat 1.expected | cut -c -48 > expout -AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat 1.expected | cut -c 53- > expout -AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c 53-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11260,10 +11256,8 @@ test_dns6 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $ # NXT_RESUMEs should be 10 OVS_WAIT_UNTIL([test 10 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets # Skipping the UDP checksum. -cat 1.expected | cut -c 1-120,125- > expout -AT_CHECK([cat 1.packets | cut -c 1-120,125-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c 1-120,125-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11289,12 +11283,9 @@ test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 11. OVS_WAIT_UNTIL([test 11 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets -cat 1.expected | cut -c -48 > expout -AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat 1.expected | cut -c 53- > expout -AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c 53-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11312,12 +11303,9 @@ test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 12. OVS_WAIT_UNTIL([test 12 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets -cat 1.expected | cut -c -48 > expout -AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat 1.expected | cut -c 53- > expout -AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c 53-"]) reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 @@ -11497,30 +11485,7 @@ test_ip_packet() # Resend packet from foo1 to outside1 check as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet - AT_CAPTURE_FILE([exp]) - AT_CAPTURE_FILE([rcv]) - check_packets() { - > exp - > rcv - - pcap=ext1/vif1-tx.pcap - type=ext1-vif1.expected - echo "--- $pcap" | tee -a exp >> rcv - sort -u "$type" >> exp - $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $pcap | sort -u >> rcv - echo | tee -a exp >> rcv - - pcap=$active_gw/br-phys_n1-tx.pcap - echo "--- $pcap" | tee -a exp >> rcv - sort -u "$type" >> exp - $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $pcap > packets - (grep "$expected" packets; grep "$exp_gw_ip_garp" packets) | sort -u >> rcv - echo | tee -a exp >> rcv - - $at_diff exp rcv >/dev/null - } - - OVS_WAIT_UNTIL([check_packets], [$at_diff -F'^---' exp rcv]) + OVN_CHECK_PACKETS_CONTAIN([ext1/vif1-tx.pcap], [ext1-vif1.expected]) if test $backup_vswitchd_dead != 1; then # Check for backup gw only if vswitchd is alive @@ -12256,21 +12221,16 @@ OVN_WAIT_PATCH_PORT_FLOWS(["ln_port"], ["hv3"]) # Re-add nat-addresses option ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" -# Wait for packets to be received. -OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 250]) trim_zeros() { sed 's/\(00\)\{1,\}$//' } -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | sort | uniq > packets garp_1="fffffffffffff0000000000308060001080006040001f00000000003c0a80003000000000000c0a80003" -echo $garp_1 > expout +echo $garp_1 > expected_out garp_2="fffffffffffff0000000000408060001080006040001f00000000004c0a80004000000000000c0a80004" -echo $garp_2 >> expout +echo $garp_2 >> expected_out -cat packets | grep $garp_1 | head -1 > exp -cat packets | grep $garp_2 | head -1 >> exp -AT_CHECK([cat exp], [0], [expout]) +OVN_CHECK_PACKETS_CONTAIN([hv1/snoopvif-tx.pcap], [expected_out], "trim_zeros") OVN_CLEANUP([hv1],[hv2],[hv3]) @@ -12716,14 +12676,9 @@ test_ipv6_ra 1 $src_mac $src_lla $addr_mode 0 $default_prefix_option_config # NXT_RESUME should be 1. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets - -cat 1.expected | cut -c -112 > expout -AT_CHECK([cat 1.packets | cut -c -112], [0], [expout]) - +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c -112"]) # Skipping the ICMPv6 checksum. -cat 1.expected | cut -c 117- > expout -AT_CHECK([cat 1.packets | cut -c 117-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c 117-"]) rm -f *.expected reset_pcap_file hv1-vif1 hv1/vif1 @@ -12756,14 +12711,9 @@ test_ipv6_ra 2 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config $ # NXT_RESUME should be 2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets - -cat 2.expected | cut -c -112 > expout -AT_CHECK([cat 2.packets | cut -c -112], [0], [expout]) - +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c -112"]) # Skipping the ICMPv6 checksum. -cat 2.expected | cut -c 117- > expout -AT_CHECK([cat 2.packets | cut -c 117-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [2.expected], ["cut -c 117-"]) rm -f *.expected reset_pcap_file hv1-vif1 hv1/vif1 @@ -12790,14 +12740,9 @@ test_ipv6_ra 3 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config " # NXT_RESUME should be 3. OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > 3.packets - -cat 3.expected | cut -c -112 > expout -AT_CHECK([cat 3.packets | cut -c -112], [0], [expout]) - +OVN_CHECK_PACKETS([hv1/vif3-tx.pcap], [3.expected], ["cut -c -112"]) # Skipping the ICMPv6 checksum. -cat 3.expected | cut -c 117- > expout -AT_CHECK([cat 3.packets | cut -c 117-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif3-tx.pcap], [3.expected], ["cut -c 117-"]) rm -f *.expected reset_pcap_file hv1-vif1 hv1/vif1 @@ -12822,14 +12767,9 @@ test_ipv6_ra 1 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config # NXT_RESUME should be 4. OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets - -cat 1.expected | cut -c -112 > expout -AT_CHECK([cat 1.packets | cut -c -112], [0], [expout]) - +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c -112"]) # Skipping the ICMPv6 checksum. -cat 1.expected | cut -c 117- > expout -AT_CHECK([cat 1.packets | cut -c 117-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected], ["cut -c 117-"]) rm -f *.expected reset_pcap_file hv1-vif1 hv1/vif1 @@ -13895,8 +13835,6 @@ as hv1 reset_pcap_file snoopvif hv1/snoopvif # add nat-addresses option ovn-nbctl --wait=hv lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" -# Wait for packets to be received through hv2. -OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) trim_zeros() { sed 's/\(00\)\{1,\}$//' } @@ -13906,22 +13844,10 @@ only_broadcast_from_lrp1() { } garp="fffffffffffff0000000000108060001080006040001f00000000001c0a80064000000000000c0a80064" -echo $garp > expout +echo $garp > expected_out -OVS_WAIT_UNTIL( - [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap > rcv_text - exp_rcvd=$(cat rcv_text | grep $garp | wc -l) - echo "expected received = $exp_rcvd" - test $exp_rcvd -ge 1]) - -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoop_tx -echo "packets on hv1-snoopvif:" -cat hv1_snoop_tx -AT_CHECK([sort hv1_snoop_tx], [0], [expout]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx -echo "packets on hv2 br-phys tx" -cat hv2_br_phys_tx -AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], [expout]) +OVN_CHECK_PACKETS_CONTAIN([hv1/snoopvif-tx.pcap], [expected_out], "trim_zeros") +OVN_CHECK_PACKETS_CONTAIN([hv2/br-phys_n1-tx.pcap], [expected_out], "trim_zeros") $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx echo "packets on hv3 br-phys tx" cat hv3_br_phys_tx @@ -13947,17 +13873,8 @@ trim_zeros() { sed 's/\(00\)\{1,\}$//' } -# Wait for packets to be received. -OVS_WAIT_UNTIL( - [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap > rcv_text - exp_rcvd=$(cat rcv_text | grep $garp | wc -l) - echo "expected received = $exp_rcvd" - test $exp_rcvd -ge 1]) - -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx -AT_CHECK([sort hv1_snoopvif_tx], [0], [expout]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx -AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], [expout]) +OVN_CHECK_PACKETS_CONTAIN([hv1/snoopvif-tx.pcap], [expected_out], "trim_zeros") +OVN_CHECK_PACKETS_CONTAIN([hv3/br-phys_n1-tx.pcap], [expected_out], "trim_zeros") $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], []) @@ -13990,25 +13907,15 @@ ovn-nbctl --wait=hv lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="rout OVS_WAIT_UNTIL([test 1 = `ovn-sbctl --bare --columns nat_addresses find port_binding \ logical_port=lrp0-rp | grep is_chassis | wc -l`]) -# Wait for packets to be received. -OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) trim_zeros() { sed 's/\(00\)\{1,\}$//' } garp="fffffffffffff00000000001810007de08060001080006040001f00000000001c0a80064000000000000c0a80064" -echo $garp > expout +echo $garp > expected_out -OVS_WAIT_UNTIL( - [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap > rcv_text - exp_rcvd=$(cat rcv_text | grep $garp | wc -l) - echo "expected received = $exp_rcvd" - test $exp_rcvd -ge 1]) - -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx -AT_CHECK([sort hv1_snoopvif_tx], [0], [expout]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx -AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], [expout]) +OVN_CHECK_PACKETS_CONTAIN([hv1/snoopvif-tx.pcap], [expected_out], "trim_zeros") +OVN_CHECK_PACKETS_CONTAIN([hv3/br-phys_n1-tx.pcap], [expected_out], "trim_zeros") $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], []) @@ -19895,12 +19802,9 @@ OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 0 in hv2. OVS_WAIT_UNTIL([test 0 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets -cat ext1_v4.expected | cut -c -48 > expout -AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v4.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat ext1_v4.expected | cut -c 53- > expout -AT_CHECK([cat ext1_v4.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v4.expected], ["cut -c 53-"]) # ovs-ofctl also resumes the packets and this causes other ports to receive # the DHCP request packet. So reset the pcap files so that its easier to test. @@ -19922,13 +19826,9 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 0 in hv2. OVS_WAIT_UNTIL([test 0 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ -sort > ext1_v6.packets -cat ext1_v6.expected | cut -c -120 > expout -AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v6.expected], ["cut -c -120"]) # Skipping the UDP checksum -cat ext1_v6.expected | cut -c 125- > expout -AT_CHECK([cat ext1_v6.packets | cut -c 125-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v6.expected], ["cut -c 125-"]) rm -f ext1_v6.expected rm -f ext1_v6.packets @@ -19988,12 +19888,9 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 1 in hv2. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets -cat ext1_v4.expected | cut -c -48 > expout -AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v4.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat ext1_v4.expected | cut -c 53- > expout -AT_CHECK([cat ext1_v4.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v4.expected], ["cut -c 53-"]) # ovs-ofctl also resumes the packets and this causes other ports to receive # the DHCP request packet. So reset the pcap files so that its easier to test. @@ -20014,13 +19911,9 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 2 in hv2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ -sort > ext1_v6.packets -cat ext1_v6.expected | cut -c -120 > expout -AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v6.expected], ["cut -c -120"]) # Skipping the UDP checksum -cat ext1_v6.expected | cut -c 125- > expout -AT_CHECK([cat ext1_v6.packets | cut -c 125-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v6.expected], ["cut -c 125-"]) rm -f ext1_v6.expected rm -f ext1_v6.packets @@ -20096,12 +19989,9 @@ OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 2 in hv2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets -cat ext1_v4.expected | cut -c -48 > expout -AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v4.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat ext1_v4.expected | cut -c 53- > expout -AT_CHECK([cat ext1_v4.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v4.expected], ["cut -c 53-"]) # ovs-ofctl also resumes the packets and this causes other ports to receive # the DHCP request packet. So reset the pcap files so that its easier to test. @@ -20123,13 +20013,9 @@ OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 2 in hv2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ -sort > ext1_v6.packets -cat ext1_v6.expected | cut -c -120 > expout -AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v6.expected], ["cut -c -120"]) # Skipping the UDP checksum -cat ext1_v6.expected | cut -c 125- > expout -AT_CHECK([cat ext1_v6.packets | cut -c 125-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v6.expected], ["cut -c 125-"]) rm -f ext1_v6.expected rm -f ext1_v6.packets @@ -20177,12 +20063,9 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 1 in hv3. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv3.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets -cat ext1_v4.expected | cut -c -48 > expout -AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v4.expected], ["cut -c -48"]) # Skipping the IPv4 checksum. -cat ext1_v4.expected | cut -c 53- > expout -AT_CHECK([cat ext1_v4.packets | cut -c 53-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v4.expected], ["cut -c 53-"]) # ovs-ofctl also resumes the packets and this causes other ports to receive # the DHCP request packet. So reset the pcap files so that its easier to test. @@ -20207,13 +20090,9 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 2 in hv3. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv3.log | grep -c NXT_RESUME`]) -$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ -sort > ext1_v6.packets -cat ext1_v6.expected | cut -c -120 > expout -AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v6.expected], ["cut -c -120"]) # Skipping the UDP checksum -cat ext1_v6.expected | cut -c 125- > expout -AT_CHECK([cat ext1_v6.packets | cut -c 125-], [0], [expout]) +OVN_CHECK_PACKETS([hv1/ext1-tx.pcap], [ext1_v6.expected], ["cut -c 125-"]) # disconnect hv3 from the network, hv1 should take over as hv3