pbs_job_array_comment.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 TestJobArrayComment(TestFunctional):
  38. """
  39. Testing job array comment is accurate
  40. """
  41. def test_job_array_comment(self):
  42. """
  43. Testing job array comment is correct when one or more sub jobs
  44. are rejected by mom
  45. """
  46. attr = {'resources_available.ncpus': 10}
  47. self.server.manager(MGR_CMD_SET, NODE, attr)
  48. attr = {'job_history_enable': 'true'}
  49. self.server.manager(MGR_CMD_SET, SERVER, attr)
  50. # create a mom hook that rejects and deletes subjob 0, 5, and 7
  51. hook_name = "reject_subjob"
  52. hook_body = (
  53. "import pbs\n"
  54. "import re\n"
  55. "e = pbs.event()\n"
  56. "jid = str(e.job.id)\n"
  57. "if re.match(r'[0-9]*\[[057]\]', jid):\n"
  58. " e.job.delete()\n"
  59. " e.reject()\n"
  60. "else:\n"
  61. " e.accept()\n"
  62. )
  63. attr = {'event': 'execjob_begin', 'enabled': 'True'}
  64. self.server.create_import_hook(hook_name, attr, hook_body)
  65. # Check if the hook copy was successful
  66. self.server.log_match("successfully sent hook file.*" +
  67. hook_name + ".PY", regexp=True,
  68. max_attempts=60, interval=2)
  69. test_job_array = Job(TEST_USER, attrs={
  70. ATTR_J: '0-9',
  71. 'Resource_List.select': 'ncpus=1'
  72. })
  73. test_job_array.set_sleep_time(1)
  74. jid = self.server.submit(test_job_array)
  75. attr = {
  76. ATTR_state: 'B',
  77. ATTR_comment: (MATCH_RE, 'Job Array Began at .*')
  78. }
  79. self.server.expect(JOB, attr, id=jid, attrop=PTL_AND)
  80. self.server.expect(JOB, {ATTR_comment: 'Not Running: PBS Error:' +
  81. ' Execution server rejected request' +
  82. ' and failed'},
  83. id=test_job_array.create_subjob_id(jid, 0),
  84. extend='x')
  85. attr = {
  86. ATTR_state: 'R',
  87. ATTR_comment: (MATCH_RE, 'Job run at .*')
  88. }
  89. self.server.expect(JOB, attr, extend='x',
  90. id=test_job_array.create_subjob_id(jid, 1),
  91. attrop=PTL_AND)
  92. self.server.expect(JOB, {ATTR_comment: 'Not Running: PBS Error:' +
  93. ' Execution server rejected request' +
  94. ' and failed'},
  95. id=test_job_array.create_subjob_id(jid, 5),
  96. extend='x')
  97. self.server.expect(JOB, {ATTR_comment: 'Not Running: PBS Error:' +
  98. ' Execution server rejected request' +
  99. ' and failed'},
  100. id=test_job_array.create_subjob_id(jid, 7),
  101. extend='x')