Change in vdsm[master]: tests: Introduce indirection tests for storage refactoring

nsoffer at redhat.com nsoffer at redhat.com
Tue Jul 28 20:24:19 UTC 2015


Nir Soffer has posted comments on this change.

Change subject: tests: Introduce indirection tests for storage refactoring
......................................................................


Patch Set 1: Code-Review-1

(2 comments)

Nice, suggested way to simplify and improve test isolation.

https://gerrit.ovirt.org/#/c/44098/1/tests/sdm_indirection_tests.py
File tests/sdm_indirection_tests.py:

Line 115:             return FakeBlockStorageDomain()
Line 116:         elif domType == 'file':
Line 117:             return FakeFileStorageDomain()
Line 118:         else:
Line 119:             raise ValueError("%s is not a valid domain type" % domType)
You can simplify this by having base class implementing the tests:

    class DomainTestMixin:
        
        # Must be implemented by subclass
        fakeDomClass = None

        def setUp(self):
            self.dom = self.fakeDomClass()

        @permutations()    
        def test_common(self):
            ...

    class TestBlock(DomainTestMixin, VdsmTestCase):
        fakeDomClass = FakeBlockStorageDomain

        def test_block_only_thing(self):
            ...

     class TestFile(DomainTestMixin, VdsmTestCase):
        fakeDomClass = FakeFileStorageDomain
        
        def test_file_only_thing(self):
            ...
     
This should run all permuations once for file domain and once for block domain, and the block/file specific tests.
Line 120: 
Line 121:     def _check(self, domType, fn, args, result):
Line 122:         dom = self._get_domain(domType)
Line 123:         getattr(dom, fn)(*args)


Line 160:         ['getMDPath'],
Line 161:         ['getMetaParam', 1],
Line 162:     ])
Line 163:     def test_domain_funcs(self, fn, nargs=0):
Line 164:         for domType in 'file', 'block':
This should go into the permutations, so failure of block domain with some function is isolated form success of file domain for the same function.
Line 165:             self.check_call(domType, fn, nargs)
Line 166: 
Line 167:     @permutations([
Line 168:         ['getVAllocSize', 2]


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I336b543aa7ba019c91104e860a28bb40acc268b9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list