Skip to content

Commit

Permalink
Merge pull request #1128 from johnelse/unit-test-refactor-clearwater
Browse files Browse the repository at this point in the history
CLEARWATER: Refactor unit tests for consistency
  • Loading branch information
johnelse committed Apr 3, 2013
2 parents 8669fbc + 8b6b9fb commit c112548
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
31 changes: 3 additions & 28 deletions ocaml/test/suite.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,12 @@

open OUnit

let test_basic =
let open Test_basic in
"test_basic" >:::
[
"test_always_pass" >:: test_always_pass ;
"test_always_fail" >:: test_always_fail ;
"test_mock_db" >:: test_mock_db ;
"test_assert_licensed_storage_motion" >:: test_assert_licensed_storage_motion ;
]

let test_db_backup =
"test_db_backup" >:::
[
"test_prepare_restore" >:: Test_pool_db_backup.test_prepare_restore;
]

let test_db_upgrade =
let open Test_xapi_db_upgrade in
"test_db_upgrade" >:::
[
"upgrade_vm_memory_for_dmc" >:: upgrade_vm_memory_for_dmc;
"upgrade_bios" >:: upgrade_bios;
"update_snapshots" >:: update_snapshots;
]

let base_suite =
"base_suite" >:::
[
test_basic;
test_db_backup;
test_db_upgrade;
Test_basic.test;
Test_pool_db_backup.test;
Test_xapi_db_upgrade.test;
]

let _ = run_test_tt_main base_suite
9 changes: 9 additions & 0 deletions ocaml/test/test_basic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ let test_assert_licensed_storage_motion () = skip "TODO" ;
let licensed = try Xapi_vm_migrate.assert_licensed_storage_motion ~__context; true
with _ -> false in
assert_bool "Not licensed for SXM" licensed

let test =
"test_basic" >:::
[
"test_always_pass" >:: test_always_pass ;
"test_always_fail" >:: test_always_fail ;
"test_mock_db" >:: test_mock_db ;
"test_assert_licensed_storage_motion" >:: test_assert_licensed_storage_motion ;
]
8 changes: 7 additions & 1 deletion ocaml/test/test_pool_db_backup.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ let test_prepare_restore () =
(* new_context should have correct master dom0 uuid *)
let dom0 = List.hd (Db.Host.get_resident_VMs ~__context:new_context ~self:master) in
let dom0_uuid = Db.VM.get_uuid ~__context:new_context ~self:dom0 in
assert_equal ~msg:"test_prepare_restore: master dom0 uuid wrong" dom0_uuid my_control_uuid;
assert_equal ~msg:"test_prepare_restore: master dom0 uuid wrong" dom0_uuid my_control_uuid

let test =
"test_db_backup" >:::
[
"test_prepare_restore" >:: test_prepare_restore;
]
10 changes: 9 additions & 1 deletion ocaml/test/test_xapi_db_upgrade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,12 @@ let update_snapshots () =

(* b_snap2.parent = b_snap *)
assert_equal ~msg:"b_snap2.parent <> b_snap"
(Db.VM.get_parent ~__context ~self:b_snap2)b_snap;
(Db.VM.get_parent ~__context ~self:b_snap2)b_snap

let test =
"test_db_upgrade" >:::
[
"upgrade_vm_memory_for_dmc" >:: upgrade_vm_memory_for_dmc;
"upgrade_bios" >:: upgrade_bios;
"update_snapshots" >:: update_snapshots;
]

0 comments on commit c112548

Please sign in to comment.