From 23e5ecbdbb4b37c6c6666ff6b2d6d057c266fd15 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Thu, 5 Jul 2018 23:01:11 +0300 Subject: Tests: ensure volume deletion works when intended. It could have failed without anyone noticing. Added 'xfail' - do we expect to fail in deletion (and changed tests accordingly) On the way, ensure stdout and stderr are logged in case of such failures. Change-Id: Ibdf7a43cadb0393707a6c68c19a664453a971eb1 Signed-off-by: Yaniv Kaul --- .../functional/glusterd/test_volume_operations.py | 46 ++++++++++++---------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'tests/functional/glusterd/test_volume_operations.py') diff --git a/tests/functional/glusterd/test_volume_operations.py b/tests/functional/glusterd/test_volume_operations.py index fc8d8b0b6..47807c6f9 100644 --- a/tests/functional/glusterd/test_volume_operations.py +++ b/tests/functional/glusterd/test_volume_operations.py @@ -179,11 +179,12 @@ class TestVolumeCreate(GlusterBaseClass): g.log.info("Stopping a non existing volume is failed") # Deleting a non existing volume should fail - ret = volume_delete(self.mnode, "no_vol") - self.assertTrue(ret, "Expected: It should fail to delete a " - "non existing volume. Actual:Successfully deleted " - "a non existing volume") - g.log.info("Deleting a non existing volume is failed") + self.assertTrue( + volume_delete(self.mnode, "no_vol", xfail=True), + "Expected: It should fail to delete a " + "non existing volume. Actual:Successfully deleted " + "a non existing volume" + ) # Detach a server and try to create volume with node # which is not in cluster @@ -220,11 +221,14 @@ class TestVolumeCreate(GlusterBaseClass): g.log.info("Starting a already started volume is Failed.") # Deleting a volume without stopping should fail - ret = volume_delete(self.mnode, self.volname) - self.assertFalse(ret, ("Expected: It should fail to delete a volume" - " without stopping. Actual: Successfully " - "deleted a volume without stopping it")) - g.log.error("Failed to delete a volume without stopping it") + self.assertTrue( + volume_delete(self.mnode, self.volname, xfail=True), + "Expected: It should fail to delete a volume" + " without stopping. Actual: Successfully " + "deleted a volume without stopping it" + ) + g.log.info("Expected: volume delete should fail without " + "stopping volume: %s", self.volname) # Stopping a volume should succeed ret, _, _ = volume_stop(self.mnode, self.volname) @@ -239,16 +243,18 @@ class TestVolumeCreate(GlusterBaseClass): g.log.info("Volume stop is failed on already stopped volume") # Deleting a volume should succeed - ret = volume_delete(self.mnode, self.volname) - self.assertTrue(ret, ("Volume delete is failed")) - g.log.info("Volume delete is success") - - # Deleting a non existing volume should fail - ret = volume_delete(self.mnode, self.volname) - self.assertTrue(ret, "Expected: It should fail to delete a non " - "existing volume. Actual:Successfully deleted a " - "non existing volume") - g.log.info("Volume delete is failed for non existing volume") + self.assertTrue( + volume_delete(self.mnode, self.volname), + "Volume delete is failed" + ) + + # Deleting an already deleted volume should fail + self.assertTrue( + volume_delete(self.mnode, self.volname, xfail=True), + "Expected: It should fail to delete an " + "already deleted volume. Actual:Successfully " + "deleted an already deleted volume" + ) # Volume info command should succeed ret = get_volume_info(self.mnode) -- cgit