No subject


Wed Jun 13 23:53:29 UTC 2012


When import gluster fails, check if the test is running in the local source tree.
If the test is running in local source tree, do not skip and raise exceptipn.
If the test is running in the installed directory, and import gluster fails, that means vdsm-gluster is not installed, should skip.

Otherwise, if the user does not install vdsm-gluster, and runs the tests in the installed vdsm, he will see gluster related tests failing and get very confused.

Am I right?

Other developers may get confused with your code, if they do not meet the same problem before.  So, please explain a little bit more in the commit message.

....................................................
File tests/main.py
Line 67:                 raise
Twisted logic, suggest change a little bit.

if getattr(TestCaseBase, "_local_test", False):
    # running in local source tree
    raise
else:
    # running in installed directory
    raise SkipTest("can not import gluster, maybe vdsm-gluster is not installed")

Actually, I suggest encapsulate the logic into a function. Other test cases may reuse the function, if in future they want to detect if running in local src tree or installed tree.

....................................................
File tests/testrunner.py
Line 53:         self.log = logging.getLogger(self.__class__.__name__)
Consider encapsulate the "_local_test" thing to a class method here. I mean, you can write this:

class VdsmTestCase(unittest.TestCase):
    _local_test = False

    def __init__(self, *args, **kwargs):
        unittest.TestCase.__init__(self, *args, **kwargs)
        self.log = logging.getLogger(self.__class__.__name__)

    @classmethod
    def is_local_test(cls):
        return cls._local_test

Then in hackVdsmModule, you can say:

VdsmTestCase._local_test = True

Then in main.py, you can say:

if TestCaseBase.is_local_test:
    raise
else:
    skip

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic6ee0e5b6b550daa2506ac8192ffa8119ca40585
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>


More information about the vdsm-patches mailing list