Adam Litke has uploaded a new change for review.

Change subject: tests: SDM.copy_data test for abort while copying
......................................................................

tests: SDM.copy_data test for abort while copying

When a copy operation is aborted the final job status should be aborted
and the destination volume should be illegal.

Change-Id: I740d9ba42e3bd70865eadcb024ce6d9d8da0af95
Signed-off-by: Adam Litke <[email protected]>
---
M tests/storage_sdm_copy_data_test.py
1 file changed, 28 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/79/64479/1

diff --git a/tests/storage_sdm_copy_data_test.py 
b/tests/storage_sdm_copy_data_test.py
index fef85cc..5080aa8 100644
--- a/tests/storage_sdm_copy_data_test.py
+++ b/tests/storage_sdm_copy_data_test.py
@@ -19,6 +19,7 @@
 #
 from __future__ import absolute_import
 
+import threading
 import uuid
 from contextlib import contextmanager
 
@@ -29,6 +30,7 @@
 from storagetestlib import make_qemu_chain, write_qemu_chain, verify_qemu_chain
 from storagetestlib import ChainVerificationError
 from testlib import VdsmTestCase, expandPermutations, permutations
+from testlib import start_thread
 from testlib import wait_for_job
 
 from vdsm import jobs
@@ -252,10 +254,30 @@
             self.assertEqual(final_status, job.status)
             self.assertEqual(final_legality, dst_vol.getLegality())
 
+    @permutations((('file',), ('block',)))
+    def test_abort_during_copy(self, env_type):
+        fmt = sc.RAW_FORMAT
+        with self.get_vols(env_type, fmt, fmt) as (src_chain, dst_chain):
+            src_vol = src_chain[0]
+            dst_vol = dst_chain[0]
+            source = dict(endpoint_type='div', sd_id=src_vol.sdUUID,
+                          img_id=src_vol.imgUUID, vol_id=src_vol.volUUID)
+            dest = dict(endpoint_type='div', sd_id=dst_vol.sdUUID,
+                        img_id=dst_vol.imgUUID, vol_id=dst_vol.volUUID)
+            fake_convert = FakeQemuConvertChecker(src_vol, dst_vol,
+                                                  ['/bin/read'])
+            with MonkeyPatchScope([(qemuimg, 'convert', fake_convert)]):
+                job_id = str(uuid.uuid4())
+                job = storage.sdm.api.copy_data.Job(job_id, 0, source, dest)
+                t = start_thread(job.run)
+                fake_convert.started.wait()
+                job.abort()
+                self.assertEqual(jobs.STATUS.ABORTED, job.status)
+                self.assertEqual(sc.ILLEGAL_VOL, dst_vol.getLegality())
+
     # TODO: Missing tests:
     # Copy between 2 different domains
     # Abort before copy
-    # Abort during copy
 
 
 class FakeQemuConvertChecker(object):
@@ -263,8 +285,12 @@
         self.src_vol = src_vol
         self.dst_vol = dst_vol
         self.command = command
+        self.started = threading.Event()
 
     def __call__(self, *args, **kwargs):
         assert sc.LEGAL_VOL == self.src_vol.getLegality()
         assert sc.ILLEGAL_VOL == self.dst_vol.getLegality()
-        return qemuimg.QemuImgOperation(self.command)
+        try:
+            return qemuimg.QemuImgOperation(self.command)
+        finally:
+            self.started.set()


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I740d9ba42e3bd70865eadcb024ce6d9d8da0af95
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <[email protected]>
_______________________________________________
vdsm-patches mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to