diff mbox series

[ovs-dev,1/2] tests: Skip some tests if nft not installed.

Message ID 20240812121436.2982073-2-xsimonar@redhat.com
State Accepted
Headers show
Series nft in tests. | 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 fail github build: failed

Commit Message

Xavier Simonart Aug. 12, 2024, 12:14 p.m. UTC
If nft related packages are not installed, stop_ovsdb_controller_updates
macro does nothing, and race conditions it is supposed to create won't happen.
Skip the tests using stop_ovsdb_controller_updates if nft is not available.

Also, fail those tests if nft fails.

Fixes: 8d46e542767b ("tests: Add macros to pause controller updates.")
Fixes: 39eb73d92a21 ("tests: Remove almost duplicate macros.")

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

Comments

Mark Michelson Aug. 12, 2024, 8:37 p.m. UTC | #1
Thanks Xavier,

Acked-by: Mark Michelson <mmichels@redhat.com>

On 8/12/24 08:14, Xavier Simonart wrote:
> If nft related packages are not installed, stop_ovsdb_controller_updates
> macro does nothing, and race conditions it is supposed to create won't happen.
> Skip the tests using stop_ovsdb_controller_updates if nft is not available.
> 
> Also, fail those tests if nft fails.
> 
> Fixes: 8d46e542767b ("tests: Add macros to pause controller updates.")
> Fixes: 39eb73d92a21 ("tests: Remove almost duplicate macros.")
> 
> Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
> ---
>   tests/ovn-macros.at | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
> index 4fd941e55..77d1515f6 100644
> --- a/tests/ovn-macros.at
> +++ b/tests/ovn-macros.at
> @@ -1109,16 +1109,18 @@ stop_ovsdb_controller_updates() {
>     TCP_PORT=$1
>     echo Stopping updates from ovn-controller to ovsdb using port $TCP_PORT
>     on_exit 'nft list tables | grep ovn-test && nft delete table ip ovn-test'
> -  nft add table ip ovn-test
> -  nft 'add chain ip ovn-test INPUT { type filter hook input priority 0; policy accept; }'
> -  nft add rule ip ovn-test INPUT tcp dport $TCP_PORT counter drop
> +  # Report the test as skipped if proper nft related packages are not installed.
> +  AT_SKIP_IF([! which nft])
> +  AT_CHECK([nft add table ip ovn-test])
> +  AT_CHECK([nft 'add chain ip ovn-test INPUT { type filter hook input priority 0; policy accept; }'])
> +  AT_CHECK([nft add rule ip ovn-test INPUT tcp dport $TCP_PORT counter drop])
>   }
>   
>   restart_ovsdb_controller_updates() {
>     TCP_PORT=$1
>     echo Restarting updates from ovn-controller to ovsdb
> -  nft list ruleset | grep $TCP_PORT
> -  nft delete table ip ovn-test
> +  AT_CHECK([nft list ruleset | grep $TCP_PORT], [0], [ignore])
> +  AT_CHECK([nft delete table ip ovn-test])
>   }
>   
>   trim_zeros() {
diff mbox series

Patch

diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
index 4fd941e55..77d1515f6 100644
--- a/tests/ovn-macros.at
+++ b/tests/ovn-macros.at
@@ -1109,16 +1109,18 @@  stop_ovsdb_controller_updates() {
   TCP_PORT=$1
   echo Stopping updates from ovn-controller to ovsdb using port $TCP_PORT
   on_exit 'nft list tables | grep ovn-test && nft delete table ip ovn-test'
-  nft add table ip ovn-test
-  nft 'add chain ip ovn-test INPUT { type filter hook input priority 0; policy accept; }'
-  nft add rule ip ovn-test INPUT tcp dport $TCP_PORT counter drop
+  # Report the test as skipped if proper nft related packages are not installed.
+  AT_SKIP_IF([! which nft])
+  AT_CHECK([nft add table ip ovn-test])
+  AT_CHECK([nft 'add chain ip ovn-test INPUT { type filter hook input priority 0; policy accept; }'])
+  AT_CHECK([nft add rule ip ovn-test INPUT tcp dport $TCP_PORT counter drop])
 }
 
 restart_ovsdb_controller_updates() {
   TCP_PORT=$1
   echo Restarting updates from ovn-controller to ovsdb
-  nft list ruleset | grep $TCP_PORT
-  nft delete table ip ovn-test
+  AT_CHECK([nft list ruleset | grep $TCP_PORT], [0], [ignore])
+  AT_CHECK([nft delete table ip ovn-test])
 }
 
 trim_zeros() {