mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-22 04:25:21 +00:00
tests: Simplify Windows guest boot and DHCP setup
A new method has been introduced for WindowsGuest, that would poll on the SSH connection and try to execute a test command. When successfull, the polling stops and the guest is considered finished boot. The downside of this method is that the network setup is needed always even if the test doesn't use network, however it complies with the behavior of other tests. I also observe a bit more stability on the local test run, however it still appears to be a resource issue so some sporadic fails are possible on a slower machine. The hardcoded timeouts for guest boot and DHCP setup have been removed. The dnsmasq invocation uses `--bind-dynamic` so then the daemon can be started while the target interface could be down yet. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com> Co-authored-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
0699dc1000
commit
57f70c0761
@ -5367,7 +5367,7 @@ mod tests {
|
|||||||
.arg("--log-queries")
|
.arg("--log-queries")
|
||||||
.arg(listen_address.as_str())
|
.arg(listen_address.as_str())
|
||||||
.arg("--except-interface=lo")
|
.arg("--except-interface=lo")
|
||||||
.arg("--bind-interfaces")
|
.arg("--bind-dynamic") // Allow listening to host_ip while the interface is not ready yet.
|
||||||
.arg("--conf-file=/dev/null")
|
.arg("--conf-file=/dev/null")
|
||||||
.arg(dhcp_host.as_str())
|
.arg(dhcp_host.as_str())
|
||||||
.arg(dhcp_range.as_str())
|
.arg(dhcp_range.as_str())
|
||||||
@ -5484,6 +5484,39 @@ mod tests {
|
|||||||
fname
|
fname
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn wait_for_boot(&self) -> bool {
|
||||||
|
let cmd = "dir /b c:\\ | find \"Windows\"";
|
||||||
|
let tmo_max = 180;
|
||||||
|
// The timeout increase by n*1+n*2+n*3+..., therefore the initial
|
||||||
|
// interval must be small.
|
||||||
|
let tmo_int = 2;
|
||||||
|
let out = ssh_command_ip_with_auth(
|
||||||
|
cmd,
|
||||||
|
&self.auth,
|
||||||
|
&self.guest.network.guest_ip,
|
||||||
|
{
|
||||||
|
let mut ret = 1;
|
||||||
|
let mut tmo_acc = 0;
|
||||||
|
loop {
|
||||||
|
tmo_acc += tmo_int * ret;
|
||||||
|
if tmo_acc >= tmo_max {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ret += 1;
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
},
|
||||||
|
tmo_int,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
if "Windows" == out.trim() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vcpu_threads_count(pid: u32) -> u8 {
|
fn vcpu_threads_count(pid: u32) -> u8 {
|
||||||
@ -5551,14 +5584,12 @@ mod tests {
|
|||||||
|
|
||||||
assert!(pipesize >= PIPE_SIZE && pipesize1 >= PIPE_SIZE);
|
assert!(pipesize >= PIPE_SIZE && pipesize1 >= PIPE_SIZE);
|
||||||
|
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
|
||||||
|
|
||||||
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
||||||
// Give some time for the guest to reach dnsmasq and get
|
|
||||||
// assigned the right IP address.
|
|
||||||
thread::sleep(std::time::Duration::new(30, 0));
|
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
// Wait to make sure Windows boots up
|
||||||
|
assert!(windows_guest.wait_for_boot());
|
||||||
|
|
||||||
windows_guest.shutdown();
|
windows_guest.shutdown();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -5618,14 +5649,12 @@ mod tests {
|
|||||||
|
|
||||||
assert!(pipesize >= PIPE_SIZE && pipesize1 >= PIPE_SIZE);
|
assert!(pipesize >= PIPE_SIZE && pipesize1 >= PIPE_SIZE);
|
||||||
|
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
|
||||||
|
|
||||||
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
||||||
// Give some time for the guest to reach dnsmasq and get
|
|
||||||
// assigned the right IP address.
|
|
||||||
thread::sleep(std::time::Duration::new(30, 0));
|
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
// Wait to make sure Windows boots up
|
||||||
|
assert!(windows_guest.wait_for_boot());
|
||||||
|
|
||||||
windows_guest.shutdown();
|
windows_guest.shutdown();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -5671,13 +5700,10 @@ mod tests {
|
|||||||
|
|
||||||
assert!(pipesize >= PIPE_SIZE && pipesize1 >= PIPE_SIZE);
|
assert!(pipesize >= PIPE_SIZE && pipesize1 >= PIPE_SIZE);
|
||||||
|
|
||||||
// Wait to make sure Windows boots up
|
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
|
||||||
|
|
||||||
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
||||||
// Give some time for the guest to reach dnsmasq and get
|
|
||||||
// assigned the right IP address.
|
// Wait to make sure Windows boots up
|
||||||
thread::sleep(std::time::Duration::new(30, 0));
|
assert!(windows_guest.wait_for_boot());
|
||||||
|
|
||||||
let snapshot_dir = temp_snapshot_dir_path(&tmp_dir);
|
let snapshot_dir = temp_snapshot_dir_path(&tmp_dir);
|
||||||
|
|
||||||
@ -5753,15 +5779,12 @@ mod tests {
|
|||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Wait to make sure Windows boots up
|
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
|
||||||
|
|
||||||
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
||||||
// Give some time for the guest to reach dnsmasq and get
|
|
||||||
// assigned the right IP address.
|
|
||||||
thread::sleep(std::time::Duration::new(30, 0));
|
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
// Wait to make sure Windows boots up
|
||||||
|
assert!(windows_guest.wait_for_boot());
|
||||||
|
|
||||||
let vcpu_num = 2;
|
let vcpu_num = 2;
|
||||||
// Check the initial number of CPUs the guest sees
|
// Check the initial number of CPUs the guest sees
|
||||||
assert_eq!(windows_guest.cpu_count(), vcpu_num);
|
assert_eq!(windows_guest.cpu_count(), vcpu_num);
|
||||||
@ -5830,15 +5853,12 @@ mod tests {
|
|||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Wait to make sure Windows boots up
|
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
|
||||||
|
|
||||||
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
||||||
// Give some time for the guest to reach dnsmasq and get
|
|
||||||
// assigned the right IP address.
|
|
||||||
thread::sleep(std::time::Duration::new(30, 0));
|
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
// Wait to make sure Windows boots up
|
||||||
|
assert!(windows_guest.wait_for_boot());
|
||||||
|
|
||||||
let ram_size = 2 * 1024 * 1024 * 1024;
|
let ram_size = 2 * 1024 * 1024 * 1024;
|
||||||
// Check the initial number of RAM the guest sees
|
// Check the initial number of RAM the guest sees
|
||||||
let current_ram_size = windows_guest.ram_size();
|
let current_ram_size = windows_guest.ram_size();
|
||||||
@ -5907,15 +5927,12 @@ mod tests {
|
|||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Wait to make sure Windows boots up
|
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
|
||||||
|
|
||||||
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
||||||
// Give some time for the guest to reach dnsmasq and get
|
|
||||||
// assigned the right IP address.
|
|
||||||
thread::sleep(std::time::Duration::new(30, 0));
|
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
// Wait to make sure Windows boots up
|
||||||
|
assert!(windows_guest.wait_for_boot());
|
||||||
|
|
||||||
// Initially present network device
|
// Initially present network device
|
||||||
let netdev_num = 1;
|
let netdev_num = 1;
|
||||||
assert_eq!(windows_guest.netdev_count(), netdev_num);
|
assert_eq!(windows_guest.netdev_count(), netdev_num);
|
||||||
@ -5982,17 +5999,14 @@ mod tests {
|
|||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Wait to make sure Windows boots up
|
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
|
||||||
|
|
||||||
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
let mut child_dnsmasq = windows_guest.run_dnsmasq();
|
||||||
// Give some time for the guest to reach dnsmasq and get
|
|
||||||
// assigned the right IP address.
|
|
||||||
thread::sleep(std::time::Duration::new(30, 0));
|
|
||||||
|
|
||||||
let disk = windows_guest.disk_new();
|
let disk = windows_guest.disk_new();
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
// Wait to make sure Windows boots up
|
||||||
|
assert!(windows_guest.wait_for_boot());
|
||||||
|
|
||||||
// Initially present disk device
|
// Initially present disk device
|
||||||
let disk_num = 1;
|
let disk_num = 1;
|
||||||
assert_eq!(windows_guest.disk_count(), disk_num);
|
assert_eq!(windows_guest.disk_count(), disk_num);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user