Skip to content

Commit de716ff

Browse files
committed
feat: add dynamic port allocation to prevent test conflicts
Add centralized port allocation utilities and update all tests and launch scripts to use available ports instead of hard-coded ports (8000, 8081, 8082). This prevents port conflicts and enables parallel test execution in the future. Changes: - Add tests/utils/port_utils.py with get_free_port(), get_free_ports(), and helper functions for test configuration - Update fault tolerance cancellation tests to dynamically allocate both frontend and worker ports - Update DynamoFrontendProcess and request functions to accept dynamic frontend_port instead of hard-coded FRONTEND_PORT constant - Modify backend launch scripts to respect environment variables DYN_FRONTEND_PORT and DYN_SYSTEM_PORT with fallback to defaults Signed-off-by: Keiven Chang <[email protected]>
1 parent 72b0aec commit de716ff

39 files changed

+441
-130
lines changed

examples/backends/sglang/launch/agg.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ trap cleanup EXIT INT TERM
1313

1414

1515
# run ingress
16-
python3 -m dynamo.frontend --http-port=8000 &
16+
python3 -m dynamo.frontend --http-port=${DYN_FRONTEND_PORT:-8000} &
1717
DYNAMO_PID=$!
1818

1919
# run worker with metrics enabled
20-
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=8081 \
20+
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT:-8081} \
2121
python3 -m dynamo.sglang \
2222
--model-path Qwen/Qwen3-0.6B \
2323
--served-model-name Qwen/Qwen3-0.6B \

examples/backends/sglang/launch/agg_embed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trap cleanup EXIT INT TERM
1313

1414

1515
# run ingress
16-
python3 -m dynamo.frontend --http-port=8000 &
16+
python3 -m dynamo.frontend --http-port=${DYN_FRONTEND_PORT:-8000} &
1717
DYNAMO_PID=$!
1818

1919
# run worker

examples/backends/sglang/launch/agg_router.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trap cleanup EXIT INT TERM
1313

1414

1515
# run ingress
16-
python -m dynamo.frontend --router-mode kv --http-port=8000 &
16+
python -m dynamo.frontend --router-mode kv --http-port=${DYN_FRONTEND_PORT:-8000} &
1717
DYNAMO_PID=$!
1818

1919
# run worker

examples/backends/sglang/launch/disagg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trap cleanup EXIT INT TERM
1313

1414

1515
# run ingress
16-
python3 -m dynamo.frontend --http-port=8000 &
16+
python3 -m dynamo.frontend --http-port=${DYN_FRONTEND_PORT:-8000} &
1717
DYNAMO_PID=$!
1818

1919
# run prefill worker

examples/backends/sglang/launch/disagg_dp_attn.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trap cleanup EXIT INT TERM
1313

1414

1515
# run ingress
16-
python3 -m dynamo.frontend --http-port=8000 &
16+
python3 -m dynamo.frontend --http-port=${DYN_FRONTEND_PORT:-8000} &
1717
DYNAMO_PID=$!
1818

1919
# run prefill worker

examples/backends/sglang/launch/disagg_router.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trap cleanup EXIT INT TERM
1313

1414
# run ingress
1515
python3 -m dynamo.frontend \
16-
--http-port=8000 \
16+
--http-port=${DYN_FRONTEND_PORT:-8000} \
1717
--router-mode kv \
1818
--kv-overlap-score-weight 0 \
1919
--router-reset-states &

examples/backends/sglang/launch/disagg_same_gpu.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ trap cleanup EXIT INT TERM
3737

3838

3939
# run ingress with KV router mode for disaggregated setup
40-
python3 -m dynamo.frontend --router-mode kv --http-port=8000 &
40+
python3 -m dynamo.frontend --router-mode kv --http-port=${DYN_FRONTEND_PORT:-8000} &
4141
DYNAMO_PID=$!
4242

4343
# run prefill worker with metrics on port 8081
44-
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=8081 \
44+
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT1:-8081} \
4545
python3 -m dynamo.sglang \
4646
--model-path Qwen/Qwen3-0.6B \
4747
--served-model-name Qwen/Qwen3-0.6B \
@@ -71,7 +71,7 @@ echo "Waiting for prefill worker to initialize..."
7171
sleep 5
7272

7373
# run decode worker with metrics on port 8082 (foreground)
74-
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=8082 \
74+
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT2:-8082} \
7575
python3 -m dynamo.sglang \
7676
--model-path Qwen/Qwen3-0.6B \
7777
--served-model-name Qwen/Qwen3-0.6B \

examples/backends/sglang/launch/multimodal_agg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if [[ -n "$SERVED_MODEL_NAME" ]]; then
6060
fi
6161

6262
# run ingress
63-
python3 -m dynamo.frontend --http-port=8000 &
63+
python3 -m dynamo.frontend --http-port=${DYN_FRONTEND_PORT:-8000} &
6464
DYNAMO_PID=$!
6565

6666
# run SGLang multimodal processor

examples/backends/sglang/launch/multimodal_disagg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if [[ -n "$SERVED_MODEL_NAME" ]]; then
6060
fi
6161

6262
# run ingress
63-
python3 -m dynamo.frontend --http-port=8000 &
63+
python3 -m dynamo.frontend --http-port=${DYN_FRONTEND_PORT:-8000} &
6464
DYNAMO_PID=$!
6565

6666
# run SGLang multimodal processor

examples/backends/trtllm/launch/agg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trap cleanup EXIT INT TERM
2222

2323

2424
# run frontend
25-
python3 -m dynamo.frontend --http-port 8000 &
25+
python3 -m dynamo.frontend --http-port ${DYN_FRONTEND_PORT:-8000} &
2626
DYNAMO_PID=$!
2727

2828
# run worker

0 commit comments

Comments
 (0)