From 7fb737ccbf8478d64b373e68574cc40d409ce7ca Mon Sep 17 00:00:00 2001 From: setkyar Date: Fri, 28 Aug 2026 02:48:42 +0700 Subject: [PATCH] test(orchestrator): keep worker cap fixtures alive --- .../orchestrator/internal/manager/worker_cap_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/orchestrator/internal/manager/worker_cap_test.go b/services/orchestrator/internal/manager/worker_cap_test.go index 3568bf05..f03a03fb 100644 --- a/services/orchestrator/internal/manager/worker_cap_test.go +++ b/services/orchestrator/internal/manager/worker_cap_test.go @@ -3,7 +3,9 @@ package manager import ( "context" "fmt" + "os" "os/exec" + "path/filepath" "sync" "testing" @@ -79,11 +81,16 @@ func TestSpawnWorker_ConcurrentAdmissionRespectsLimit(t *testing.T) { t.Skip("timing test") } - m := New(Config{WhatsAppBinaryPath: "/bin/sh", MaxWorkers: 3}) + workerPath := filepath.Join(t.TempDir(), "long-running-worker") + require.NoError(t, os.WriteFile(workerPath, []byte("#!/bin/sh\nsleep 60\n"), 0o700)) + + m := New(Config{WhatsAppBinaryPath: workerPath, MaxWorkers: 3}) m.ctx, m.cancel = context.WithCancel(context.Background()) defer m.cancel() - // Use real short-lived processes so cmd.Start() succeeds. + // Keep admitted processes alive until every concurrent request reaches the + // admission gate. A short-lived command can exit and free its slot before + // the remaining requests arrive, which tests throughput instead of the cap. var wg sync.WaitGroup var mu sync.Mutex var admitted, rejected int