[Kimchi-devel] [PATCH][Kimchi 2/2] Add test to live snapshot

Ramon Medeiros ramonn at linux.vnet.ibm.com
Thu Jan 19 18:06:22 UTC 2017


Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
 tests/test_model.py |  6 ++++--
 tests/test_rest.py  | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/tests/test_model.py b/tests/test_model.py
index f3da835..af69254 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -204,8 +204,10 @@ class ModelTests(unittest.TestCase):
             info = inst.vm_lookup('kimchi-vm')
             self.assertEquals('running', info['state'])
 
-            self.assertRaises(InvalidOperation, inst.vmsnapshots_create,
-                              u'kimchi-vm')
+            task =  inst.vmsnapshots_create(u'kimchi-vm')
+            inst.task_wait(task['id'])
+            task = inst.task_lookup(task['id'])
+            self.assertEquals('finished', task['status'])
 
             inst.vm_poweroff(u'kimchi-vm')
             vm = inst.vm_lookup(u'kimchi-vm')
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 56b8a89..2af465c 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -403,6 +403,25 @@ class RestTests(unittest.TestCase):
         resp = self.request('/plugins/kimchi/vms/test-vm/clone', '{}', 'POST')
         self.assertEquals(400, resp.status)
 
+        # Create a snapshot on running vm VM
+        params = {'name': 'test-snap2'}
+        resp = self.request('/plugins/kimchi/vms/test-vm/snapshots',
+                            json.dumps(params),
+                            'POST')
+        self.assertEquals(202, resp.status)
+        task = json.loads(resp.read())
+        wait_task(self._task_lookup, task['id'])
+        task = json.loads(
+            self.request('/plugins/kimchi/tasks/%s' % task['id']).read()
+        )
+        self.assertEquals('finished', task['status'])
+
+        # Delete a snapshot
+        resp = self.request('/plugins/kimchi/vms/test-vm/snapshots/%s' %
+                            params['name'], '{}', 'DELETE')
+        self.assertEquals(204, resp.status)
+
+
         # Force poweroff the VM
         resp = self.request('/plugins/kimchi/vms/test-vm/poweroff', '{}',
                             'POST')
-- 
2.7.4



More information about the Kimchi-devel mailing list