From 2e56f0df77cbfcad1d0506f88932273d88ace4dd Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Thu, 9 Sep 2021 16:23:03 -0700 Subject: [PATCH] ci: Rustify ovs-dpdk setup and cleanup Signed-off-by: Bo Chen --- scripts/run_integration_tests_aarch64.sh | 6 +--- .../run_integration_tests_live_migration.sh | 6 ---- scripts/run_integration_tests_x86_64.sh | 6 ---- tests/integration.rs | 31 +++++++++++++++++-- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/scripts/run_integration_tests_aarch64.sh b/scripts/run_integration_tests_aarch64.sh index 4f6422c12..821e21b85 100755 --- a/scripts/run_integration_tests_aarch64.sh +++ b/scripts/run_integration_tests_aarch64.sh @@ -292,12 +292,8 @@ sudo bash -c "echo 1000000 > /sys/kernel/mm/ksm/pages_to_scan" sudo bash -c "echo 10 > /sys/kernel/mm/ksm/sleep_millisecs" sudo bash -c "echo 1 > /sys/kernel/mm/ksm/run" -# Setup ovs-dpdk +# Setup huge-pages for ovs-dpdk echo 2048 | sudo tee /proc/sys/vm/nr_hugepages -service openvswitch-switch start -ovs-vsctl init -ovs-vsctl set Open_vSwitch . other_config:dpdk-init=true -service openvswitch-switch restart # Run all direct kernel boot (Device Tree) test cases in mod `parallel` time cargo test $features_test "tests::parallel::$test_filter" diff --git a/scripts/run_integration_tests_live_migration.sh b/scripts/run_integration_tests_live_migration.sh index 42dfd4d32..b060c754f 100755 --- a/scripts/run_integration_tests_live_migration.sh +++ b/scripts/run_integration_tests_live_migration.sh @@ -83,12 +83,6 @@ strip target/$BUILD_TARGET/release/ch-remote echo 6144 | sudo tee /proc/sys/vm/nr_hugepages sudo chmod a+rwX /dev/hugepages -# Setup ovs-dpdk -service openvswitch-switch start -ovs-vsctl init -ovs-vsctl set Open_vSwitch . other_config:dpdk-init=true -service openvswitch-switch restart - export RUST_BACKTRACE=1 time cargo test $features_test "tests::live_migration::$test_filter" -- --test-threads=1 RES=$? diff --git a/scripts/run_integration_tests_x86_64.sh b/scripts/run_integration_tests_x86_64.sh index 0b8d43195..c814dc5da 100755 --- a/scripts/run_integration_tests_x86_64.sh +++ b/scripts/run_integration_tests_x86_64.sh @@ -202,12 +202,6 @@ sudo bash -c "echo 1 > /sys/kernel/mm/ksm/run" echo 6144 | sudo tee /proc/sys/vm/nr_hugepages sudo chmod a+rwX /dev/hugepages -# Setup ovs-dpdk -service openvswitch-switch start -ovs-vsctl init -ovs-vsctl set Open_vSwitch . other_config:dpdk-init=true -service openvswitch-switch restart - export RUST_BACKTRACE=1 time cargo test $features_test "tests::parallel::$test_filter" RES=$? diff --git a/tests/integration.rs b/tests/integration.rs index 83da380b6..0bc73ee65 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -349,8 +349,17 @@ mod tests { cmd.status().expect("Failed to launch ch-remote").success() } - // Setup two guests and ensure they are connected through ovs-dpdk - fn setup_ovs_dpdk_guests(guest1: &Guest, guest2: &Guest, api_socket: &str) -> (Child, Child) { + // setup OVS-DPDK bridge and ports + fn setup_ovs_dpdk() { + // setup OVS-DPDK + assert!(exec_host_command_status("service openvswitch-switch start").success()); + assert!(exec_host_command_status("ovs-vsctl init").success()); + assert!(exec_host_command_status( + "ovs-vsctl set Open_vSwitch . other_config:dpdk-init=true" + ) + .success()); + assert!(exec_host_command_status("service openvswitch-switch restart").success()); + // Create OVS-DPDK bridge and ports assert!(exec_host_command_status( "ovs-vsctl add-br ovsbr0 -- set bridge ovsbr0 datapath_type=netdev", @@ -360,6 +369,14 @@ mod tests { assert!(exec_host_command_status("ovs-vsctl add-port ovsbr0 vhost-user2 -- set Interface vhost-user2 type=dpdkvhostuserclient options:vhost-server-path=/tmp/dpdkvhostclient2").success()); assert!(exec_host_command_status("ip link set up dev ovsbr0").success()); assert!(exec_host_command_status("service openvswitch-switch restart").success()); + } + fn cleanup_ovs_dpdk() { + assert!(exec_host_command_status("ovs-vsctl del-br ovsbr0").success()); + exec_host_command_status("rm -f ovs-vsctl /tmp/dpdkvhostclient1 /tmp/dpdkvhostclient2"); + } + // Setup two guests and ensure they are connected through ovs-dpdk + fn setup_ovs_dpdk_guests(guest1: &Guest, guest2: &Guest, api_socket: &str) -> (Child, Child) { + setup_ovs_dpdk(); let mut child1 = GuestCommand::new(guest1) .args(&["--cpus", "boot=2"]) @@ -403,6 +420,8 @@ mod tests { }); }); if r.is_err() { + cleanup_ovs_dpdk(); + let _ = child1.kill(); let output = child1.wait_with_output().unwrap(); handle_child_output(r, &output); @@ -439,6 +458,8 @@ mod tests { guest2.ssh_command("nc -vz 172.100.0.1 12345").unwrap(); }); if r.is_err() { + cleanup_ovs_dpdk(); + let _ = child1.kill(); let _ = child2.kill(); let output = child2.wait_with_output().unwrap(); @@ -5543,6 +5564,8 @@ mod tests { guest2.ssh_command("nc -vz 172.100.0.1 12345").unwrap(); }); + cleanup_ovs_dpdk(); + let _ = child1.kill(); let _ = child2.kill(); @@ -7156,6 +7179,8 @@ mod tests { String::from_utf8_lossy(&ovs_output.stderr) ); + cleanup_ovs_dpdk(); + panic!("Test failed: {}", message) }; @@ -7202,6 +7227,8 @@ mod tests { migration_guest .ssh_command("nc -vz 172.100.0.1 12345") .unwrap(); + + cleanup_ovs_dpdk(); }); // Clean-up the destination VM and OVS VM, and make sure they terminated correctly