Making PTL testsuite independent of PBSTestSuite

Hi Guys,

Currently all testsuites in PTL are need to be derived from PBSTestSuite class otherwise benchpress wont run the testsuites/testcases without -f option.

I think it’s better to make it more generic that a user can write a testsuite by inheriting unittest.TestCase and run them using PTL.

So for this we have to update PTL plugins.
Let me know if there are any issues or comments.

@vishwaks : Looks good to me.

Just to make sure I understand correctly what you are proposing: you are saying that you want to make pbs_benchpress capable of running tests from any test suite that inherits from unittest.TestCase, regardless of whether those tests are being written for PBSPro or some other software?

Yes, want to make generic.

@vishwaks Suggested changes sound good to me. Can you just summarize the internal changes involved in achieving this?

Sounds good, thanks @vishwaks. I do second @saritakh, please briefly describe the internal design of this, I think externally this won’t change anything so no need for an external design doc.

Thanks for the reply guys. Below is change in few files:

In fw/bin/pbs_benchpress

test_regex = r’(^(?:[\w]+|^)Test|^test_[(]*|.+(.py)?)’

This change is needed not to restrict a filename to include “pbs_”.

In lib/utils/plugins/ptl_test_info.py

def wantClass(self, cls):
    """
    Is the class wanted?
    """

- if not issubclass(cls, PBSTestSuite):
+ if not issubclass(cls, TestCase):
return False
- if cls.name == ‘PBSTestSuite’:
+ if cls.name == ‘TestCase’:
return False
self._tree.setdefault(cls.name, cls)
if len(cls.bases) > 0:
self.wantClass(cls.bases[0])
return False

In lib/utils/plugins/ptl_test_loader.py

def check_follow(self, cls, method=None):
    cname = cls.__name__

- if not issubclass(cls, PBSTestSuite):
+ if not issubclass(cls, TestCase):
return False
- if cname == ‘PBSTestSuite’:
+ if cname == ‘TestCase’:
- if ‘PBSTestSuite’ not in self._tests_list[self._only_ts]:
+ if ‘TestCase’ not in self._tests_list[self._only_ts]:
return False

Above are 2 file changes. The same changes need to be done on other plugins.(code representation is not good in above lines)
In plugins wherever we have used PBSTestSuite that should be replaced with unittest.TestCase.

Thanks

1 Like

Hi Guys, please provide your comments if any, otherwise I will go ahead with PR.

Changes summarized look good to me.