finalizer.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. from constants import *
  19. log = logging.getLogger(__name__)
  20. global installation_prefix
  21. installation_prefix=os.getenv('PREFIX')
  22. def test_finalizer():
  23. global installation_prefix
  24. # for each defined instance, remove it
  25. for args_instance in ALL_INSTANCES:
  26. if installation_prefix:
  27. # overwrite the environment setting
  28. args_instance[SER_DEPLOYED_DIR] = installation_prefix
  29. instance = DirSrv(verbose=True)
  30. instance.allocate(args_instance)
  31. if instance.exists():
  32. instance.delete()
  33. # remove any existing backup for this instance
  34. instance.clearBackupFS()
  35. def run_isolated():
  36. '''
  37. run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
  38. To run isolated without py.test, you need to
  39. - set the installation prefix
  40. - run this program
  41. '''
  42. global installation_prefix
  43. installation_prefix = None
  44. test_finalizer()
  45. if __name__ == '__main__':
  46. run_isolated()