Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vm_lifecycle quicktest to use specified SR #5489

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions ocaml/quicktest/qt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,32 @@ module VM = struct
Some x
end

let install rpc session_id ~template ~name =
let install rpc session_id ~template ~name ?sr () =
let template_uuid =
Client.Client.VM.get_uuid ~rpc ~session_id ~self:template
in
let newvm_uuid =
cli_cmd
[
"vm-install"
; "template-uuid=" ^ template_uuid
; "new-name-label=" ^ name
]
let cmd =
["vm-install"; "template-uuid=" ^ template_uuid; "new-name-label=" ^ name]
in
let sr_uuid =
Option.map
(fun sr -> Client.Client.SR.get_uuid ~rpc ~session_id ~self:sr)
sr
in
let cmd =
cmd @ Option.fold ~none:[] ~some:(fun x -> ["sr-uuid=" ^ x]) sr_uuid
in
let newvm_uuid = cli_cmd cmd in
Client.Client.VM.get_by_uuid ~rpc ~session_id ~uuid:newvm_uuid

let uninstall rpc session_id vm =
let uuid = Client.Client.VM.get_uuid ~rpc ~session_id ~self:vm in
cli_cmd ["vm-uninstall"; "uuid=" ^ uuid; "--force"] |> ignore

let with_new rpc session_id ~template f =
let vm = install rpc session_id ~template ~name:"temp_quicktest_vm" in
let with_new rpc session_id ~template ?sr f =
let vm =
install rpc session_id ~template ~name:"temp_quicktest_vm" ?sr ()
in
Xapi_stdext_pervasives.Pervasiveext.finally
(fun () -> f vm)
(fun () -> uninstall rpc session_id vm)
Expand Down
7 changes: 6 additions & 1 deletion ocaml/quicktest/qt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ module VM : sig
end

val with_new :
rpc -> API.ref_session -> template:API.ref_VM -> (API.ref_VM -> 'a) -> 'a
rpc
-> API.ref_session
-> template:API.ref_VM
-> ?sr:API.ref_SR
-> (API.ref_VM -> 'a)
-> 'a

val dom0_of_host : rpc -> API.ref_session -> API.ref_host -> API.ref_VM
(** Return a host's domain zero *)
Expand Down
12 changes: 9 additions & 3 deletions ocaml/quicktest/quicktest_vm_lifecycle.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,18 @@ let one rpc session_id vm test =
| Halted ->
wait_for_domid (fun domid' -> domid' = -1L)

let test rpc session_id vm_template () =
Qt.VM.with_new rpc session_id ~template:vm_template (fun vm ->
let test rpc session_id sr_info vm_template () =
let sr = sr_info.Qt.sr in
Qt.VM.with_new rpc session_id ~template:vm_template ~sr (fun vm ->
List.iter (one rpc session_id vm) all_possible_tests
)

let tests () =
let open Qt_filter in
[[("VM lifecycle tests", `Slow, test)] |> conn |> vm_template "CoreOS"]
[
[("VM lifecycle tests", `Slow, test)]
|> conn
|> sr SR.(all |> allowed_operations [`vdi_create])
|> vm_template "CoreOS"
]
|> List.concat
Loading