pbs_moved_job.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 TestMovedJob(TestFunctional):
  38. """
  39. This test suite tests moved jobs between two servers
  40. """
  41. @timeout(500)
  42. def test_moved_job_history(self):
  43. """
  44. This test suite verifies that moved (M) job preserves in the system
  45. at least until the job is really finished on the target server.
  46. Supposing the job is finished, this test also checks whether
  47. the M job is removed after <job_history_duration>.
  48. """
  49. # Skip test if number of servers is not equal to two
  50. if len(self.servers) != 2:
  51. self.skipTest("test requires atleast two servers as input, " +
  52. "use -p servers=<server1:server2>,moms=<server1>")
  53. second_server = self.servers.keys()[1]
  54. attr = {'job_history_enable': 'True', 'job_history_duration': 5}
  55. self.servers[second_server].manager(MGR_CMD_SET, SERVER, attr)
  56. attr = {'queue_type': 'execution',
  57. 'started': 'True', 'enabled': 'True'}
  58. self.server.manager(MGR_CMD_CREATE, QUEUE, attr, id='p2p')
  59. self.servers[second_server].manager(MGR_CMD_CREATE, QUEUE,
  60. attr, id='p2p')
  61. attr = {'peer_queue': '\"p2p p2p@' + second_server + '\"'}
  62. self.scheduler.set_sched_config(attr)
  63. attr = {'scheduler_iteration': 5}
  64. self.server.manager(MGR_CMD_SET, SERVER, attr)
  65. self.server.restart()
  66. attr = {ATTR_queue: "p2p", ATTR_j: "oe",
  67. ATTR_W: "Output_Path=%s:/dev/null" % self.servers.keys()[0],
  68. 'Resource_List.select': 'host=%s' % self.moms.keys()[0]}
  69. j = Job(TEST_USER, attrs=attr)
  70. j.set_sleep_time(300)
  71. jid = self.servers[second_server].submit(j)
  72. self.server.expect(JOB, {'job_state': 'R'}, id=jid)
  73. self.servers[second_server].expect(JOB, {'job_state': 'M'},
  74. id=jid, extend='x')
  75. # history work task runs every two minutes
  76. self.logger.info("Wait for history work task to process...")
  77. time.sleep(125)
  78. # the jid should be still present with state M
  79. self.servers[second_server].expect(JOB, {'job_state': 'M'},
  80. id=jid, extend='x')
  81. self.server.delete(id=jid, wait=True)
  82. # history work task runs every two minutes
  83. self.logger.info("Wait for history work task to process...")
  84. time.sleep(125)
  85. # the jid should be gone
  86. try:
  87. qstat = self.servers[second_server].status(JOB, 'status',
  88. id=jid,
  89. extend='x')
  90. except PbsStatusError as err:
  91. # rc = 153 is for 'Unknown Job Id'
  92. self.assertEqual(err.rc, 153)
  93. qstat = ""
  94. self.assertEqual(qstat, "")