diff mbox series

[ovs-dev,v2,2/7] tests: Add macros for checking related ports.

Message ID 20240723155444.2530187-3-xsimonar@redhat.com
State Accepted
Delegated to: Numan Siddique
Headers show
Series pmtud and related ports. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Xavier Simonart July 23, 2024, 3:54 p.m. UTC
Two macros have been added:
- CHECK_RELATED_PORTS_AFTER_RECOMPUTE
  Checks the related_lports using IP and recompute.
- CHECK_AFTER_RECOMPUTE
  Checks related_lports and flows using IP and recompute.
  Using CHECK_RELATED_PORTS_AFTER_RECOMPUTE followed by
  CHECK_FLOWS_PORTS_AFTER_RECOMPUTE would not detect any lflow related issues.

CHECK_RELATED_PORTS_AFTER_RECOMPUTE will be used in following patch
to check related_ports at the end of the tests.

Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
---
 tests/ovn-macros.at | 80 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)

Comments

Numan Siddique July 30, 2024, 8:35 p.m. UTC | #1
On Tue, Jul 23, 2024 at 11:55 AM Xavier Simonart <xsimonar@redhat.com> wrote:
>
> Two macros have been added:
> - CHECK_RELATED_PORTS_AFTER_RECOMPUTE
>   Checks the related_lports using IP and recompute.
> - CHECK_AFTER_RECOMPUTE
>   Checks related_lports and flows using IP and recompute.
>   Using CHECK_RELATED_PORTS_AFTER_RECOMPUTE followed by
>   CHECK_FLOWS_PORTS_AFTER_RECOMPUTE would not detect any lflow related issues.
>
> CHECK_RELATED_PORTS_AFTER_RECOMPUTE will be used in following patch
> to check related_ports at the end of the tests.
>
> Signed-off-by: Xavier Simonart <xsimonar@redhat.com>

Thanks.  I applied this patch to main with the below changes

------------------
diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
index 02de7208dc..d57eadfc57 100644
--- a/tests/ovn-macros.at
+++ b/tests/ovn-macros.at
@@ -27,7 +27,7 @@ m4_define([DUMP_FLOWS], [
           sort > $output_file
 ])

