CountBdDaemons() was using `bd daemon list --json` which triggers daemon auto-start as a side effect. During shutdown verification, this caused a new daemon to spawn after all daemons were killed, resulting in "bd daemon shutdown incomplete: 1 still running" error. Replaced all `bd daemon killall` calls with pkill in: - stopBdDaemons() - restartBdDaemons() Changed CountBdDaemons() to use pgrep instead of bd daemon list. Also removed the now-unused parseBdDaemonCount helper function and its tests.
34 lines
776 B
Go
34 lines
776 B
Go
package beads
|
|
|
|
import (
|
|
"os/exec"
|
|
"testing"
|
|
)
|
|
|
|
func TestCountBdActivityProcesses(t *testing.T) {
|
|
count := CountBdActivityProcesses()
|
|
if count < 0 {
|
|
t.Errorf("count should be non-negative, got %d", count)
|
|
}
|
|
}
|
|
|
|
func TestCountBdDaemons(t *testing.T) {
|
|
if _, err := exec.LookPath("bd"); err != nil {
|
|
t.Skip("bd not installed")
|
|
}
|
|
count := CountBdDaemons()
|
|
if count < 0 {
|
|
t.Errorf("count should be non-negative, got %d", count)
|
|
}
|
|
}
|
|
|
|
func TestStopAllBdProcesses_DryRun(t *testing.T) {
|
|
daemonsKilled, activityKilled, err := StopAllBdProcesses(true, false)
|
|
if err != nil {
|
|
t.Errorf("unexpected error: %v", err)
|
|
}
|
|
if daemonsKilled < 0 || activityKilled < 0 {
|
|
t.Errorf("counts should be non-negative: daemons=%d, activity=%d", daemonsKilled, activityKilled)
|
|
}
|
|
}
|