diff mbox series

[ovs-dev,v2,1/3] tests: Add macros to pause controller updates.

Message ID 20240326115525.3433113-1-xsimonar@redhat.com
State Accepted
Headers show
Series [ovs-dev,v2,1/3] tests: Add macros to pause controller updates. | expand

Commit Message

Xavier Simonart March 26, 2024, 11:55 a.m. UTC
Such macros can then be used for instance to create condition where
sb is seen as read-only by ovn-controller.

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

Comments

Ales Musil March 28, 2024, 8:48 a.m. UTC | #1
On Tue, Mar 26, 2024 at 12:55 PM Xavier Simonart <xsimonar@redhat.com>
wrote:

> Such macros can then be used for instance to create condition where
> sb is seen as read-only by ovn-controller.
>
> Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
> ---
>

Hi Xavier,

thank you for the v2, there is one small nit that can be addressed during
merge.

 tests/ovn-macros.at | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
> index ed93764d3..bcfd6a521 100644
> --- a/tests/ovn-macros.at
> +++ b/tests/ovn-macros.at
> @@ -220,12 +220,14 @@ ovn_start_northd() {
>  # options are accepted to adjust that:
>  #   --backup-northd         Start a backup northd.
>  #   --backup-northd=paused  Start the backup northd in the paused state.
> +#   --use-tcp-to-sb         Use tcp to connect to sb.
>  ovn_start () {
>      local backup_northd=false
>      local backup_northd_options=
>      case $1 in
>          --backup-northd) backup_northd=true; shift ;;
>          --backup-northd=paused) backup_northd=true;
> backup_northd_options=--paused; shift ;;
> +        --use-tcp-to-sb) use_tcp=true; shift ;;
>      esac
>      local AZ=$1
>      local msg_prefix=${AZ:+$AZ: }
> @@ -246,7 +248,13 @@ ovn_start () {
>          ovn_start_northd $backup_northd_options backup $AZ
>      fi
>
> -    if test X$HAVE_OPENSSL = Xyes; then
> +    if test $use_tcp; then
> +        # Create the SB DB ptcp connection.
> +        ovn-sbctl \
> +            -- --id=@c create connection \
> +                target=\"ptcp:0:127.0.0.1\" \
> +            -- add SB_Global . connections @c
> +    elif test X$HAVE_OPENSSL = Xyes; then
>          # Create the SB DB pssl+RBAC connection.
>          ovn-sbctl \
>              -- --id=@c create connection \
> @@ -973,6 +981,21 @@ wake_up_ovsdb() {
>    AT_CHECK([kill -CONT $(cat $1/ovsdb-server.pid)])
>  }
>
> +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
> +}
>

nit: Missing new line.


> +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
> +}
> +
>  trim_zeros() {
>      sed 's/\(00\)\{1,\}$//'
>  }
> --
> 2.31.1
>
>
Acked-by: Ales Musil <amusil@redhat.com>

Thanks,
Ales
Mark Michelson April 3, 2024, 4:44 p.m. UTC | #2
Thanks Xavier and Ales. I addresed Ales's finding and pushed this to 
main and all branches back to branch-23.06.

On 3/28/24 04:48, Ales Musil wrote:
> On Tue, Mar 26, 2024 at 12:55 PM Xavier Simonart <xsimonar@redhat.com>
> wrote:
> 
>> Such macros can then be used for instance to create condition where
>> sb is seen as read-only by ovn-controller.
>>
>> Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
>> ---
>>
> 
> Hi Xavier,
> 
> thank you for the v2, there is one small nit that can be addressed during
> merge.
> 
>   tests/ovn-macros.at | 25 ++++++++++++++++++++++++-
>>   1 file changed, 24 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
>> index ed93764d3..bcfd6a521 100644
>> --- a/tests/ovn-macros.at
>> +++ b/tests/ovn-macros.at
>> @@ -220,12 +220,14 @@ ovn_start_northd() {
>>   # options are accepted to adjust that:
>>   #   --backup-northd         Start a backup northd.
>>   #   --backup-northd=paused  Start the backup northd in the paused state.
>> +#   --use-tcp-to-sb         Use tcp to connect to sb.
>>   ovn_start () {
>>       local backup_northd=false
>>       local backup_northd_options=
>>       case $1 in
>>           --backup-northd) backup_northd=true; shift ;;
>>           --backup-northd=paused) backup_northd=true;
>> backup_northd_options=--paused; shift ;;
>> +        --use-tcp-to-sb) use_tcp=true; shift ;;
>>       esac
>>       local AZ=$1
>>       local msg_prefix=${AZ:+$AZ: }
>> @@ -246,7 +248,13 @@ ovn_start () {
>>           ovn_start_northd $backup_northd_options backup $AZ
>>       fi
>>
>> -    if test X$HAVE_OPENSSL = Xyes; then
>> +    if test $use_tcp; then
>> +        # Create the SB DB ptcp connection.
>> +        ovn-sbctl \
>> +            -- --id=@c create connection \
>> +                target=\"ptcp:0:127.0.0.1\" \
>> +            -- add SB_Global . connections @c
>> +    elif test X$HAVE_OPENSSL = Xyes; then
>>           # Create the SB DB pssl+RBAC connection.
>>           ovn-sbctl \
>>               -- --id=@c create connection \
>> @@ -973,6 +981,21 @@ wake_up_ovsdb() {
>>     AT_CHECK([kill -CONT $(cat $1/ovsdb-server.pid)])
>>   }
>>
>> +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
>> +}
>>
> 
> nit: Missing new line.
> 
> 
>> +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
>> +}
>> +
>>   trim_zeros() {
>>       sed 's/\(00\)\{1,\}$//'
>>   }
>> --
>> 2.31.1
>>
>>
> Acked-by: Ales Musil <amusil@redhat.com>
> 
> Thanks,
> Ales
diff mbox series

Patch

diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
index ed93764d3..bcfd6a521 100644
--- a/tests/ovn-macros.at
+++ b/tests/ovn-macros.at
@@ -220,12 +220,14 @@  ovn_start_northd() {
 # options are accepted to adjust that:
 #   --backup-northd         Start a backup northd.
 #   --backup-northd=paused  Start the backup northd in the paused state.
+#   --use-tcp-to-sb         Use tcp to connect to sb.
 ovn_start () {
     local backup_northd=false
     local backup_northd_options=
     case $1 in
         --backup-northd) backup_northd=true; shift ;;
         --backup-northd=paused) backup_northd=true; backup_northd_options=--paused; shift ;;
+        --use-tcp-to-sb) use_tcp=true; shift ;;
     esac
     local AZ=$1
     local msg_prefix=${AZ:+$AZ: }
@@ -246,7 +248,13 @@  ovn_start () {
         ovn_start_northd $backup_northd_options backup $AZ
     fi
 
-    if test X$HAVE_OPENSSL = Xyes; then
+    if test $use_tcp; then
+        # Create the SB DB ptcp connection.
+        ovn-sbctl \
+            -- --id=@c create connection \
+                target=\"ptcp:0:127.0.0.1\" \
+            -- add SB_Global . connections @c
+    elif test X$HAVE_OPENSSL = Xyes; then
         # Create the SB DB pssl+RBAC connection.
         ovn-sbctl \
             -- --id=@c create connection \
@@ -973,6 +981,21 @@  wake_up_ovsdb() {
   AT_CHECK([kill -CONT $(cat $1/ovsdb-server.pid)])
 }
 
+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
+}
+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
+}
+
 trim_zeros() {
     sed 's/\(00\)\{1,\}$//'
 }