Usage of tearDown in PTL

Can someone explain whether teardown from parent class (PbsTestSuite) should be called explicitly or not inside a PTL test case? I thought teardown is not necessary as it will do duplicate things as setup but looking at the code I don’t think it is doing anything besides stopping process monitoring.
I think I am confused as when teardown is necessary and when not? In other words when should one define tearDown explicitly in his test and if one does should it be calling parentclass tearDown?


@anamika In one liner answer, if you have custom tearDown in your testsuite then you have to call parent class’ tearDown explicitly else no need.

Now when should user create custom tearDown in his/her testsuite:
If you are doing something which PTL’s revert part doesn’t take care like changing system configuration then user should define custom tearDown in testsuite then first do revert of whatever system configuration is changed then call parent class’ tearDown explicitly.

Suggestion: It is always good practice to try first without defining custom tearDown then if require then only define custom tearDown.


Thanks much Hiren. This is helpful. Is this documented somewhere?

BTW, if PTL revert function don’t revert some of PBS settings then should that be treated as PTL bug/enhancements?

Will add it to FAQ section of PTL.


@anamika and @all I have updated for when to use custom tearDown. Please have a look and let me know if anything is missing.

Thanks for adding Hiren. point b look redundant with point a. May be update point b saying if custom teardown is defined then parent class tearDown() must be called towards the end of custom tearDown().

@anamika I don’t think it’s redundant, however it was little bit confusing but anyways I have modified it to make it clear. If it still not clear then please feel free to update it.

Hi Hiren. Can you please elaborate what changing system configuration means? Maybe a few examples?
Does creating custom vnodes counts as changing system configuration?


Hi @minghui

What I meant by system configuration is, lets say test is installing some helper tools in system or changing content of /etc/hosts or $HOME/.rhosts or temp file/directory created without using DshUtils().mk*() method or changing environment variables as per test need then those changes won’t be reverted by PTL, those kind a change test has to revert by custom tearDown.

Nope, From PTL perspective, it is PBS related changed, and PTL should revert that.

Hope this help!