diff mbox series

[ovs-dev,1/8] tests: Cleanup on_exit commands.

Message ID 20240604131042.825909-2-xsimonar@redhat.com
State Accepted
Headers show
Series Flaky tests fixes and tests cleanup. | 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 June 4, 2024, 1:10 p.m. UTC
Avoid unnecessary errors trying to stop already stopped processes,
or removing already removed datapath.
Tests were not failing due to this, but potentially confusing errors
were logged.

Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
---
 tests/ofproto-macros.at     | 2 +-
 tests/system-kmod-macros.at | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 31a067c1e..b0a05baf2 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -196,7 +196,7 @@  m4_define([_OVS_VSWITCHD_START],
 
    dnl Start ovsdb-server.
    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
-   on_exit "kill `cat ovsdb-server.pid`"
+   on_exit "test -e `cat ovsdb-server.pid` && kill `cat ovsdb-server.pid`"
    AT_CHECK([[sed < stderr '
 /vlog|INFO|opened log file/d
 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
diff --git a/tests/system-kmod-macros.at b/tests/system-kmod-macros.at
index 6f6670199..ec23c55cf 100644
--- a/tests/system-kmod-macros.at
+++ b/tests/system-kmod-macros.at
@@ -22,8 +22,8 @@  m4_define([OVS_TRAFFIC_VSWITCHD_START],
               [modprobe -q mod || echo "Module mod not loaded."
                on_exit 'modprobe -q -r mod'
               ])
-   on_exit 'ovs-dpctl del-dp ovs-system'
-   on_exit 'ovs-appctl dpctl/flush-conntrack'
+   on_exit 'ovs-dpctl show | grep ovs-system && ovs-dpctl del-dp ovs-system'
+   on_exit 'test -e $OVS_RUNDIR/ovs-vswitchd.pid && ovs-appctl dpctl/flush-conntrack'
    _OVS_VSWITCHD_START([])
    dnl Add bridges, ports, etc.
    AT_CHECK([ovs-vsctl -- _ADD_BR([br0]) -- $1 m4_if([$2], [], [], [| uuidfilt])], [0], [$2])