pbs_test_qorder.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_qorder(TestFunctional):
  38. """
  39. Test suite to test whether the political order of selecting a job to run
  40. in scheduler changes when one does a qorder.
  41. """
  42. def test_qorder_job(self):
  43. """
  44. Submit two jobs, switch their order using qorder and then check if the
  45. jobs are selected to run in the newly created order.
  46. """
  47. a = {'resources_available.ncpus': 1}
  48. self.server.manager(MGR_CMD_SET, NODE, a, self.mom.shortname)
  49. a = {'scheduling': 'false'}
  50. self.server.manager(MGR_CMD_SET, SERVER, a)
  51. j1 = Job(TEST_USER)
  52. j1.set_sleep_time(10)
  53. j2 = Job(TEST_USER)
  54. j2.set_sleep_time(10)
  55. jid1 = self.server.submit(j1)
  56. jid2 = self.server.submit(j2)
  57. rc = self.server.orderjob(jobid1=jid1, jobid2=jid2)
  58. self.assertEqual(rc, 0)
  59. a = {'scheduling': 'true'}
  60. self.server.manager(MGR_CMD_SET, SERVER, a)
  61. a = {'server_state': 'Scheduling'}
  62. self.server.expect(SERVER, a, op=NE)
  63. jid2 = jid2.split('.')[0]
  64. cycle = self.scheduler.cycles(start=self.server.ctime, lastN=1)
  65. cycle = cycle[0]
  66. firstconsidered = cycle.political_order[0]
  67. msg = 'testinfo: first job considered [' + str(firstconsidered) + \
  68. '] == second submitted [' + str(jid2) + ']'
  69. self.logger.info(msg)
  70. self.assertEqual(firstconsidered, jid2)
  71. def test_qorder_job_across_queues(self):
  72. a = {'resources_available.ncpus': 1}
  73. self.server.manager(MGR_CMD_SET, NODE, a, self.mom.shortname)
  74. a = {'scheduling': 'false'}
  75. self.server.manager(MGR_CMD_SET, SERVER, a)
  76. a = {'queue_type': 'e', 'enabled': '1', 'started': '1'}
  77. self.server.manager(MGR_CMD_CREATE, QUEUE, a, id='workq2')
  78. self.scheduler.set_sched_config({'by_queue': 'False'})
  79. a = {ATTR_queue: 'workq'}
  80. j1 = Job(TEST_USER, a)
  81. j1.set_sleep_time(10)
  82. a = {ATTR_queue: 'workq2'}
  83. j2 = Job(TEST_USER, a)
  84. j2.set_sleep_time(10)
  85. jid1 = self.server.submit(j1)
  86. jid2 = self.server.submit(j2)
  87. rc = self.server.orderjob(jobid1=jid1, jobid2=jid2)
  88. self.assertEqual(rc, 0)
  89. a = {'scheduling': 'true'}
  90. self.server.manager(MGR_CMD_SET, SERVER, a)
  91. a = {'server_state': 'Scheduling'}
  92. self.server.expect(SERVER, a, op=NE)
  93. jid2 = jid2.split('.')[0]
  94. cycle = self.scheduler.cycles(start=self.server.ctime, lastN=1)
  95. cycle = cycle[0]
  96. firstconsidered = cycle.political_order[0]
  97. msg = 'testinfo: first job considered [' + str(firstconsidered) + \
  98. '] == second submitted [' + str(jid2) + ']'
  99. self.logger.info(msg)
  100. self.assertEqual(firstconsidered, jid2)