Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test for CA-91480: VM destroy skips missing blobs

Xapi_vm_helpers.destroy would fail if a VM had a reference to a non-existant
blob, which would happen when the VM had been imported. This would prevent the
rest of the function from running, leaving ghost objects in the database after
an import was cancelled.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
  • Loading branch information...
commit 1fa3fb2d43371660fcb5eac9179ffcd7946ed9ba 1 parent dbd1565
Mike McClurg authored
View
1  ocaml/test/OMakefile
@@ -27,5 +27,6 @@ OCAML_OBJS = \
test_basic \
test_pool_db_backup \
test_xapi_db_upgrade \
+ test_ca91480 \
OCamlProgram(suite, suite $(OCAML_OBJS) )
View
1  ocaml/test/suite.ml
@@ -45,6 +45,7 @@ let base_suite =
test_basic;
test_db_backup;
test_db_upgrade;
+ Test_ca91480.test;
]
let _ = run_test_tt_main base_suite
View
32 ocaml/test/test_ca91480.ml
@@ -0,0 +1,32 @@
+(* Fixture: Create DB with VM. VM has records for Blobs, Appliances,
+ VBDs, VIFs, VGPUs, PCIs, VM_metrics, and VM_guest_metrics, but none
+ of these objects should actually exist in the DB. *)
+
+open OUnit
+open Test_common
+
+let setup_fixture () =
+ let __context = make_test_database () in
+ let self = make_vm ~__context () in
+
+ let fake_v f = f ~__context ~self ~value:(Ref.make ())
+ and fake_m f = f ~__context ~self ~key:"fake" ~value:(Ref.make ())
+ and fake_l f = f ~__context ~self ~value:[(Ref.make ())] in
+
+ fake_m Db.VM.add_to_blobs ;
+ fake_v Db.VM.set_appliance ;
+ fake_l Db.VM.set_attached_PCIs ;
+ fake_v Db.VM.set_metrics ;
+ fake_v Db.VM.set_guest_metrics ;
+
+ __context, self
+
+let test_vm_destroy () =
+ let __context, self = setup_fixture () in
+ Xapi_vm_helpers.destroy ~__context ~self
+
+let test =
+ "test_ca91480" >:::
+ [
+ "test_vm_destroy" >:: test_vm_destroy;
+ ]
Please sign in to comment.
Something went wrong with that request. Please try again.