Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ostool-server/src/api/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
26 changes: 23 additions & 3 deletions ostool-server/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<std::io::Result<tokio_modbus::server::Terminated>>;
Expand Down