From 2e50d1fc7242b0d229d3fc921f5b79f29c4aa5d8 Mon Sep 17 00:00:00 2001 From: Gabor Igloi Date: Mon, 23 Apr 2018 10:03:35 +0000 Subject: [PATCH] Remove inactive with_vm quicktests These quicktests are looking for a template that does not exist currently, therefore they are always skipped. Signed-off-by: Gabor Igloi --- ocaml/quicktest/quicktest.ml | 78 ---------- ocaml/quicktest/quicktest_lifecycle.ml | 199 ------------------------- 2 files changed, 277 deletions(-) delete mode 100644 ocaml/quicktest/quicktest_lifecycle.ml diff --git a/ocaml/quicktest/quicktest.ml b/ocaml/quicktest/quicktest.ml index 17c27f04731..29fbfcff0d1 100644 --- a/ocaml/quicktest/quicktest.ml +++ b/ocaml/quicktest/quicktest.ml @@ -573,47 +573,6 @@ let rec wait_for_task_complete session_id task = | `pending | `cancelling -> wait_for_task_complete session_id task | _ -> () -(* CP-831 *) -let test_vhd_locking_hook session_id vm = - let test = make_test "test vhd locking hook" 2 in - start test; - Client.VM.start !rpc session_id vm false false; - (* Add a new VDI whose VBD is unplugged (so 2 plugged, 1 unplugged *) - - let all_srs = all_srs_with_vdi_create session_id in - let sr = List.hd all_srs in - - let new_vdi = Client.VDI.create !rpc session_id "lvhd_testvdi" - "description" sr 4194304L `user false false [] [] [] [] in - let new_vbd = Client.VBD.create ~rpc:!rpc ~session_id ~vM:vm ~vDI:new_vdi ~userdevice:"9" ~bootable:false - ~mode:`RW ~_type:`Disk ~unpluggable:true ~empty:false ~other_config:[Xapi_globs.owner_key,""] - ~qos_algorithm_type:"" ~qos_algorithm_params:[] in - - (* In a background thread plug/unplug the new VBD to cause some transient locking failures *) - let start = Unix.gettimeofday () in - debug test "Starting up conflicting thread in the background"; - let total_bg_ops = ref 0 in - let t = Thread.create - (fun () -> - while Unix.gettimeofday () -. start < 30. do - (* We throw away exceptions because unplugs can fail (if the guest isn't ready) and this causes the - next plug to fail. We use asynchronous operations because we are sharing a single HTTP connection to the - master and we genuinely want the operations to (attempt to) execute in parallel *) - let task = Client.Async.VBD.plug !rpc session_id new_vbd in - incr total_bg_ops; - wait_for_task_complete session_id task; - let task = Client.Async.VBD.unplug !rpc session_id new_vbd in - incr total_bg_ops; - wait_for_task_complete session_id task - done) () in - (* Give the background thread a chance to start *) - Thread.delay 1.5; - (* Verify that the function 'test' can be called in the script *) - - Thread.join t; - debug test (Printf.sprintf "Meanwhile background thread executed %d conflicting operations" !total_bg_ops); - success test - let powercycle_test session_id vm = let test = make_test "Powercycling VM" 1 in start test; @@ -796,37 +755,6 @@ let async_test session_id = let make_vif ~session_id ~vM ~network ~device = Client.VIF.create ~rpc:!rpc ~session_id ~vM ~network ~mTU:0L ~mAC:"" ~device ~other_config:["promiscuous", "on"; "mtu", "1400"] ~qos_algorithm_type:"" ~qos_algorithm_params:[] -let with_vm s f = - try - let (_: API.ref_VM) = find_template s vm_template in - let test = make_test "Setting up test VM" 0 in - start test; - let vm = install_vm test s in - f s vm; - vm_uninstall test s vm; - success test - with Unable_to_find_suitable_vm_template -> - (* SKIP *) - () - -let vm_powercycle_test s vm = - let test = make_test "VM powercycle test" 1 in - start test; - (* Try to add some VIFs *) - let (guest_installer_network: API.ref_network) = find_guest_installer_network s in - debug test (Printf.sprintf "Adding VIF to guest installer network (%s)" (Client.Network.get_uuid !rpc s guest_installer_network)); - let (_: API.ref_VIF) = make_vif ~session_id:s ~vM:vm ~network:guest_installer_network ~device:"0" ~locking_mode:`network_default ~ipv4_allowed:[] ~ipv6_allowed:[] in - begin match Client.PIF.get_all !rpc s with - | pif :: _ -> - let net = Client.PIF.get_network !rpc s pif in - debug test (Printf.sprintf "Adding VIF to physical network (%s)" (Client.Network.get_uuid !rpc s net)); - let (_: API.ref_VIF) = make_vif ~session_id:s ~vM:vm ~network:net ~device:"1" ~locking_mode:`network_default ~ipv4_allowed:[] ~ipv6_allowed:[] in - () - | _ -> () - end; - powercycle_test s vm; - success test - let _ = let all_tests = [ @@ -836,9 +764,6 @@ let _ = "vdi"; "async"; "import"; - "powercycle"; - "lifecycle"; - "vhd"; "copy"; "cbt"; "import_raw_vdi"; @@ -891,9 +816,6 @@ let _ = maybe_run_test "vdi" (fun () -> vdi_test s); maybe_run_test "async" (fun () -> async_test s); maybe_run_test "import" (fun () -> import_export_test s); - maybe_run_test "vhd" (fun () -> with_vm s test_vhd_locking_hook); - maybe_run_test "powercycle" (fun () -> with_vm s vm_powercycle_test); - maybe_run_test "lifecycle" (fun () -> with_vm s Quicktest_lifecycle.test); maybe_run_test "copy" (fun () -> Quicktest_vdi_copy.start s sr); maybe_run_test "import_raw_vdi" (fun () -> Quicktest_import_raw_vdi.start s); with diff --git a/ocaml/quicktest/quicktest_lifecycle.ml b/ocaml/quicktest/quicktest_lifecycle.ml deleted file mode 100644 index c2c8445bed4..00000000000 --- a/ocaml/quicktest/quicktest_lifecycle.ml +++ /dev/null @@ -1,199 +0,0 @@ - - -type 'a api_call = - | Shutdown of 'a - | Reboot of 'a - -type api_mode = - | Clean - | Hard - -type api = api_mode api_call - -type parallel_op = - | Internal_reboot - | Internal_halt - | Internal_suspend - | Internal_crash - -type code_path = - | Sync - | Event - | Both - -type result = - | Rebooted - | Halted - -let final_guest_state = function - | Shutdown _ -> Halted - | Reboot _ -> Rebooted - -type test = { - api: api option; - parallel_op: parallel_op option; - code_path: code_path; -} - -let string_of_result = function - | Rebooted -> "Reboot" - | Halted -> "Halt" - -let expected_result = function - | { api = Some (Shutdown _); parallel_op = Some _; code_path = (Sync|Both) } -> Some Halted - | { api = Some (Reboot _); parallel_op = Some _; code_path = (Sync|Both) } -> Some Rebooted - | { api = Some (Shutdown _); parallel_op = None; code_path = (Sync|Event|Both) } -> Some Halted - | { api = Some (Reboot _); parallel_op = None; code_path = (Sync|Event|Both) } -> Some Rebooted - | { parallel_op = Some (Internal_halt | Internal_crash); code_path = Event } -> Some Halted - | { parallel_op = Some Internal_reboot; code_path = Event } -> Some Rebooted - - | _ -> None (* invalid test *) - - -let string_of_test x = - let string_of_api = function - | Shutdown Clean -> "clean_shutdown" - | Shutdown Hard -> "hard_shutdown " - | Reboot Clean -> "clean_reboot " - | Reboot Hard -> "hard_reboot " in - let string_of_parallel_op = function - | Internal_reboot -> "reboot " - | Internal_halt -> "halt " - | Internal_suspend -> "suspend " - | Internal_crash -> "crash " in - let string_of_code_path = function - | Sync -> "synch " - | Event -> "event " - | Both -> "both " in - let dm f x = match x with - | None -> "Nothing " - | Some x -> f x in - Printf.sprintf "%s %s %s -> %s" - (dm string_of_api x.api) (dm string_of_parallel_op x.parallel_op) (string_of_code_path x.code_path) - (match expected_result x with None -> "invalid" | Some y -> string_of_result y) -open List - -let all_possible_tests = - let all_api_variants x = - [ { x with api = None }; - { x with api = Some (Shutdown Clean) }; - { x with api = Some (Shutdown Hard) }; - { x with api = Some (Reboot Clean) }; - { x with api = Some (Reboot Hard) } ] in - let all_parallel_op_variants x = - [ { x with parallel_op = None }; - { x with parallel_op = Some Internal_reboot }; - { x with parallel_op = Some Internal_halt }; - { x with parallel_op = Some Internal_suspend }; - { x with parallel_op = Some Internal_crash } ] in - let all_code_path_variants x = - [ { x with code_path = Sync }; - { x with code_path = Event }; - { x with code_path = Both } ] in - - let xs = [ { api = None; parallel_op = None; code_path = Sync } ] in - concat (map all_code_path_variants (concat (map all_parallel_op_variants (concat (map all_api_variants xs))))) - -let all_valid_tests = List.filter (fun t -> expected_result t <> None) all_possible_tests - - (* -let _ = - List.iter print_endline (map string_of_test all_valid_tests); - Printf.printf "In total there are %d tests.\n" (List.length all_valid_tests) - *) - -open Quicktest_common -open Client - -let one s vm test = - let open Stdext in - let t = make_test (string_of_test test) 1 in - start t; - let event = "/tmp/fist_disable_event_lifecycle_path" in - let sync = "/tmp/fist_disable_sync_lifecycle_path" in - let simulate = "/tmp/fist_simulate_internal_shutdown" in - let delay = "/tmp/fist_disable_reboot_delay" in - - Pervasiveext.finally - (fun () -> - try - begin - Unixext.unlink_safe simulate; - Unixext.touch_file delay; - match test.code_path with - | Sync -> - Unixext.unlink_safe sync; - Unixext.touch_file event - | Event -> - Unixext.unlink_safe event; - Unixext.touch_file sync - | Both -> - Unixext.unlink_safe sync; - Unixext.unlink_safe event - end; - if Client.VM.get_power_state !rpc s vm = `Halted - then Client.VM.start !rpc s vm false false; - (* wait for the guest to actually start up *) - Thread.delay 15.; - - let call_api = function - | Shutdown Clean -> Client.VM.clean_shutdown !rpc s vm - | Shutdown Hard -> Client.VM.hard_shutdown !rpc s vm - | Reboot Clean -> Client.VM.clean_reboot !rpc s vm - | Reboot Hard -> Client.VM.hard_reboot !rpc s vm in - - let domid = Client.VM.get_domid !rpc s vm in - begin match test with - | { api = None; parallel_op = Some x } -> - let reason = match x with - | Internal_reboot -> Xenctrl.Reboot - | Internal_halt -> Xenctrl.Poweroff - | Internal_crash -> Xenctrl.Crash - | Internal_suspend -> Xenctrl.Suspend in - begin - try - Xenctrl.with_intf (fun xc -> Xenctrl.domain_shutdown xc (Int64.to_int domid) reason) - with e -> - debug t (Printf.sprintf "Ignoring exception: %s" (Printexc.to_string e)) - end - | { api = Some x; parallel_op = Some y } -> - let reason = match y with - | Internal_reboot -> "reboot" - | Internal_halt -> "halt" - | Internal_crash -> "crash" - | Internal_suspend -> "suspend" in - Unixext.write_string_to_file simulate reason; - call_api x - | { api = Some x; parallel_op = None } -> - call_api x - | t -> failwith (Printf.sprintf "Invalid test: %s" (string_of_test t)) - end; - - let wait_for_domid p = - let start = Unix.gettimeofday () in - let finished = ref false in - while Unix.gettimeofday () -. start < 300. && (not !finished) do - finished := p (Client.VM.get_domid !rpc s vm); - if not !finished then Thread.delay 1. - done; - if not !finished then failwith "timeout" - in - - begin match expected_result test with - | None -> failwith (Printf.sprintf "Invalid test: %s" (string_of_test test)) - | Some Rebooted -> - wait_for_domid (fun domid' -> domid <> domid') - | Some Halted -> - wait_for_domid (fun domid' -> domid' = -1L) - end - with e -> failed t (Printexc.to_string e) - ) - (fun () -> - Unixext.unlink_safe sync; - Unixext.unlink_safe event; - Unixext.unlink_safe delay - ); - success t - -let test s vm = - List.iter (one s vm) all_valid_tests