pbs_test_run_count.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 Test_run_count(TestFunctional):
  38. """
  39. Test suite to test run_count attribute of a job.
  40. """
  41. def create_reject_begin_hook(self):
  42. start_time = int(time.time())
  43. name = "h1"
  44. body = ("import pbs\n"
  45. "e=pbs.event()\n"
  46. "e.reject()\n")
  47. attr = {'event': 'execjob_begin'}
  48. self.server.create_import_hook(name, attr, body)
  49. # make sure hook has propogated to mom
  50. self.mom.log_match("h1.HK;copy hook-related file request received",
  51. existence=True, starttime=start_time)
  52. def check_run_count(self, input_count="0", output_count="21"):
  53. """
  54. Creates a hook, submits a job and checks the run count.
  55. input_count is the user requested run_count and output_count
  56. is the run_count attribute of job from the scheduler.
  57. """
  58. # Create an execjob_begin hook that rejects the job
  59. self.create_reject_begin_hook()
  60. a = {ATTR_W: "run_count=" + input_count}
  61. j = Job(TEST_USER, a)
  62. jid = self.server.submit(j)
  63. self.server.expect(JOB, {'job_state': "H", 'run_count': output_count},
  64. attrop=PTL_AND, id=jid)
  65. def test_run_count_overflow(self):
  66. """
  67. Submit a job that requests run count exceeding 64 bit integer limit
  68. and see that such a job gets rejected.
  69. """
  70. a = {ATTR_W: "run_count=18446744073709551616"}
  71. j = Job(TEST_USER, a)
  72. try:
  73. self.server.submit(j)
  74. except PbsSubmitError as e:
  75. self.assertTrue("illegal -W value" in e.msg[0])
  76. def test_large_run_count(self):
  77. """
  78. Submit a job with a large (>20) but valid run_count value and create
  79. an execjob_begin hook that will reject the job. Check run_count to
  80. make sure that the job goes to held state just after one rejection.
  81. This is so because if run_count is greater than 20 then PBS will hold
  82. the job upon the first rejection from mom.
  83. """
  84. self.check_run_count(input_count="184", output_count="185")
  85. def test_less_than_20_run_count(self):
  86. """
  87. Submit a job with a run count 15, create a execjob_begin
  88. hook to reject the job and test that the job goes
  89. into held state after 5 rejections
  90. """
  91. self.check_run_count(input_count="15", output_count="21")