From 74e8c207c4ca020a95204fda3647826e0b8565b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E7=9D=BF?= Date: Tue, 16 Jun 2026 10:43:58 +0800 Subject: [PATCH] fix(ostool-server): extend Zhongsheng release delay --- ostool-server/src/api/router.rs | 4 +++- ostool-server/src/state.rs | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ostool-server/src/api/router.rs b/ostool-server/src/api/router.rs index 9c6c5707..f323d0e1 100644 --- a/ostool-server/src/api/router.rs +++ b/ostool-server/src/api/router.rs @@ -2932,7 +2932,9 @@ mod tests { Some(session_id.as_str()) ); - tokio::time::sleep(std::time::Duration::from_millis(2300)).await; + let zhongsheng_release_settle_delay = std::time::Duration::from_secs(10); + tokio::time::sleep(zhongsheng_release_settle_delay + std::time::Duration::from_millis(300)) + .await; let session_response = app .clone() diff --git a/ostool-server/src/state.rs b/ostool-server/src/state.rs index 8a342c59..5e01ab6e 100644 --- a/ostool-server/src/state.rs +++ b/ostool-server/src/state.rs @@ -23,8 +23,8 @@ use crate::{ const RELEASE_RETRY_ATTEMPTS: usize = 3; const RELEASE_RETRY_DELAY: Duration = Duration::from_millis(200); const RELEASE_WAIT_TIMEOUT: Duration = Duration::from_secs(2); -const RELEASE_COMPLETION_TIMEOUT: Duration = Duration::from_secs(8); -const ZHONGSHENG_RELEASE_SETTLE_DELAY: Duration = Duration::from_secs(2); +const RELEASE_COMPLETION_TIMEOUT: Duration = Duration::from_secs(12); +const ZHONGSHENG_RELEASE_SETTLE_DELAY: Duration = Duration::from_secs(10); #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "snake_case")] @@ -616,7 +616,8 @@ mod tests { }; use super::{ - BoardLeaseState, TouchSessionError, ZHONGSHENG_RELEASE_SETTLE_DELAY, build_app_state, + BoardLeaseState, RELEASE_COMPLETION_TIMEOUT, TouchSessionError, + ZHONGSHENG_RELEASE_SETTLE_DELAY, build_app_state, release_settle_delay, }; use crate::{ ServerConfig, @@ -648,6 +649,25 @@ mod tests { } } + #[test] + fn zhongsheng_release_settle_delay_is_ten_seconds() { + let mut board = sample_board("relay-board"); + board.power_management = + PowerManagementConfig::ZhongshengRelay(ZhongshengRelayPowerManagement { + key: SerialPortKey { + kind: SerialPortKeyKind::UsbPath, + value: "/dev/ttyUSB0".into(), + }, + }); + + assert_eq!(release_settle_delay(&board), Some(Duration::from_secs(10))); + } + + #[test] + fn release_completion_timeout_covers_zhongsheng_settle_delay() { + assert!(RELEASE_COMPLETION_TIMEOUT > ZHONGSHENG_RELEASE_SETTLE_DELAY); + } + #[cfg(unix)] type RelayServerHandle = tokio::task::JoinHandle>;