mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 13:05:45 +00:00
tests: Factorize shutdown and reboot functions for Windows
Add some factorization for both functions rebooting and shutting down a Windows guest. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
2646b24047
commit
14544d64e4
@ -5309,6 +5309,28 @@ mod tests {
|
|||||||
n
|
n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reboot_windows(auth: &PasswordAuth) {
|
||||||
|
ssh_command_ip_with_auth(
|
||||||
|
"shutdown /r /t 0",
|
||||||
|
&auth,
|
||||||
|
"192.168.249.2",
|
||||||
|
DEFAULT_SSH_RETRIES,
|
||||||
|
DEFAULT_SSH_TIMEOUT,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn shutdown_windows(auth: &PasswordAuth) {
|
||||||
|
ssh_command_ip_with_auth(
|
||||||
|
"shutdown /s",
|
||||||
|
&auth,
|
||||||
|
"192.168.249.2",
|
||||||
|
DEFAULT_SSH_RETRIES,
|
||||||
|
DEFAULT_SSH_TIMEOUT,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_windows_guest() {
|
fn test_windows_guest() {
|
||||||
let windows = WindowsDiskConfig::new(WINDOWS_IMAGE_NAME.to_string());
|
let windows = WindowsDiskConfig::new(WINDOWS_IMAGE_NAME.to_string());
|
||||||
@ -5345,14 +5367,7 @@ mod tests {
|
|||||||
thread::sleep(std::time::Duration::new(60, 0));
|
thread::sleep(std::time::Duration::new(60, 0));
|
||||||
let auth = windows_auth();
|
let auth = windows_auth();
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
ssh_command_ip_with_auth(
|
shutdown_windows(&auth);
|
||||||
"shutdown /s",
|
|
||||||
&auth,
|
|
||||||
"192.168.249.2",
|
|
||||||
DEFAULT_SSH_RETRIES,
|
|
||||||
DEFAULT_SSH_TIMEOUT,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
||||||
@ -5440,15 +5455,7 @@ mod tests {
|
|||||||
assert!(remote_command(&api_socket, "resume", None));
|
assert!(remote_command(&api_socket, "resume", None));
|
||||||
|
|
||||||
let auth = windows_auth();
|
let auth = windows_auth();
|
||||||
|
shutdown_windows(&auth);
|
||||||
ssh_command_ip_with_auth(
|
|
||||||
"shutdown /s",
|
|
||||||
&auth,
|
|
||||||
"192.168.249.2",
|
|
||||||
DEFAULT_SSH_RETRIES,
|
|
||||||
DEFAULT_SSH_TIMEOUT,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
||||||
@ -5517,14 +5524,7 @@ mod tests {
|
|||||||
// Wait to make sure CPUs are removed
|
// Wait to make sure CPUs are removed
|
||||||
thread::sleep(std::time::Duration::new(10, 0));
|
thread::sleep(std::time::Duration::new(10, 0));
|
||||||
// Reboot to let Windows catch up
|
// Reboot to let Windows catch up
|
||||||
ssh_command_ip_with_auth(
|
reboot_windows(&auth);
|
||||||
"shutdown /r /t 0",
|
|
||||||
&auth,
|
|
||||||
"192.168.249.2",
|
|
||||||
DEFAULT_SSH_RETRIES,
|
|
||||||
DEFAULT_SSH_TIMEOUT,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
// Wait to make sure Windows completely rebooted
|
// Wait to make sure Windows completely rebooted
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
thread::sleep(std::time::Duration::new(60, 0));
|
||||||
// Check the guest sees the correct number
|
// Check the guest sees the correct number
|
||||||
@ -5532,14 +5532,7 @@ mod tests {
|
|||||||
// Check the CH process has the correct number of vcpu threads
|
// Check the CH process has the correct number of vcpu threads
|
||||||
assert_eq!(get_vcpu_threads_count(child.id()), vcpu_num);
|
assert_eq!(get_vcpu_threads_count(child.id()), vcpu_num);
|
||||||
|
|
||||||
ssh_command_ip_with_auth(
|
shutdown_windows(&auth);
|
||||||
"shutdown /s",
|
|
||||||
&auth,
|
|
||||||
"192.168.249.2",
|
|
||||||
DEFAULT_SSH_RETRIES,
|
|
||||||
DEFAULT_SSH_TIMEOUT,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
||||||
@ -5610,27 +5603,13 @@ mod tests {
|
|||||||
// Wait to make sure RAM has been added
|
// Wait to make sure RAM has been added
|
||||||
thread::sleep(std::time::Duration::new(10, 0));
|
thread::sleep(std::time::Duration::new(10, 0));
|
||||||
// Reboot to let Windows catch up
|
// Reboot to let Windows catch up
|
||||||
ssh_command_ip_with_auth(
|
reboot_windows(&auth);
|
||||||
"shutdown /r /t 0",
|
|
||||||
&auth,
|
|
||||||
"192.168.249.2",
|
|
||||||
DEFAULT_SSH_RETRIES,
|
|
||||||
DEFAULT_SSH_TIMEOUT,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
// Wait to make sure guest completely rebooted
|
// Wait to make sure guest completely rebooted
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
thread::sleep(std::time::Duration::new(60, 0));
|
||||||
// Check the guest sees the correct number
|
// Check the guest sees the correct number
|
||||||
assert_eq!(get_ram_size_windows(&auth), ram_size - reserved_ram_size);
|
assert_eq!(get_ram_size_windows(&auth), ram_size - reserved_ram_size);
|
||||||
|
|
||||||
ssh_command_ip_with_auth(
|
shutdown_windows(&auth);
|
||||||
"shutdown /s",
|
|
||||||
&auth,
|
|
||||||
"192.168.249.2",
|
|
||||||
DEFAULT_SSH_RETRIES,
|
|
||||||
DEFAULT_SSH_TIMEOUT,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
||||||
@ -5714,14 +5693,7 @@ mod tests {
|
|||||||
netdev_num
|
netdev_num
|
||||||
);
|
);
|
||||||
|
|
||||||
ssh_command_ip_with_auth(
|
shutdown_windows(&auth);
|
||||||
"shutdown /s",
|
|
||||||
&auth,
|
|
||||||
"192.168.249.2",
|
|
||||||
DEFAULT_SSH_RETRIES,
|
|
||||||
DEFAULT_SSH_TIMEOUT,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
let _ = child.wait_timeout(std::time::Duration::from_secs(60));
|
||||||
|
Loading…
Reference in New Issue
Block a user