Adam Litke has uploaded a new change for review.
Change subject: tests: Move TestingJob to sdmtestlib
......................................................................
tests: Move TestingJob to sdmtestlib
The TestingJob currently used in storage_sdm_api_test.py is needed for testing
Job handling in the hsm tests. Move it to a common place where it can be
reused.
Change-Id: Ibf4b1707f3e6a56918a52511f23e21ead1bd5adc
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M tests/sdmtestlib.py
M tests/storage_sdm_api_test.py
2 files changed, 21 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/61256/1
diff --git a/tests/sdmtestlib.py b/tests/sdmtestlib.py
index 8f95218..2844a6c 100644
--- a/tests/sdmtestlib.py
+++ b/tests/sdmtestlib.py
@@ -18,8 +18,28 @@
#
import time
+import uuid
+
+from vdsm import jobs
+from vdsm.storage.threadlocal import vars
+
+from storage.sdm.api import base
def wait_for_job(job):
while job.active:
time.sleep(1)
+
+
+class TestingJob(base.Job):
+
+ def __init__(self, exception=None):
+ job_id = str(uuid.uuid4())
+ super(TestingJob, self).__init__(job_id, 'testing_job',
'host_id')
+ self.exception = exception
+
+ def _run(self):
+ assert(self.status == jobs.STATUS.RUNNING)
+ assert(vars.job_id == self.id)
+ if self.exception:
+ raise self.exception
diff --git a/tests/storage_sdm_api_test.py b/tests/storage_sdm_api_test.py
index a5f00bc..3c4367e 100644
--- a/tests/storage_sdm_api_test.py
+++ b/tests/storage_sdm_api_test.py
@@ -18,16 +18,12 @@
# Refer to the README and COPYING files for full details of the license
#
-import uuid
-
from testlib import VdsmTestCase
-from sdmtestlib import wait_for_job
+from sdmtestlib import TestingJob, wait_for_job
from vdsm import jobs
from vdsm import exception
from vdsm.storage.threadlocal import vars
-
-from storage.sdm.api import base
class ApiBaseTests(VdsmTestCase):
@@ -63,17 +59,3 @@
self.run_job(job)
self.assertEqual(jobs.STATUS.FAILED, job.status)
self.assertIsInstance(job.error, exception.VdsmException)
-
-
-class TestingJob(base.Job):
-
- def __init__(self, exception=None):
- job_id = str(uuid.uuid4())
- super(TestingJob, self).__init__(job_id, 'testing_job',
'host_id')
- self.exception = exception
-
- def _run(self):
- assert(self.status == jobs.STATUS.RUNNING)
- assert(vars.job_id == self.id)
- if self.exception:
- raise self.exception
--
To view, visit
https://gerrit.ovirt.org/61256
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf4b1707f3e6a56918a52511f23e21ead1bd5adc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>