From a1408cc3e2551283d502864aeb4bba00ae63d28c Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 28 Nov 2023 17:43:57 +0000 Subject: [PATCH] fmt_pkt: make sure scapy-server is started once 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 Acked-by: Mark Michelson Signed-off-by: Mark Michelson --- tests/ovn-macros.at | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at index 2c92051eac..d9d8d16daf 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() {