From patchwork Tue Mar 26 11:56:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1916080 X-Patchwork-Delegate: dceara@redhat.com 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=NCcFjNvE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 4V3pFB2DtWz1yY2 for ; Tue, 26 Mar 2024 22:57:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A4CAE40806; Tue, 26 Mar 2024 11:57:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PR3bw8hvp_Lv; Tue, 26 Mar 2024 11:56:58 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 4423E407D4 Authentication-Results: smtp4.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=NCcFjNvE Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 4423E407D4; Tue, 26 Mar 2024 11:56:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1A0C3C0077; Tue, 26 Mar 2024 11:56:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 59E9FC0037 for ; Tue, 26 Mar 2024 11:56:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 56C5C60AC1 for ; Tue, 26 Mar 2024 11:56:56 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id IwYgDziI_dgr for ; Tue, 26 Mar 2024 11:56:55 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=xsimonar@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 8EEEC60ACA Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8EEEC60ACA Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NCcFjNvE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 8EEEC60ACA for ; Tue, 26 Mar 2024 11:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711454214; 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; bh=FfPhEd7G7UY9OWQmGlOx7JSMjP7HrviDdXzwJ0aKMVc=; b=NCcFjNvEnCrtQjN6FfWyuryOuDXyNXSaHrAJ22R8B+hPUONN5LJ5hPd3ELjsZz5ZtZgf15 P6zNQkPKLNAry5nqWXKRfXkU7da82VaxiwbPCWGyowiErXq2ReGfojyEBtJNZnIqgK2SlC 1SMZLq3iYr9ZvtqjzgPzthTeJJngB/k= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-369-Np_ZVfZdMDOH_g4Xr7tjww-1; Tue, 26 Mar 2024 07:56:52 -0400 X-MC-Unique: Np_ZVfZdMDOH_g4Xr7tjww-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8A831C02159 for ; Tue, 26 Mar 2024 11:56:51 +0000 (UTC) Received: from wsfd-netdev90.ntdv.lab.eng.bos.redhat.com (wsfd-netdev90.anl.eng.rdu2.dc.redhat.com [10.6.38.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id B13A5C04121; Tue, 26 Mar 2024 11:56:51 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Tue, 26 Mar 2024 12:56:51 +0100 Message-Id: <20240326115651.3433227-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] tests: Add macro for checking flows after recompute. 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" The macro CHECK_FLOWS_AFTER_RECOMPUTE dumps the Openflows, then recomputes, then dumps again the Openflows, and finally compares both sets of flows. The test fails if flows are different. As of now, the macro cannot be used in all tests: many tests would fail as I+P does not properly remove flows when the last logical port of a datapath is deleted. Signed-off-by: Xavier Simonart Acked-by: Ales Musil --- tests/ovn-macros.at | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at index ed93764d3..11377f616 100644 --- a/tests/ovn-macros.at +++ b/tests/ovn-macros.at @@ -10,6 +10,50 @@ m4_define([OVN_CLEANUP_VSWITCH],[ OVS_APP_EXIT_AND_WAIT([ovsdb-server]) ]) +# DUMP_FLOWS(sbox, output_file) +# Dump openflows to output_file for sbox +m4_define([DUMP_FLOWS], [ + sbox=$1 + output_file=$2 + as $sbox + ovs-ofctl dump-flows br-int | + sed 's/cookie=0x[[^,]]*/cookie=xx/g' | + sed 's/duration=[[^,]]*/duration=xx/g' | + sed 's/idle_age=[[^,]]*/idle_age=xx/g' | + sed 's/, hard_age=[[^,]]*//g' | + sed 's/n_bytes=[[^,]]*/n_bytes=xx/g' | + sed 's/n_packets=[[^,]]*/n_packets=xx/g' | + sed 's/conjunction([[^,]]*/conjunction(xx/g' | + sort > $output_file +]) + +m4_define([CHECK_FLOWS_AFTER_RECOMPUTE], [ + hv=$1 + sbox=$2 + # Make sure I+P has finalized his job before getting flows and comparing them after recompte. + # Some tests have northd and ovn-nb ovsdb stopped, so avoid ovn-nbctl for those. + if [[ -e ovn-nb/ovn-nb.sock ]] && [[ -e northd/ovn-northd.pid ]]; then + # Do wait twice to handle some potential race conditions + check ovn-nbctl --wait=hv sync + check ovn-nbctl --wait=hv sync + fi + + as $sbox + if test "$hv" != "vtep"; then + # Get flows before and after recompute + DUMP_FLOWS([$sbox], [flows-$hv-1]) + + check ovn-appctl -t ovn-controller recompute + # The recompute might cause some sb changes. Let controller catch up. + if [[ -e ovn-nb/ovn-nb.sock ]] && [[ -e northd/ovn-northd.pid ]]; then + check ovn-nbctl --wait=hv sync + fi + DUMP_FLOWS([$sbox], [flows-$hv-2]) + diff flows-$hv-1 flows-$hv-2 > flow-diff + AT_CHECK([test $(diff flows-$hv-1 flows-$hv-2 | wc -l) == 0]) + fi +]) + # OVN_CLEANUP_CONTROLLER(sbox) # # Gracefully terminate ovn-controller in the specified