Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions services/orchestrator/internal/manager/worker_cap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package manager
import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"sync"
"testing"

Expand Down Expand Up @@ -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
Expand Down
Loading