Francesco Romani has uploaded a new change for review.

Change subject: tests: initial tests for vm libvirt callbacks
......................................................................

tests: initial tests for vm libvirt callbacks

This patch adds initial tests for the libvirt callbacks
of vdsm.virt.Vm.

The dispatching logic for the libvirt callbacks in clientIF
is not covered by this patch.

Change-Id: I059ef6cd42e8cfa03e2891dade00ff21e4c435bb
Signed-off-by: Francesco Romani <[email protected]>
---
M tests/vmTests.py
1 file changed, 23 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/28/27128/1

diff --git a/tests/vmTests.py b/tests/vmTests.py
index c431fb8..15bde59 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -773,7 +773,7 @@
 
 
 @contextmanager
-def FakeVM(params=None, devices=None):
+def FakeVM(params=None, devices=None, run=False):
     with namedTemporaryDir() as tmpDir:
         with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpDir + '/'),
                                (libvirtconnection, 'get',
@@ -783,6 +783,7 @@
             fake = vm.Vm(None, vmParams)
             fake.guestAgent = FakeGuestAgent()
             fake.conf['devices'] = [] if devices is None else devices
+            fake._guestCpuRunning = run
             yield fake
 
 
@@ -919,3 +920,24 @@
             res = fake.getStats()
             self.assertIn('balloonInfo', res)
             self.assertIn('balloon_cur', res['balloonInfo'])
+
+
+class TestLibVirtCallbacks(TestCaseBase):
+    FAKE_ERROR = 'EFAKERROR'
+
+    def test_onIOErrorPause(self):
+        with FakeVM(run=True) as fake:
+            self.assertTrue(fake._guestCpuRunning)
+            error = 'EFAKEERROR'
+            fake._onIOError('fakedev', self.FAKE_ERROR,
+                            libvirt.VIR_DOMAIN_EVENT_IO_ERROR_PAUSE)
+            self.assertFalse(fake._guestCpuRunning)
+            self.assertEqual(fake.conf.get('pauseCode'), self.FAKE_ERROR)
+
+    def test_onIOErrorReport(self):
+        with FakeVM(run=True) as fake:
+            self.assertTrue(fake._guestCpuRunning)
+            fake._onIOError('fakedev', self.FAKE_ERROR,
+                            libvirt.VIR_DOMAIN_EVENT_IO_ERROR_REPORT)
+            self.assertTrue(fake._guestCpuRunning)
+            self.assertNotEquals(fake.conf.get('pauseCode'), self.FAKE_ERROR)


-- 
To view, visit http://gerrit.ovirt.org/27128
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I059ef6cd42e8cfa03e2891dade00ff21e4c435bb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to