diff mbox series

[ovs-dev,v2,4/4] fmt_pkt: make sure scapy-server is started once

Message ID 20231128174357.1233186-5-ihrachys@redhat.com
State Accepted
Headers show
Series misc fmt_pkt improvements | expand

Checks

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

Commit Message

Ihar Hrachyshka Nov. 28, 2023, 5:43 p.m. UTC
When running fmt_pkt in parallel, before the patch, there could be
several attempts to start scapy-server. Using flock on a test case
specific file should guarantee that only one of the subshells will
actually be able to start a daemon, which is designed to be a singleton.

Now that start_scapy_server doesn't necessarily start a server (only the
first lucky subshell will do), wait for server socket file before
proceeding with ovs-appctl call.

Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
---
 tests/ovn-macros.at | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
index 21c314c7c..633ef05f8 100644
--- a/tests/ovn-macros.at
+++ b/tests/ovn-macros.at
@@ -876,6 +876,7 @@  fmt_pkt() {
     if [[ ! -S $ctlfile ]]; then
         start_scapy_server
     fi
+    while [[ ! -S $ctlfile ]]; do sleep 0.1; done
     ovs-appctl -t $ctlfile payload "$1"
 }
 
@@ -883,10 +884,11 @@  start_scapy_server() {
     pidfile=$ovs_base/scapy.pid
     ctlfile=$ovs_base/scapy.ctl
     logfile=$ovs_base/scapy.log
+    lockfile=$ovs_base/scapy.lock
 
-    "$top_srcdir"/tests/scapy-server.py \
-        --pidfile=$pidfile --unixctl=$ctlfile --log-file=$logfile --detach
-    on_exit "test -e \"$pidfile\" && ovs-appctl -t $ctlfile exit"
+    flock -n $lockfile "$top_srcdir"/tests/scapy-server.py \
+        --pidfile=$pidfile --unixctl=$ctlfile --log-file=$logfile --detach \
+    && on_exit "test -e \"$pidfile\" && ovs-appctl -t $ctlfile exit"
 }
 
 sleep_sb() {