diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-27 21:57:37 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-27 21:57:37 +0300 |
| commit | 99e99c6ea35ae97e84d727449f9ad7c4c0a9fa23 (patch) | |
| tree | a5c690689719687716186de08f2085352461d2b4 /cmd | |
| parent | 45e02c6754dbc8217713d81d792bfc83e8523505 (diff) | |
Stabilize integration test startup
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/ioworkload/main.go | 38 | ||||
| -rw-r--r-- | cmd/ioworkload/scenario_security.go | 4 |
2 files changed, 39 insertions, 3 deletions
diff --git a/cmd/ioworkload/main.go b/cmd/ioworkload/main.go index 57424e4..525baa5 100644 --- a/cmd/ioworkload/main.go +++ b/cmd/ioworkload/main.go @@ -18,6 +18,8 @@ import ( const ( defaultStartupDelay = 8 * time.Second startupDelayEnv = "IOR_WORKLOAD_STARTUP_DELAY_MS" + startupFileEnv = "IOR_WORKLOAD_STARTUP_FILE" + startupFileTimeout = 30 * time.Second ) func main() { @@ -44,7 +46,10 @@ func main() { } fmt.Println(os.Getpid()) - time.Sleep(configuredStartupDelay()) + if err := waitForStartup(); err != nil { + fmt.Fprintf(os.Stderr, "startup wait failed: %v\n", err) + os.Exit(1) + } if err := run(); err != nil { fmt.Fprintf(os.Stderr, "scenario %s failed: %v\n", *scenario, err) @@ -52,6 +57,37 @@ func main() { } } +func waitForStartup() error { + path := os.Getenv(startupFileEnv) + if path == "" { + time.Sleep(configuredStartupDelay()) + return nil + } + return waitForStartupFile(path) +} + +func waitForStartupFile(path string) error { + deadline := time.NewTimer(startupFileTimeout) + defer deadline.Stop() + + ticker := time.NewTicker(10 * time.Millisecond) + defer ticker.Stop() + + for { + if _, err := os.Stat(path); err == nil { + return nil + } else if !os.IsNotExist(err) { + return err + } + + select { + case <-ticker.C: + case <-deadline.C: + return fmt.Errorf("timeout waiting for %s", path) + } + } +} + func configuredStartupDelay() time.Duration { raw := os.Getenv(startupDelayEnv) if raw == "" { diff --git a/cmd/ioworkload/scenario_security.go b/cmd/ioworkload/scenario_security.go index e9e0fe8..3adef75 100644 --- a/cmd/ioworkload/scenario_security.go +++ b/cmd/ioworkload/scenario_security.go @@ -98,8 +98,8 @@ func runKeySyscalls(nr securitySyscalls) { func runPtraceSyscall(nr securitySyscalls) { _, _, _ = syscall.Syscall6( nr.ptrace, - uintptr(syscall.PTRACE_TRACEME), - 0, + uintptr(syscall.PTRACE_PEEKDATA), + ^uintptr(0), 0, 0, 0, |
