Skip to content

Commit a4ce182

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]> Fix port allocation issues and rename to DYN_HTTP_PORT - Rename DYN_FRONTEND_PORT to DYN_HTTP_PORT to match actual frontend env var - Export DYN_HTTP_PORT in all cancellation tests so workers know frontend port - Fix TensorRT-LLM disagg_same_gpu.sh port conflict (prefill used PORT2, now uses PORT1) Signed-off-by: Keiven Chang <[email protected]> Remove redundant --http-port flag from frontend launch commands dynamo.frontend already reads DYN_HTTP_PORT env var and defaults to 8000, so explicit --http-port=${DYN_HTTP_PORT:-8000} flag is redundant. Add comment to clarify this behavior for maintainability. Signed-off-by: Keiven Chang <[email protected]>
1 parent 4765d88 commit a4ce182

40 files changed

+645
-123
lines changed

examples/backends/sglang/launch/agg.sh

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

1414

1515
# run ingress
16-
python3 -m dynamo.frontend --http-port=8000 &
16+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
17+
python3 -m dynamo.frontend &
1718
DYNAMO_PID=$!
1819

1920
# run worker with metrics enabled
20-
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=8081 \
21+
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT:-8081} \
2122
python3 -m dynamo.sglang \
2223
--model-path Qwen/Qwen3-0.6B \
2324
--served-model-name Qwen/Qwen3-0.6B \

examples/backends/sglang/launch/agg_embed.sh

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

1414

1515
# run ingress
16-
python3 -m dynamo.frontend --http-port=8000 &
16+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
17+
python3 -m dynamo.frontend &
1718
DYNAMO_PID=$!
1819

1920
# run worker

examples/backends/sglang/launch/agg_router.sh

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

1414

1515
# run ingress
16-
python -m dynamo.frontend --router-mode kv --http-port=8000 &
16+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
17+
python -m dynamo.frontend --router-mode kv &
1718
DYNAMO_PID=$!
1819

1920
# run worker

examples/backends/sglang/launch/disagg.sh

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

1414

1515
# run ingress
16-
python3 -m dynamo.frontend --http-port=8000 &
16+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
17+
python3 -m dynamo.frontend &
1718
DYNAMO_PID=$!
1819

1920
# run prefill worker

examples/backends/sglang/launch/disagg_dp_attn.sh

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

1414

1515
# run ingress
16-
python3 -m dynamo.frontend --http-port=8000 &
16+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
17+
python3 -m dynamo.frontend &
1718
DYNAMO_PID=$!
1819

1920
# 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_HTTP_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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ 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+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
41+
python3 -m dynamo.frontend --router-mode kv &
4142
DYNAMO_PID=$!
4243

4344
# run prefill worker with metrics on port 8081
44-
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=8081 \
45+
DYN_SYSTEM_ENABLED=true DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT1:-8081} \
4546
python3 -m dynamo.sglang \
4647
--model-path Qwen/Qwen3-0.6B \
4748
--served-model-name Qwen/Qwen3-0.6B \
@@ -71,7 +72,7 @@ echo "Waiting for prefill worker to initialize..."
7172
sleep 5
7273

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

examples/backends/sglang/launch/multimodal_agg.sh

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

6262
# run ingress
63-
python3 -m dynamo.frontend --http-port=8000 &
63+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
64+
python3 -m dynamo.frontend &
6465
DYNAMO_PID=$!
6566

6667
# run SGLang multimodal processor

examples/backends/sglang/launch/multimodal_disagg.sh

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

6262
# run ingress
63-
python3 -m dynamo.frontend --http-port=8000 &
63+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
64+
python3 -m dynamo.frontend &
6465
DYNAMO_PID=$!
6566

6667
# run SGLang multimodal processor

examples/backends/trtllm/launch/agg.sh

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

2323

2424
# run frontend
25-
python3 -m dynamo.frontend --http-port 8000 &
25+
# DYN_HTTP_PORT env var is read by dynamo.frontend (defaults to 8000 if not set)
26+
python3 -m dynamo.frontend &
2627
DYNAMO_PID=$!
2728

2829
# run worker

0 commit comments

Comments
 (0)