On Thu, Jan 16, 2025 at 5:58 PM Xavier Simonart <xsimo...@redhat.com> wrote:

> The tests was sometimes (rarely) failing as:
> - Looking for flows with e.g. cookie c5d057f but hitting cookie bec5d057.
> - Looking for flows with e.g. cookie 1000000 but hitting
> set_field:0x1000000.
>
> Signed-off-by: Xavier Simonart <xsimo...@redhat.com>
> ---
> v2: Use ovn-debug to get the cookie (as per Ales' feedback).
> ---
>  tests/ovn.at | 79 +++++++++++++++++++++++-----------------------------
>  1 file changed, 35 insertions(+), 44 deletions(-)
>
> diff --git a/tests/ovn.at b/tests/ovn.at
> index aa212f774..bf68991d3 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -35415,6 +35415,22 @@ m4_define([MULTIPLE_OVS_INT],
>             sed -e 's/n_bytes=[[0-9]]*, //g'
>     }
>
> +   WAIT_UNTIL_FLOWS()
> +   {
> +       cookie=${1}
> +       interface=${2}
> +       OVS_WAIT_UNTIL([
> +           ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=$interface)
> +           ovs-ofctl dump-flows br-int | grep "cookie=$cookie" | grep
> "actions=output:$ofport"
> +       ])
> +   }
> +
> +   get_nb_flows()
> +   {
> +       cookie=${1}
> +       ovs-ofctl dump-flows br-int | grep "cookie=$cookie" | wc -l
> +   }
> +
>     check ovn-nbctl ls-add ls
>     check ovn-nbctl lsp-add ls lp
>     if test X$1 != X; then
> @@ -35438,13 +35454,11 @@ m4_define([MULTIPLE_OVS_INT],
>     echo ======================================================
>     echo === Flows after iface-id set for the old interface ===
>     echo ======================================================
> -   COOKIE=$(ovn-sbctl find port_binding logical_port=lp|grep uuid|cut -d:
> -f2| cut -c1-8 | sed 's/^\s*0\{0,8\}//')
> +   COOKIE=$(ovn-debug uuid-to-cookie $(fetch_column port_binding _uuid
> logical_port=lp))
>
> -   OVS_WAIT_UNTIL([
> -       ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=lpold)
> -       ovs-ofctl dump-flows br-int | grep $COOKIE | grep
> "actions=output:$ofport"
> -   ])
> -   nb_flows=`ovs-ofctl dump-flows br-int | grep $COOKIE | wc -l`
> +   WAIT_UNTIL_FLOWS $COOKIE lpold
> +
> +   nb_flows=$(get_nb_flows $COOKIE )
>     echo $nb_flows "flows after iface-id set for old interface"
>
>     echo ======================================================
> @@ -35453,11 +35467,8 @@ m4_define([MULTIPLE_OVS_INT],
>     # Set external_ids:iface-id within same transaction as adding the port.
>     # This will generally cause ovn-controller to get initially notified
> of ovs interface changes with ofport == 0.
>     check ovs-vsctl add-port br-int lpnew -- set interface lpnew
> type=internal -- set interface lpnew external_ids:iface-id=lp
> -   OVS_WAIT_UNTIL([
> -       ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=lpnew)
> -       ovs-ofctl dump-flows br-int | grep $COOKIE | grep
> "actions=output:$ofport"
> -   ])
> -   check test "$nb_flows" = $(ovs-ofctl dump-flows br-int | grep $COOKIE
> | wc -l)
> +   WAIT_UNTIL_FLOWS $COOKIE lpnew
> +   check test "$nb_flows" = $(get_nb_flows $COOKIE)
>     flows_lpnew=$(get_flows $COOKIE)
>
>     echo ======================================================
> @@ -35466,7 +35477,7 @@ m4_define([MULTIPLE_OVS_INT],
>     check ovs-vsctl del-port br-int lpold
>     # We do not expect changes, so let's wait for controller to get time
> to process any update
>     check ovn-nbctl --wait=hv sync
> -   check test "$nb_flows" = $(ovs-ofctl dump-flows br-int | grep $COOKIE
> | wc -l)
> +   check test "$nb_flows" = $(get_nb_flows $COOKIE)
>     flows_after_deletion=$(get_flows $COOKIE)
>     check test "$flows_lpnew" = "$flows_after_deletion"
>
> @@ -35477,23 +35488,15 @@ m4_define([MULTIPLE_OVS_INT],
>     # This will generally cause ovn-controller to get notified of ovs
> interface changes with a proper ofport.
>     check ovs-vsctl add-port br-int lptemp -- set Interface lptemp
> type=internal
>     check ovs-vsctl set Interface lptemp external_ids:iface-id=lp
> -   OVS_WAIT_UNTIL([
> -       ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=lptemp)
> -       ovs-ofctl dump-flows br-int | grep $COOKIE | grep
> "actions=output:$ofport"
> -   ])
> -   check test "$nb_flows" = $(ovs-ofctl dump-flows br-int | grep $COOKIE
> | wc -l)
> +   WAIT_UNTIL_FLOWS $COOKIE lptemp
> +   check test "$nb_flows" = $(get_nb_flows $COOKIE)
>
>     echo ======================================================
>     echo ======= Flows after lptemp interface is deleted ======
>     echo ======================================================
>     check ovs-vsctl del-port br-int lptemp
> -   OVS_WAIT_UNTIL([
> -       ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=lpnew)
> -       echo $ofport
> -       ovs-ofctl dump-flows br-int  | grep $COOKIE
> -       ovs-ofctl dump-flows br-int | grep $COOKIE | grep
> "actions=output:$ofport"
> -   ])
> -   check test "$nb_flows" = $(ovs-ofctl dump-flows br-int | grep $COOKIE
> | wc -l)
> +   WAIT_UNTIL_FLOWS $COOKIE lpnew
> +   check test "$nb_flows" = $(get_nb_flows $COOKIE)
>     flows_after_deletion=$(get_flows $COOKIE)
>     check test "$flows_lpnew" = "$flows_after_deletion"
>
> @@ -35502,7 +35505,7 @@ m4_define([MULTIPLE_OVS_INT],
>     echo ======================================================
>     check ovs-vsctl del-port br-int lpnew
>     OVS_WAIT_UNTIL([
> -       nb_flows=`ovs-ofctl dump-flows br-int | grep $COOKIE | wc -l`
> +       nb_flows=`get_nb_flows $COOKIE`
>         test "${nb_flows}" = $nb_flows_ref
>     ])
>
> @@ -35515,21 +35518,15 @@ m4_define([MULTIPLE_OVS_INT],
>     check ovs-vsctl set interface lpnew external_ids:iface-id=lp
>
>     # Wait for lpnew  flows to be installed
> -   OVS_WAIT_UNTIL([
> -       ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=lpnew)
> -       ovs-ofctl dump-flows br-int | grep $COOKIE | grep
> "actions=output:$ofport"
> -   ])
> +   WAIT_UNTIL_FLOWS $COOKIE lpnew
>     flows_lpnew=$(get_flows $COOKIE)
> -   nb_flows=`ovs-ofctl dump-flows br-int | grep $COOKIE | wc -l`
> +   nb_flows=`get_nb_flows $COOKIE`
>
>     check ovs-vsctl add-port br-int lptemp -- set Interface lptemp
> type=internal
>     check ovs-vsctl set Interface lptemp external_ids:iface-id=lp
>
>     # Wait for lptemp  flows to be installed
> -   OVS_WAIT_UNTIL([
> -       ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=lptemp)
> -       ovs-ofctl dump-flows br-int | grep $COOKIE | grep
> "actions=output:$ofport"
> -   ])
> +   WAIT_UNTIL_FLOWS $COOKIE lptemp
>
>     # Delete both lpold and lptemp to go to a stable situation
>     check ovs-vsctl del-port br-int lptemp
> @@ -35540,21 +35537,15 @@ m4_define([MULTIPLE_OVS_INT],
>     ])
>
>     # Wait for correct/lpnew flows to be installed
> -   OVS_WAIT_UNTIL([
> -       ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=lpnew)
> -       ovs-ofctl dump-flows br-int | grep $COOKIE | grep
> "actions=output:$ofport"
> -   ])
> -   check test "$nb_flows" = $(ovs-ofctl dump-flows br-int | grep $COOKIE
> | wc -l)
> +   WAIT_UNTIL_FLOWS $COOKIE lpnew
> +   check test "$nb_flows" = $(get_nb_flows $COOKIE)
>     flows_after_deletion=$(get_flows $COOKIE)
>     check test "$flows_lpnew" = "$flows_after_deletion"
>
>     # Check that recompute still works
>     check ovn-appctl -t ovn-controller recompute
> -   OVS_WAIT_UNTIL([
> -       ofport=$(ovs-vsctl --bare --columns ofport find Interface
> name=lpnew)
> -       ovs-ofctl dump-flows br-int | grep $COOKIE | grep
> "actions=output:$ofport"
> -   ])
> -   check test "$nb_flows" = $(ovs-ofctl dump-flows br-int | grep $COOKIE
> | wc -l)
> +   WAIT_UNTIL_FLOWS $COOKIE lpnew
> +   check test "$nb_flows" = $(get_nb_flows $COOKIE)
>     flows_after_deletion=$(get_flows $COOKIE)
>     check test "$flows_lpnew" = "$flows_after_deletion"
>
> --
> 2.47.1
>
>
Looks good to me, thanks.

Acked-by: Ales Musil <amu...@redhat.com>
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to