From f0e9e10fa76f920756bd9a9e031ed110a5431d1c Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Tue, 28 Apr 2026 16:22:33 +0200 Subject: [PATCH] Revert "wrapper fix: kill all opencloud and nats processes" This reverts commit 62674c71cff594fcd4a6f10dbca1d28142ab78f0. --- tests/ocwrapper/opencloud/opencloud.go | 34 +++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/ocwrapper/opencloud/opencloud.go b/tests/ocwrapper/opencloud/opencloud.go index 86e0ac8379..3191c82dd4 100644 --- a/tests/ocwrapper/opencloud/opencloud.go +++ b/tests/ocwrapper/opencloud/opencloud.go @@ -121,10 +121,19 @@ func Stop() (bool, string) { return true, "OpenCloud server is not running" } - exec.Command("sh", "-c", "pkill -9 -f 'opencloud|nats-server' 2>/dev/null || true").Run() - + err := cmd.Process.Signal(syscall.SIGINT) + if err != nil { + if !strings.HasSuffix(err.Error(), "process already finished") { + log.Fatalln(err) + } else { + return true, "OpenCloud server is already stopped" + } + } + cmd.Process.Wait() + success, message := waitUntilCompleteShutdown() + cmd = nil - return true, "OpenCloud server stopped successfully" + return success, message } func Restart(envMap []string) (bool, string) { @@ -144,7 +153,24 @@ func IsOpencloudRunning() bool { return false } +func waitAllServices(startTime time.Time, timeout time.Duration) { + timeoutS := timeout * time.Second + + c := exec.Command(config.Get("bin"), "list") + _, err := c.CombinedOutput() + if err != nil { + if time.Since(startTime) <= timeoutS { + time.Sleep(500 * time.Millisecond) + waitAllServices(startTime, timeout) + } + return + } + log.Println("All services are up") +} + func WaitForConnection() (bool, string) { + waitAllServices(time.Now(), 30) + transport := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } @@ -188,7 +214,7 @@ func WaitForConnection() (bool, string) { } func waitUntilCompleteShutdown() (bool, string) { - timeout := 45 * time.Second + timeout := 30 * time.Second startTime := time.Now() c := exec.Command("sh", "-c", "ps ax | grep 'opencloud server' | grep -v grep | awk '{print $1}'")