-# DUMP_RELATED_PORTS(sbix, output_file)
+# DUMP_RELATED_PORTS(sbox, output_file)
 # Dump related ports
 m4_define([DUMP_RELATED_PORTS], [
     sbox=$1
@@ -69,7 +69,7 @@ m4_define([CHECK_RELATED_PORTS_AFTER_RECOMPUTE], [
     sbox=$2
     related_ports=$3
     AT_CAPTURE_FILE([related-ports-diff])
-    # Make sure I+P has finalized his job before getting flows and
comparing them after recompte.
+    # Make sure I+P has finalized the 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
@@ -79,15 +79,15 @@ m4_define([CHECK_RELATED_PORTS_AFTER_RECOMPUTE], [

     as $sbox
     if test "$hv" != "vtep"; then
-      DUMP_RELATED_PORTS([$sbox], [related-ports-$hv-1])
+      DUMP_RELATED_PORTS([$sbox], [related-ports-$hv-before])
       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_RELATED_PORTS([$sbox], [related-ports-$hv-2])
+      DUMP_RELATED_PORTS([$sbox], [related-ports-$hv-after])
       # Compare and store differences before and after recompute
-      comm -3 related-ports-$hv-1 related-ports-$hv-2 > related-ports-diff-$hv
+      comm -3 related-ports-$hv-before related-ports-$hv-after >
related-ports-diff-$hv
       # Ignore some differences.
       echo "$related_ports" | comm -2 -3 related-ports-diff-$hv - >
related-ports-diff
       AT_CHECK([wc -l < related-ports-diff], [0], [0
---------------------

Numan



> ---
>  tests/ovn-macros.at | 80 ++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 79 insertions(+), 1 deletion(-)
>
> diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
> index 47ada5c70..02de7208d 100644
> --- a/tests/ovn-macros.at
> +++ b/tests/ovn-macros.at
> @@ -27,6 +27,15 @@ m4_define([DUMP_FLOWS], [
>            sort > $output_file
>  ])
>
> +# DUMP_RELATED_PORTS(sbix, output_file)
> +# Dump related ports
> +m4_define([DUMP_RELATED_PORTS], [
> +    sbox=$1
> +    output_file=$2
> +    as $sbox
> +    ovn-appctl debug/dump-related-ports | sort > $output_file
> +])
> +
>  m4_define([CHECK_FLOWS_AFTER_RECOMPUTE], [
>      hv=$1
>      sbox=$2
> @@ -50,7 +59,76 @@ m4_define([CHECK_FLOWS_AFTER_RECOMPUTE], [
>        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])
> +      AT_CHECK([wc -l < flow-diff], [0], [0
> +])
> +    fi
> +])
> +
> +m4_define([CHECK_RELATED_PORTS_AFTER_RECOMPUTE], [
> +    hv=$1
> +    sbox=$2
> +    related_ports=$3
> +    AT_CAPTURE_FILE([related-ports-diff])
> +    # 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
> +      DUMP_RELATED_PORTS([$sbox], [related-ports-$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_RELATED_PORTS([$sbox], [related-ports-$hv-2])
> +      # Compare and store differences before and after recompute
> +      comm -3 related-ports-$hv-1 related-ports-$hv-2 > related-ports-diff-$hv
> +      # Ignore some differences.
> +      echo "$related_ports" | comm -2 -3 related-ports-diff-$hv - > related-ports-diff
> +      AT_CHECK([wc -l < related-ports-diff], [0], [0
> +])
> +    fi
> +])
> +
> +m4_define([CHECK_AFTER_RECOMPUTE], [
> +    hv=$1
> +    sbox=$2
> +    related_ports=$3
> +    AT_CAPTURE_FILE([related-ports-diff])
> +    # 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
> +      DUMP_RELATED_PORTS([$sbox], [related-ports-$hv-1])
> +      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_RELATED_PORTS([$sbox], [related-ports-$hv-2])
> +      DUMP_FLOWS([$sbox], [flows-$hv-2])
> +      # Compare and store differences before and after recompute
> +      comm -3 related-ports-$hv-1 related-ports-$hv-2 > related-ports-diff-$hv
> +      # Ignore some differences.
> +      echo "$related_ports" | comm -2 -3 related-ports-diff-$hv - > related-ports-diff
> +      AT_CHECK([wc -l < related-ports-diff], [0], [0
> +])
> +      diff flows-$hv-1 flows-$hv-2 > flow-diff
> +      AT_CHECK([wc -l < flow-diff], [0], [0
> +])
> +      diff flows-$hv-1 flows-$hv-2 > flow-diff
>      fi
>  ])
>
> --
> 2.31.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
index 47ada5c70..02de7208d 100644
--- a/tests/ovn-macros.at
+++ b/tests/ovn-macros.at
@@ -27,6 +27,15 @@  m4_define([DUMP_FLOWS], [
           sort > $output_file
 ])
 
+# DUMP_RELATED_PORTS(sbix, output_file)
+# Dump related ports
+m4_define([DUMP_RELATED_PORTS], [
+    sbox=$1
+    output_file=$2
+    as $sbox
+    ovn-appctl debug/dump-related-ports | sort > $output_file
+])
+
 m4_define([CHECK_FLOWS_AFTER_RECOMPUTE], [
     hv=$1
     sbox=$2
@@ -50,7 +59,76 @@  m4_define([CHECK_FLOWS_AFTER_RECOMPUTE], [
       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])
+      AT_CHECK([wc -l < flow-diff], [0], [0
+])
+    fi
+])
+
+m4_define([CHECK_RELATED_PORTS_AFTER_RECOMPUTE], [
+    hv=$1
+    sbox=$2
+    related_ports=$3
+    AT_CAPTURE_FILE([related-ports-diff])
+    # 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
+      DUMP_RELATED_PORTS([$sbox], [related-ports-$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_RELATED_PORTS([$sbox], [related-ports-$hv-2])
+      # Compare and store differences before and after recompute
+      comm -3 related-ports-$hv-1 related-ports-$hv-2 > related-ports-diff-$hv
+      # Ignore some differences.
+      echo "$related_ports" | comm -2 -3 related-ports-diff-$hv - > related-ports-diff
+      AT_CHECK([wc -l < related-ports-diff], [0], [0
+])
+    fi
+])
+
+m4_define([CHECK_AFTER_RECOMPUTE], [
+    hv=$1
+    sbox=$2
+    related_ports=$3
+    AT_CAPTURE_FILE([related-ports-diff])
+    # 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
+      DUMP_RELATED_PORTS([$sbox], [related-ports-$hv-1])
+      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_RELATED_PORTS([$sbox], [related-ports-$hv-2])
+      DUMP_FLOWS([$sbox], [flows-$hv-2])
+      # Compare and store differences before and after recompute
+      comm -3 related-ports-$hv-1 related-ports-$hv-2 > related-ports-diff-$hv
+      # Ignore some differences.
+      echo "$related_ports" | comm -2 -3 related-ports-diff-$hv - > related-ports-diff
+      AT_CHECK([wc -l < related-ports-diff], [0], [0
+])
+      diff flows-$hv-1 flows-$hv-2 > flow-diff
+      AT_CHECK([wc -l < flow-diff], [0], [0
+])
+      diff flows-$hv-1 flows-$hv-2 > flow-diff
     fi
 ])