Skip to content

Commit f111403

Browse files
committed
fix: rid flakiness of integration tests
1 parent 084e79a commit f111403

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

crates/base/src/commands.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub async fn start_server(
1616
user_worker_policy: Option<WorkerPoolPolicy>,
1717
import_map_path: Option<String>,
1818
no_module_cache: bool,
19+
no_signal_handler: bool,
1920
callback_tx: Option<Sender<ServerCodes>>,
2021
entrypoints: WorkerEntrypoints,
2122
) -> Result<(), Error> {
@@ -34,6 +35,7 @@ pub async fn start_server(
3435
user_worker_policy,
3536
import_map_path,
3637
no_module_cache,
38+
no_signal_handler,
3739
callback_tx,
3840
entrypoints,
3941
)

crates/base/src/macros/test_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ macro_rules! integration_test {
2727
None,
2828
None,
2929
false,
30+
true,
3031
Some(tx.clone()),
3132
$crate::server::WorkerEntrypoints {
3233
main: None,

crates/base/src/rt_worker/supervisor/strategy_per_worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub async fn supervise(args: Arguments) -> ShutdownReason {
2424
req: (_, mut req_end_rx),
2525
} = timing.unwrap_or_default();
2626

27-
let is_retired = is_retired.unwrap();
27+
let is_retired = is_retired.unwrap_or_default();
2828

2929
let mut cpu_time_soft_limit_reached = false;
3030
let mut wall_clock_alerts = 0;

crates/base/src/rt_worker/worker_ctx.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ pub fn create_supervisor(
122122
let (cpu_alarms_tx, cpu_alarms_rx) = mpsc::unbounded_channel::<()>();
123123

124124
(
125-
if !cfg!(test) && conf.cpu_time_soft_limit_ms != 0 && conf.cpu_time_hard_limit_ms != 0 {
125+
if conf.cpu_time_soft_limit_ms != 0 && conf.cpu_time_hard_limit_ms != 0 {
126126
Some(CPUTimer::start(
127127
if supervisor_policy.is_per_worker() {
128128
conf.cpu_time_soft_limit_ms
@@ -174,12 +174,11 @@ pub fn create_supervisor(
174174
}
175175
};
176176

177-
if !cfg!(test) {
178-
// NOTE: It's not a big deal in unit testing because it is nothing
179-
// but sending just a message to the pooler that it is the user
180-
// worker going disposed down and will not accept awaiting
181-
// subsequent requests and they must be re-polled again.
182-
cancel.as_ref().unwrap().notify_waiters();
177+
// NOTE: Sending a signal to the pooler that it is the user worker going
178+
// disposed down and will not accept awaiting subsequent requests, so
179+
// they must be re-polled again.
180+
if let Some(cancel) = cancel.as_ref() {
181+
cancel.notify_waiters();
183182
}
184183

185184
// NOTE: If we issue a hard CPU time limit, It's OK because it is

crates/base/src/server.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ impl Server {
171171
maybe_user_worker_policy: Option<WorkerPoolPolicy>,
172172
import_map_path: Option<String>,
173173
no_module_cache: bool,
174+
no_signal_handler: bool,
174175
callback_tx: Option<Sender<ServerCodes>>,
175176
entrypoints: WorkerEntrypoints,
176177
) -> Result<Self, Error> {
@@ -212,7 +213,7 @@ impl Server {
212213
)
213214
.await?;
214215

215-
if !cfg!(test) {
216+
if !no_signal_handler {
216217
// register alarm signal handler
217218
cpu_timer::register_alarm()?;
218219
}

crates/cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ fn main() -> Result<(), anyhow::Error> {
167167
)),
168168
import_map_path,
169169
no_module_cache,
170+
cfg!(not(target_os = "linux")),
170171
None,
171172
WorkerEntrypoints {
172173
main: maybe_main_entrypoint,

0 commit comments

Comments
 (0)