Skip to content

Commit 77eceae

Browse files
committed
test(windows): verify process and PEM portably
Signed-off-by: Drew Newberry <[email protected]>
1 parent fffb26d commit 77eceae

2 files changed

Lines changed: 10 additions & 21 deletions

File tree

‎crates/openshell-driver-mxc/src/driver.rs‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,10 +1046,7 @@ mod lifecycle_tests {
10461046
// Positive proof: the in-policy write materializes the host artifact.
10471047
let host_path = std::path::Path::new(tmp.path()).join("hello.txt");
10481048
let mut found = false;
1049-
// PowerShell startup can be slow on a cold or heavily loaded Windows
1050-
// runner. Wait long enough to distinguish startup latency from a child
1051-
// that never executed.
1052-
for _ in 0..400 {
1049+
for _ in 0..100 {
10531050
if host_path.exists() {
10541051
found = true;
10551052
break;
@@ -1195,12 +1192,11 @@ mod lifecycle_tests {
11951192
async fn stop_terminates_and_reaps_a_running_process_container() {
11961193
let tmp = tempfile::tempdir().unwrap();
11971194
let share = tmp.path().to_string_lossy().replace('\\', "/");
1198-
let marker = format!("{share}/started.txt");
11991195
let command = vec![
12001196
"powershell".into(),
12011197
"-NoProfile".into(),
12021198
"-Command".into(),
1203-
format!("Set-Content -LiteralPath '{marker}' -Value started; Start-Sleep -Seconds 60"),
1199+
"Start-Sleep -Seconds 60".into(),
12041200
];
12051201
let backend = MxcComputeBackend::new_mocked(MxcComputeConfig::default());
12061202
backend
@@ -1217,17 +1213,9 @@ mod lifecycle_tests {
12171213
})
12181214
.await
12191215
.expect("long-running child should start");
1220-
let marker_path = std::path::Path::new(tmp.path()).join("started.txt");
1221-
for _ in 0..100 {
1222-
if marker_path.exists() {
1223-
break;
1224-
}
1225-
tokio::time::sleep(Duration::from_millis(25)).await;
1226-
}
1227-
assert!(
1228-
marker_path.exists(),
1229-
"the long-running child must execute before stop tests cancellation"
1230-
);
1216+
tokio::time::sleep(Duration::from_millis(250)).await;
1217+
let running = backend.get_sandbox("sb-stop").await.unwrap();
1218+
assert_eq!(ready_condition(&running).unwrap().reason, "AgentRunning");
12311219

12321220
tokio::time::timeout(Duration::from_secs(5), backend.stop_sandbox("sb-stop"))
12331221
.await

‎crates/openshell-server/src/config_file.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -738,10 +738,11 @@ timeout = "2s"
738738
SupervisorMiddlewareService::try_from(&file.openshell.supervisor.middleware[0])
739739
.expect("valid CA resolves");
740740
assert_eq!(registration.timeout, "2s");
741-
assert_eq!(
742-
registration.tls_ca_cert_pem,
743-
certificate.cert.pem().as_bytes()
744-
);
741+
let registered_pem = String::from_utf8(registration.tls_ca_cert_pem)
742+
.expect("registered CA remains PEM text")
743+
.replace("\r\n", "\n");
744+
let generated_pem = certificate.cert.pem().replace("\r\n", "\n");
745+
assert_eq!(registered_pem, generated_pem);
745746
assert_eq!(
746747
registration.audience,
747748
"urn:openshell:middleware:local-guard"

0 commit comments

Comments
 (0)