-
Notifications
You must be signed in to change notification settings - Fork 13
Revert "scheduler: fix executor allocation for non-gang policies and gang batch semantics (#500)" #508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "scheduler: fix executor allocation for non-gang policies and gang batch semantics (#500)" #508
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,24 +225,16 @@ pub trait Shim: Send + 'static { | |
| async fn on_session_leave(&mut self) -> Result<(), FlameError>; | ||
| } | ||
|
|
||
| /// Single process-wide lock shared by all shims submodule tests. | ||
| /// | ||
| /// `shims::tests` and `shims::grpc_shim::tests` both mutate global process state | ||
| /// (`FLAME_SOCKET_DIR` env var, current directory). Using a single lock prevents | ||
| /// those tests from racing each other when the test binary runs them in parallel. | ||
| /// | ||
| /// Use `lock().unwrap_or_else(|e| e.into_inner())` so that a panic in one test | ||
| /// does not permanently poison the lock and block all subsequent tests. | ||
| #[cfg(test)] | ||
| pub(crate) static SHIMS_TEST_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use std::collections::HashMap; | ||
| use std::fs::File; | ||
| use std::sync::Mutex; | ||
| use tempfile::tempdir; | ||
|
|
||
| static TEST_LOCK: Mutex<()> = Mutex::new(()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverting the shared Both test modules modify the same global process-wide state:
Since Cargo runs tests in parallel across multiple threads by default, these tests will run concurrently and interfere with each other's environment and working directory, leading to flaky test failures. A single process-wide lock should be shared across all shim tests to prevent parallel execution of tests that mutate global state. |
||
|
|
||
| fn create_test_app(name: &str, working_directory: Option<String>) -> ApplicationContext { | ||
| ApplicationContext { | ||
| name: name.to_string(), | ||
|
|
@@ -267,7 +259,7 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_executor_work_dir_with_auto_dir() { | ||
| let _guard = SHIMS_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); | ||
| let _guard = TEST_LOCK.lock().unwrap(); | ||
| let temp = tempdir().unwrap(); | ||
| let socket_dir = setup_test_env(&temp); | ||
|
|
||
|
|
@@ -288,7 +280,7 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_executor_work_dir_with_custom_working_directory() { | ||
| let _guard = SHIMS_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); | ||
| let _guard = TEST_LOCK.lock().unwrap(); | ||
| let temp = tempdir().unwrap(); | ||
| let socket_dir = setup_test_env(&temp); | ||
| let custom_dir = temp.path().join("custom-workdir"); | ||
|
|
@@ -309,7 +301,7 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_executor_work_dir_socket_path_length() { | ||
| let _guard = SHIMS_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); | ||
| let _guard = TEST_LOCK.lock().unwrap(); | ||
| let temp = tempdir().unwrap(); | ||
| setup_test_env(&temp); | ||
|
|
||
|
|
@@ -329,7 +321,7 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_executor_work_dir_cleanup_on_drop() { | ||
| let _guard = SHIMS_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); | ||
| let _guard = TEST_LOCK.lock().unwrap(); | ||
| let temp = tempdir().unwrap(); | ||
| setup_test_env(&temp); | ||
|
|
||
|
|
@@ -363,7 +355,7 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_executor_work_dir_no_cleanup_custom_dir_on_drop() { | ||
| let _guard = SHIMS_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); | ||
| let _guard = TEST_LOCK.lock().unwrap(); | ||
| let temp = tempdir().unwrap(); | ||
| setup_test_env(&temp); | ||
| let custom_dir = temp.path().join("persistent-workdir"); | ||
|
|
@@ -390,7 +382,7 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_socket_path_is_fixed_location() { | ||
| let _guard = SHIMS_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); | ||
| let _guard = TEST_LOCK.lock().unwrap(); | ||
| let temp = tempdir().unwrap(); | ||
| let socket_dir = setup_test_env(&temp); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverting the shared
SHIMS_TEST_LOCKand replacing it with a localTEST_LOCKintroduces a race condition between tests ingrpc_shim.rsandshims/mod.rs.Both test modules modify the same global process-wide state:
FLAME_SOCKET_DIRviastd::env::set_var.std::env::set_current_dir.Since Cargo runs tests in parallel across multiple threads by default, these tests will run concurrently and interfere with each other's environment and working directory, leading to flaky test failures. A single process-wide lock should be shared across all shim tests to prevent parallel execution of tests that mutate global state.