finalizer.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. '''
  2. Created on Nov 5, 2013
  3. @author: tbordaz
  4. '''
  5. import os
  6. import sys
  7. import time
  8. import ldap
  9. import logging
  10. import socket
  11. import time
  12. import logging
  13. import pytest
  14. from lib389 import DirSrv, Entry, tools
  15. from lib389.tools import DirSrvTools
  16. from lib389._constants import DN_DM
  17. from lib389.properties import *
  18. log = logging.getLogger(__name__)
  19. global installation_prefix
  20. installation_prefix=os.getenv('PREFIX')
  21. def test_finalizer():
  22. global installation_prefix
  23. # for each defined instance, remove it
  24. for args_instance in ALL_INSTANCES:
  25. if installation_prefix:
  26. # overwrite the environment setting
  27. args_instance[SER_DEPLOYED_DIR] = installation_prefix
  28. instance = DirSrv(verbose=True)
  29. instance.allocate(args_instance)
  30. if instance.exists():
  31. instance.delete()
  32. # remove any existing backup for this instance
  33. instance.clearBackupFS()
  34. def run_isolated():
  35. '''
  36. run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
  37. To run isolated without py.test, you need to
  38. - set the installation prefix
  39. - run this program
  40. '''
  41. global installation_prefix
  42. installation_prefix = None
  43. test_finalizer()
  44. if __name__ == '__main__':
  45. run_isolated()