Adam Litke has uploaded a new change for review. Change subject: tests: add validate_domain_has_garbage helper ......................................................................
tests: add validate_domain_has_garbage helper Many of the VolumeArtifacts failure case tests check that the domain has garbage after the failed operation. Extract this logic into a helper and move it to the common class so it can be shared by the block tests. Change-Id: Ide6d9bc921121b6a90dea31685b8e8c4c37ec1c3 Signed-off-by: Adam Litke <[email protected]> --- M tests/storage_volume_artifacts_test.py 1 file changed, 12 insertions(+), 16 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/64/56864/1 diff --git a/tests/storage_volume_artifacts_test.py b/tests/storage_volume_artifacts_test.py index 59eb901..565daa5 100644 --- a/tests/storage_volume_artifacts_test.py +++ b/tests/storage_volume_artifacts_test.py @@ -154,6 +154,14 @@ artifacts.commit() self.assertIn(self.vol_id, env.sd_manifest.getAllVolumes()) + def validate_domain_has_garbage(self, sd_manifest): + # Checks that existing garbage on the storage domain prevents creation + # of these artifacts again. + artifacts = sd_manifest.get_volume_artifacts( + self.img_id, self.vol_id) + self.assertRaises(se.DomainHasGarbage, artifacts.create, + *BASE_RAW_PARAMS) + class FileVolumeArtifactsTests(VolumeArtifactsTestsMixin, VdsmTestCase): @@ -180,6 +188,7 @@ self.assertRaises(ExpectedFailure, artifacts.create, *BASE_RAW_PARAMS) self.validate_new_image_path(artifacts) + self.validate_domain_has_garbage(env.sd_manifest) def test_new_image_create_lease_failure(self): # If we fail before the lease is created we will have a garbage image @@ -191,12 +200,7 @@ self.assertRaises(ExpectedFailure, artifacts.create, *BASE_RAW_PARAMS) self.validate_new_image_path(artifacts, has_md=True) - - # We cannot re-create in this state because garbage left behind - artifacts = env.sd_manifest.get_volume_artifacts( - self.img_id, self.vol_id) - self.assertRaises(se.DomainHasGarbage, artifacts.create, - *BASE_RAW_PARAMS) + self.validate_domain_has_garbage(env.sd_manifest) def test_new_image_create_container_failure(self): # If we fail before the container is created we will have a garbage @@ -209,12 +213,7 @@ *BASE_RAW_PARAMS) self.validate_new_image_path(artifacts, has_md=True, has_lease=True) - - # We cannot re-create in this state because garbage left behind - artifacts = env.sd_manifest.get_volume_artifacts( - self.img_id, self.vol_id) - self.assertRaises(se.DomainHasGarbage, artifacts.create, - *BASE_RAW_PARAMS) + self.validate_domain_has_garbage(env.sd_manifest) def test_garbage_image_dir(self): # Creating the an artifact using an existing garbage image directory is @@ -225,10 +224,7 @@ artifacts._create_metadata_artifact = self.failure self.assertRaises(ExpectedFailure, artifacts.create, *BASE_RAW_PARAMS) - artifacts = env.sd_manifest.get_volume_artifacts( - self.img_id, self.vol_id) - self.assertRaises(se.DomainHasGarbage, artifacts.create, - *BASE_RAW_PARAMS) + self.validate_domain_has_garbage(env.sd_manifest) # Invalid use of artifacts -- To view, visit https://gerrit.ovirt.org/56864 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ide6d9bc921121b6a90dea31685b8e8c4c37ec1c3 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
