Change in vdsm[master]: virt: recovery: test: fix typo

fromani at redhat.com fromani at redhat.com
Thu Feb 18 08:47:45 UTC 2016


Francesco Romani has uploaded a new change for review.

Change subject: virt: recovery: test: fix typo
......................................................................

virt: recovery: test: fix typo

A typo sneaked in the vdsm.virt.recovery.File.save() method.
It passed by because this code path is seldom exercised, because
is meant to catch a programming error[1].

This patch fixes the typo, and adds a test to prevent it to
happen again.

+++

[1] in a sneaky way, mostly due to backward compatibility
with surrounding code.
The old 3.6.x code just swallowed any error.
Now we have at least a log line.
A better fix would be to explode with exception,
but due to arcane intertwined flows, this may cause havoc.

Change-Id: Ifc0a58758e2878d3c5398e931982d6e193fcd9f1
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M tests/vmRecoveryTests.py
M vdsm/virt/recovery.py
2 files changed, 14 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/53689/1

diff --git a/tests/vmRecoveryTests.py b/tests/vmRecoveryTests.py
index 03e2373..174119e 100644
--- a/tests/vmRecoveryTests.py
+++ b/tests/vmRecoveryTests.py
@@ -48,6 +48,19 @@
                 with open(os.path.join(tmpdir, rec.name), 'rb') as f:
                     self.assertTrue(pickle.load(f))
 
+    def test_save_after_cleanup(self):
+
+        with fake.VM() as testvm, namedTemporaryDir() as tmpdir:
+            with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpdir + '/')]):
+                rec = recovery.File(testvm.id)
+                rec.save(testvm)
+
+                rec.cleanup()
+                self.assertEqual(os.listdir(tmpdir), [])
+
+                rec.save(testvm)  # must silently fail
+                self.assertEqual(os.listdir(tmpdir), [])
+
     def test_load(self):
 
         with fake.VM() as testvm, namedTemporaryDir() as tmpdir:
diff --git a/vdsm/virt/recovery.py b/vdsm/virt/recovery.py
index e1da1d2..a01c0bd 100644
--- a/vdsm/virt/recovery.py
+++ b/vdsm/virt/recovery.py
@@ -94,7 +94,7 @@
         data = self._collect(vm)
         with self._lock:
             if self._path is None:
-                self.log.debug('save after cleanup')
+                self._log.debug('save after cleanup')
             else:
                 self._dump(data)
 


-- 
To view, visit https://gerrit.ovirt.org/53689
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc0a58758e2878d3c5398e931982d6e193fcd9f1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list