From 14163c5200f0e4bbe16aaf3c6a44a50688769341 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Tue, 6 Oct 2020 12:13:42 +0200 Subject: [PATCH] ci: Extend virtio-net hotplug integration test The existing virtio-net hotplug test is extended by removing and re-adding the virtio-net device. This ensures the unplug/re-plug feature is properly tested. Signed-off-by: Sebastien Boeuf --- tests/integration.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/integration.rs b/tests/integration.rs index 33c294408..d48447ab0 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -4947,6 +4947,35 @@ mod tests { assert!(String::from_utf8_lossy(&cmd_output) .contains("{\"id\":\"_net2\",\"bdf\":\"0000:00:05.0\"}")); + thread::sleep(std::time::Duration::new(5, 0)); + + // 1 network interfaces + default localhost ==> 2 interfaces + assert_eq!( + guest + .ssh_command("ip -o link | wc -l") + .unwrap_or_default() + .trim() + .parse::() + .unwrap_or_default(), + 2 + ); + + // Remove network + assert!(remote_command(&api_socket, "remove-device", Some("_net2"))); + thread::sleep(std::time::Duration::new(5, 0)); + + // Add network again + let (cmd_success, cmd_output) = remote_command_w_output( + &api_socket, + "add-net", + Some(guest.default_net_string().as_str()), + ); + assert!(cmd_success); + assert!(String::from_utf8_lossy(&cmd_output) + .contains("{\"id\":\"_net3\",\"bdf\":\"0000:00:05.0\"}")); + + thread::sleep(std::time::Duration::new(5, 0)); + // 1 network interfaces + default localhost ==> 2 interfaces assert_eq!( guest