Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
6f8f4aee
Unverified
Commit
6f8f4aee
authored
Jul 23, 2025
by
Simo Lin
Committed by
GitHub
Jul 23, 2025
Browse files
[router] add common ut infra to mock worker and app (#8295)
parent
0c8dab9e
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
709 additions
and
0 deletions
+709
-0
sgl-router/Cargo.toml
sgl-router/Cargo.toml
+3
-0
sgl-router/tests/common/mock_worker.rs
sgl-router/tests/common/mock_worker.rs
+650
-0
sgl-router/tests/common/mod.rs
sgl-router/tests/common/mod.rs
+56
-0
No files found.
sgl-router/Cargo.toml
View file @
6f8f4aee
...
@@ -42,6 +42,9 @@ url = "2.5.4"
...
@@ -42,6 +42,9 @@ url = "2.5.4"
[dev-dependencies]
[dev-dependencies]
criterion
=
{
version
=
"0.5"
,
features
=
["html_reports"]
}
criterion
=
{
version
=
"0.5"
,
features
=
["html_reports"]
}
tokio-stream
=
"0.1"
actix-http
=
"3.0"
futures
=
"0.3"
[[bench]]
[[bench]]
name
=
"request_processing"
name
=
"request_processing"
...
...
sgl-router/tests/common/mock_worker.rs
0 → 100644
View file @
6f8f4aee
This diff is collapsed.
Click to expand it.
sgl-router/tests/common/mod.rs
0 → 100644
View file @
6f8f4aee
pub
mod
mock_worker
;
use
actix_web
::
web
;
use
reqwest
::
Client
;
use
sglang_router_rs
::
config
::{
PolicyConfig
,
RouterConfig
,
RoutingMode
};
use
sglang_router_rs
::
server
::
AppState
;
/// Helper function to create test router configuration
pub
fn
create_test_config
(
worker_urls
:
Vec
<
String
>
)
->
RouterConfig
{
RouterConfig
{
mode
:
RoutingMode
::
Regular
{
worker_urls
},
policy
:
PolicyConfig
::
Random
,
host
:
"127.0.0.1"
.to_string
(),
port
:
3001
,
max_payload_size
:
256
*
1024
*
1024
,
// 256MB
request_timeout_secs
:
600
,
worker_startup_timeout_secs
:
300
,
worker_startup_check_interval_secs
:
10
,
discovery
:
None
,
metrics
:
None
,
log_dir
:
None
,
log_level
:
None
,
}
}
/// Helper function to create test router configuration with no health check
pub
fn
create_test_config_no_workers
()
->
RouterConfig
{
RouterConfig
{
mode
:
RoutingMode
::
Regular
{
worker_urls
:
vec!
[],
},
// Empty to skip health check
policy
:
PolicyConfig
::
Random
,
host
:
"127.0.0.1"
.to_string
(),
port
:
3001
,
max_payload_size
:
256
*
1024
*
1024
,
// 256MB
request_timeout_secs
:
600
,
worker_startup_timeout_secs
:
0
,
// No wait
worker_startup_check_interval_secs
:
10
,
discovery
:
None
,
metrics
:
None
,
log_dir
:
None
,
log_level
:
None
,
}
}
/// Helper function to create test app state
pub
async
fn
create_test_app_state
(
config
:
RouterConfig
)
->
Result
<
web
::
Data
<
AppState
>
,
String
>
{
// Create a non-blocking client
let
client
=
Client
::
builder
()
.timeout
(
std
::
time
::
Duration
::
from_secs
(
config
.request_timeout_secs
))
.build
()
.map_err
(|
e
|
e
.to_string
())
?
;
let
app_state
=
AppState
::
new
(
config
,
client
)
?
;
Ok
(
web
::
Data
::
new
(
app_state
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment