mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 21:55:20 +00:00
tests: Use new ch-remote for pause/resume integration test
Replace the use of a manual curl command with the new ch-remote tool. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
ba8cd4d55a
commit
16fd506bb8
@ -462,6 +462,14 @@ mod tests {
|
|||||||
assert!(status.success());
|
assert!(status.success());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remote_command(api_socket: &str, command: &str) -> bool {
|
||||||
|
Command::new("target/release/ch-remote")
|
||||||
|
.args(&[&format!("--api-socket={}", api_socket), command])
|
||||||
|
.status()
|
||||||
|
.expect("Failed to launch ch-remote")
|
||||||
|
.success()
|
||||||
|
}
|
||||||
|
|
||||||
const DEFAULT_SSH_RETRIES: u8 = 6;
|
const DEFAULT_SSH_RETRIES: u8 = 6;
|
||||||
const DEFAULT_SSH_TIMEOUT: u8 = 10;
|
const DEFAULT_SSH_TIMEOUT: u8 = 10;
|
||||||
fn ssh_command_ip(command: &str, ip: &str, retries: u8, timeout: u8) -> Result<String, Error> {
|
fn ssh_command_ip(command: &str, ip: &str, retries: u8, timeout: u8) -> Result<String, Error> {
|
||||||
@ -2723,7 +2731,11 @@ mod tests {
|
|||||||
aver!(tb, guest.get_entropy().unwrap_or_default() >= 900);
|
aver!(tb, guest.get_entropy().unwrap_or_default() >= 900);
|
||||||
|
|
||||||
// We now pause the VM
|
// We now pause the VM
|
||||||
curl_command(&api_socket, "PUT", "http://localhost/api/v1/vm.pause", None);
|
aver!(tb, remote_command(&api_socket, "pause"));
|
||||||
|
|
||||||
|
// Check pausing again fails
|
||||||
|
aver!(tb, !remote_command(&api_socket, "pause"));
|
||||||
|
|
||||||
thread::sleep(std::time::Duration::new(2, 0));
|
thread::sleep(std::time::Duration::new(2, 0));
|
||||||
|
|
||||||
// SSH into the VM should fail
|
// SSH into the VM should fail
|
||||||
@ -2739,12 +2751,11 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Resume the VM
|
// Resume the VM
|
||||||
curl_command(
|
aver!(tb, remote_command(&api_socket, "resume"));
|
||||||
&api_socket,
|
|
||||||
"PUT",
|
// Check resuming again fails
|
||||||
"http://localhost/api/v1/vm.resume",
|
aver!(tb, !remote_command(&api_socket, "resume"));
|
||||||
None,
|
|
||||||
);
|
|
||||||
thread::sleep(std::time::Duration::new(2, 0));
|
thread::sleep(std::time::Duration::new(2, 0));
|
||||||
|
|
||||||
// Now we should be able to SSH back in and get the right number of CPUs
|
// Now we should be able to SSH back in and get the right number of CPUs
|
||||||
|
Loading…
Reference in New Issue
Block a user