From 410537808e65cada29d9688cc75b8d63c7f8d026 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 1 Oct 2024 14:48:06 -0600 Subject: [PATCH] System tests: sdnotify: wait for socket file creation Potential race between starting socat (which creates a socket file) and processes accessing said socket. Or maybe not. I dunno, I'm grasping at straws. This is an elusive flake. Fixes: #23798 (I hope) Signed-off-by: Ed Santiago --- test/system/260-sdnotify.bats | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/system/260-sdnotify.bats b/test/system/260-sdnotify.bats index f5394e7931fe..175588f504cf 100644 --- a/test/system/260-sdnotify.bats +++ b/test/system/260-sdnotify.bats @@ -52,6 +52,16 @@ function _start_socat() { (exec socat unix-recvfrom:"$NOTIFY_SOCKET",fork \ system:"(cat;echo) >> $_SOCAT_LOG" 3>&-) & _SOCAT_PID=$! + + # Wait for socat to create the socket file. This _should_ be + # instantaneous, but can take a few seconds under high load + for try in $(seq 1 10); do + if [[ -e "$NOTIFY_SOCKET" ]]; then + return + fi + sleep 0.5 + done + die "Timed out waiting for socat to create $NOTIFY_SOCKET" } # Stop the socat background process and clean up logs