pbs_job_purge.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # coding: utf-8
  2. # Copyright (C) 1994-2018 Altair Engineering, Inc.
  3. # For more information, contact Altair at www.altair.com.
  4. #
  5. # This file is part of the PBS Professional ("PBS Pro") software.
  6. #
  7. # Open Source License Information:
  8. #
  9. # PBS Pro is free software. You can redistribute it and/or modify it under the
  10. # terms of the GNU Affero General Public License as published by the Free
  11. # Software Foundation, either version 3 of the License, or (at your option) any
  12. # later version.
  13. #
  14. # PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
  15. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. # FOR A PARTICULAR PURPOSE.
  17. # See the GNU Affero General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Affero General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. # Commercial License Information:
  23. #
  24. # For a copy of the commercial license terms and conditions,
  25. # go to: (http://www.pbspro.com/UserArea/agreement.html)
  26. # or contact the Altair Legal Department.
  27. #
  28. # Altair’s dual-license business model allows companies, individuals, and
  29. # organizations to create proprietary derivative works of PBS Pro and
  30. # distribute them - whether embedded or bundled with other software -
  31. # under a commercial license agreement.
  32. #
  33. # Use of Altair’s trademarks, including but not limited to "PBS™",
  34. # "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
  35. # trademark licensing policies.
  36. from tests.functional import *
  37. class TestJobPurge(TestFunctional):
  38. """
  39. This test suite tests the Job purge process
  40. """
  41. def test_job_files_after_execution(self):
  42. """
  43. Checks the job related files and ensures that files are
  44. deleted successfully upon job completion
  45. """
  46. a = {'resources_available.ncpus': 3}
  47. self.server.manager(MGR_CMD_SET, NODE, a, self.mom.shortname)
  48. jobs_dir_path = os.path.join(
  49. self.server.pbs_conf['PBS_HOME'], 'mom_priv', 'jobs/')
  50. # Submit a normal and an array job
  51. j = Job(TEST_USER)
  52. j.create_script(body="sleep 5")
  53. jid = self.server.submit(j)
  54. self.server.expect(JOB, {'job_state': 'R'}, id=jid)
  55. self.server.expect(JOB, 'queue', op=UNSET, id=jid)
  56. j1 = Job(TEST_USER)
  57. j1.create_script(body="sleep 5")
  58. j1.set_attributes({ATTR_J: '1-2'})
  59. jid_1 = self.server.submit(j1)
  60. jobid_list = [jid, j1.create_subjob_id(jid_1, 1),
  61. j1.create_subjob_id(jid_1, 2)]
  62. self.server.expect(JOB, {'job_state': 'B'}, id=jid_1)
  63. self.server.expect(JOB, 'queue', op=UNSET, id=jid_1)
  64. # Checking the job control(.JB) file, job script(.SC) file
  65. # and job task(.TK) directory after successful job execution
  66. jobs_suffix_list = ['.JB', '.SC', '.TK']
  67. for jobid in jobid_list:
  68. for suffix in jobs_suffix_list:
  69. job_file = jobs_dir_path + jobid + suffix
  70. self.assertFalse(self.du.isfile(path=job_file, sudo=True))