From 604e37caa54c033393afa1fd8014052897b9f043 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 4 Oct 2025 05:38:29 +0000 Subject: [PATCH] build: Retry stopping the test server On my system there needs to be a slight pause between stopping and checking to see if SwiftAIO has stopped. Without the pause the tests fail for a non-obvious reason. Instead of using a magic sleep, re-use the retry logic that is used for starting the test server. --- fstest/testserver/testserver.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fstest/testserver/testserver.go b/fstest/testserver/testserver.go index c44cff4be..18e7eabfe 100644 --- a/fstest/testserver/testserver.go +++ b/fstest/testserver/testserver.go @@ -175,7 +175,16 @@ func Start(remoteName string) (fn func(), err error) { if running[name] <= 0 { // if server isn't running check to see if this server has // been started already but not by us and stop it if so - if os.Getenv(envKey(name, "type")) == "" && isRunning(name) { + const maxTries = 10 + for i := 1; i <= maxTries; i++ { + if os.Getenv(envKey(name, "type")) == "" && !isRunning(name) { + fs.Logf(name, "Stopped server") + break + } + if i != 1 { + time.Sleep(time.Second) + fs.Logf(name, "Attempting to stop %s try %d/%d", name, i, maxTries) + } stop(name) } if !isRunning(name) { @@ -211,6 +220,6 @@ func stop(name string) { fs.Errorf(name, "Failed to stop server: %v", err) } running[name] = 0 - fs.Logf(name, "Stopped server") + fs.Logf(name, "Stopping server") } }