Design System to Execute Test Binaries from User Machines on Worker Machines
Problem Statement
Design a system that allows users to upload test binaries (e.g., executables, test scripts, or automation suites) from their local machines, which will then be executed on a pool of worker machines managed by the system.
The system should handle:
This system simulates how large-scale CI/CD or test execution platforms (like Jenkins, Bazel Remote Executors, or Nutanix Test Orchestrators) manage distributed workloads.
🧩 Context
In large engineering setups, test workloads need to be executed in distributed environments — user machines can’t handle heavy compute loads or consistent environments.
Your system should allow:
This is an LLD problem, so focus on class structure, components, and their interactions.
✅ Functional Requirements
⚙️ Non-Functional Requirements
AspectDescription
Scalability
Should support hundreds of concurrent jobs.
Reliability
Ensure no job is lost; retry mechanism on failure.
Extensibility
Add new worker types or job priorities easily.
Maintainability
Use modular, SOLID class design.
Concurrency
Multiple workers can run jobs simultaneously.
🧱 Core Components / Classes
ComponentResponsibility
UserClient
Interface for users to submit test binaries and request status.
JobManager
Handles job lifecycle — creation, tracking, and state transitions.
JobQueue
Holds pending jobs waiting for workers.
WorkerManager
Tracks available worker machines and assigns jobs.
Worker
Executes assigned test binaries, reports back results.
Scheduler
Decides which job goes to which worker (based on load, availability).
ResultStore
Persists execution results and logs for retrieval.
NotificationService
Notifies users when jobs complete or fail.
🧾 Class Diagram (Text Representation)
1
2┌────────────────────────┐
3│ UserClient │
4│────────────────────────│
5│ + submitJob(file): Job │
6│ + getJobStatus(id): Status │
7│ + getResult(id): Result │
8└─────────────┬──────────┘
9 │
10 ▼
11┌────────────────────────┐
12│ JobManager │
13│────────────────────────│
14│ + createJob(file): Job │
15│ + updateJobStatus(id, status): void │
16│ + getJob(id): Job │
17└─────────────┬──────────┘
18 │
19 ▼
20┌────────────────────────┐
21│ JobQueue │
22│────────────────────────│
23│ + enqueue(job): void │
24│ + dequeue(): Job │
25│ + isEmpty(): bool │
26└─────────────┘
27
28┌────────────────────────┐
29│ Scheduler │
30│────────────────────────│
31│ + assignJob(job): void │
32│ + pickWorker(): Worker │
33└─────────────┬──────────┘
34 │
35 ▼
36┌────────────────────────┐
37│ Worker │
38│────────────────────────│
39│ + id: String │
40│ + status: WorkerStatus │
41│ + execute(job): Result │
42└────────────────────────┘
43
44┌────────────────────────┐
45│ WorkerManager │
46│────────────────────────│
47│ + register(worker): void │
48│ + getAvailableWorker(): Worker │
49│ + markBusy(worker): void │
50│ + markFree(worker): void │
51└────────────────────────┘
52
53┌────────────────────────┐
54│ ResultStore │
55│────────────────────────│
56│ + saveResult(job, result): void │
57│ + getResult(jobId): Result │
58└────────────────────────┘🔄 Workflow Example
🧩 Key Entities
EntityAttributesDescription
Job
id, filePath, status, assignedWorker, timestamp
Represents one test binary execution task.
Worker
id, status, capacity, ipAddress
Represents a machine that executes jobs.
Result
jobId, status, outputLogs, executionTime
Captures the execution result of a job.
🧠 Design Patterns Used
PatternPurpose
Observer Pattern
Notify users when job state changes.
Strategy Pattern
Allow different scheduling strategies (e.g., round-robin, least-loaded).
Singleton Pattern
For JobManager and WorkerManager to maintain consistent system state.
Command Pattern
Represent each job execution as a command object.
Factory Pattern
For creating worker or job instances dynamically.
⚙️ Example Scenario
1
2User uploads: test_suite_v2.tar.gz
3
4🟢 Step 1: Job Created
5Job ID: 1234 | Status: PENDING
6
7🟡 Step 2: Scheduler assigns worker
8Worker: worker-node-05 | Status: BUSY
9
10🟣 Step 3: Execution
11Worker downloads test_suite_v2.tar.gz
12Runs test binary -> Captures output logs
13Result: SUCCESS | Duration: 42s
14
15🔵 Step 4: User retrieves results
16Job ID: 1234 | Status: COMPLETED | Logs: test_suite_v2_output.log💬 Discussion Points for Interview
🧠 Possible Extensions
✅ Final Summary
Problem Statement:
Design a system to execute test binaries uploaded by users on a pool of worker machines. The system should manage job scheduling, worker allocation, execution tracking, and result reporting, ensuring scalability, fault tolerance, and ease of extension.