Yoav Kleinberger has uploaded a new change for review.
Change subject: beautify and better __exit__ strategy
......................................................................
beautify and better __exit__ strategy
1. cleaned up the code a bit, added external runner script
2. __exit__ now cleans up the LVs left by the test - this is still not
perfect due to sanlock issues
Change-Id: I72a336ea08605f7acac807313f8c5a46cd14ab57
Signed-off-by: Yoav Kleinberger <ykleinbe(a)redhat.com>
---
A run_new_functional_tests.sh
M tests/functional/new/basic_storage_domain_test.py
M tests/functional/new/testlib/testcontexts/iscsi.py
3 files changed, 20 insertions(+), 41 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/32252/1
diff --git a/run_new_functional_tests.sh b/run_new_functional_tests.sh
new file mode 100755
index 0000000..af59981
--- /dev/null
+++ b/run_new_functional_tests.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+sudo PYTHONPATH=lib:vdsm:tests/functional/new nosetests -s --nologcapture
tests/functional/new/basic_storage_domain_test.py
diff --git a/tests/functional/new/basic_storage_domain_test.py
b/tests/functional/new/basic_storage_domain_test.py
index 37937ae..b50f2a9 100644
--- a/tests/functional/new/basic_storage_domain_test.py
+++ b/tests/functional/new/basic_storage_domain_test.py
@@ -1,35 +1,19 @@
-##############
import sys
-sys.path.insert(0, 'lib')
-sys.path.insert(0, 'vdsm')
-##############
import uuid
import storage.volume
import storage.image
import logging
-logging.basicConfig(level=logging.DEBUG, format='%(asctime)s TEST %(levelname)s:
%(message)s')
-from .testlib import vdsmtestcontext
-from .testlib import controlvdsm
+from testlib import vdsmtestcontext
+from testlib import controlvdsm
-class TestBasicLocalFSStorageDomain:
+class TestBasicStorageDomain:
+ @classmethod
+ def setup_class(cls):
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s TEST
%(levelname)s: %(message)s')
+
def setup(self):
controlVDSM = controlvdsm.ControlVDSM()
controlVDSM.cleanup()
-
- def notest_create_and_destroy_storage_domain(self):
- with vdsmtestcontext.vdsmTestContext('localfs') as (vdsm, verify):
- storageServerID = vdsm.connectStorageServer()
- verify.storageServerConnected()
-
- domainID = vdsm.createStorageDomain()
- verify.storageDomainCreated(domainID)
-
- vdsm.formatStorageDomain(domainID)
- verify.storageDomainGone(domainID)
-
-#what's this when using ISCSI?
- vdsm.disconnectStorageServer(storageServerID)
- verify.storageServerDisconnected()
def test_create_volume(self):
with vdsmtestcontext.vdsmTestContext('iscsi') as (vdsm, verify):
@@ -46,7 +30,7 @@
vdsm.spmStart()
verify.spmStarted(poolID)
- vdsm.activateStorageDomain()
+ vdsm.activateStorageDomain(domainID, poolID)
GIGABYTE = 1024 ** 3
taskID = vdsm.createVolume(1 * GIGABYTE)
verify.volumeCreated(taskID)
diff --git a/tests/functional/new/testlib/testcontexts/iscsi.py
b/tests/functional/new/testlib/testcontexts/iscsi.py
index c81ceff..2df2429 100644
--- a/tests/functional/new/testlib/testcontexts/iscsi.py
+++ b/tests/functional/new/testlib/testcontexts/iscsi.py
@@ -18,23 +18,10 @@
class Verify(base.Verify):
def __init__(self, iqn, volumeGroup, vdsm, volumeID):
-### store iqn here
self._iqn = iqn
self._volumeGroup = volumeGroup
self._vdsm = vdsm
self._volumeID = volumeID
-
- def assertPathExists(self, path, link = False):
- if link:
- assert os.path.lexists(path)
- else:
- assert os.path.exists(path)
-
- def assertPathDoesNotExist(self, path, link = False):
- if link:
- assert not os.path.lexists(path)
- else:
- assert not os.path.exists(path)
def storageServerConnected(self):
targetNameFiles =
glob.glob('/sys/devices/platform/host*/session*/iscsi_session/*/targetname')
@@ -107,7 +94,6 @@
self._storageFile = os.path.join(self._testDirectory, 'testfile')
self._fileioBackstore = self._randomName('backfile')
logging.info('using %s, %s' % (self._fileioBackstore,
self._storageFile))
-####
self._targetcli('/backstores/fileio create %s %s 30G' %
(self._fileioBackstore, self._storageFile))
self._targetcli('/iscsi create %s' % self._iqn)
self._targetcli('/iscsi/%s/tpg1/luns create /backstores/fileio/%s' %
(self._iqn, self._fileioBackstore))
@@ -116,6 +102,13 @@
return self, Verify(self._iqn, self._volumeGroup, self._vdsm, self._volumeID)
def __exit__(self, *args):
+ doubleDashed = self._volumeGroup['uuid'].replace('-',
'--')
+ mapperDevices = glob.glob('/dev/mapper/%s*' % doubleDashed ) + [
'/dev/mapper/%s' % self._lunGUID ]
+ for device in mapperDevices:
+ logging.info('removing %s' % device)
+ result = subprocess.call('sudo dmsetup remove %s' % device,
shell=True)
+ if result != 0:
+ logging.warning('could not remove %s' % device)
self._targetcli( '/iscsi delete %s' % self._iqn )
self._targetcli( '/backstores/fileio delete %s' % self._fileioBackstore
)
shutil.rmtree(self._testDirectory)
@@ -175,8 +168,8 @@
result = self._vdsm.spmStart(self._poolID, -1, '-1',
SCSI_FENCING_DEPRECATED, RECOVERY_MODE_DEPRECATED)
self.verifyVDSMSuccess(result)
- def activateStorageDomain(self):
- result = self._vdsm.activateStorageDomain(self._domainID(), self._poolID)
+ def activateStorageDomain(self, domainID, poolID):
+ result = self._vdsm.activateStorageDomain(domainID,poolID)
self.verifyVDSMSuccess(result)
def _createVG(self):
@@ -185,6 +178,7 @@
logging.info('createVG returned %s' % result)
self.verifyVDSMSuccess(result)
self._volumeGroup[ 'vgs_uuid' ] = result[ 'uuid' ]
+ self._lunGUID = lun['GUID']
def _newUUID(self):
return str(uuid.uuid4())
@@ -194,7 +188,6 @@
self._createStorageDomain()
return self._volumeGroup['uuid']
-#####
def embed(self,msg):
print 'embedding: %s' % msg
import IPython
--
To view, visit
http://gerrit.ovirt.org/32252
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I72a336ea08605f7acac807313f8c5a46cd14ab57
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yoav Kleinberger <ykleinbe(a)redhat.com>