mirror of https://github.com/rclone/rclone
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.
This commit is contained in:
parent
b249d384b9
commit
604e37caa5
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue