pbs_strict_ordering.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. import os
  37. import string
  38. import time
  39. from tests.functional import *
  40. class TestStrictOrderingAndBackfilling(TestFunctional):
  41. """
  42. Test strict ordering when backfilling is truned off
  43. """
  44. @timeout(1800)
  45. def test_t1(self):
  46. a = {'resources_available.ncpus': 4}
  47. self.server.create_vnodes('vn', a, 1, self.mom, usenatvnode=True)
  48. rv = self.scheduler.set_sched_config(
  49. {'round_robin': 'false all', 'by_queue': 'false prime',
  50. 'by_queue': 'false non_prime', 'strict_ordering': 'true all',
  51. 'help_starving_jobs': 'false all'})
  52. self.assertTrue(rv)
  53. a = {'backfill_depth': 0}
  54. self.server.manager(MGR_CMD_SET, SERVER, a, expect=True)
  55. j1 = Job(TEST_USER)
  56. a = {'Resource_List.select': '1:ncpus=2',
  57. 'Resource_List.walltime': 9999}
  58. j1.set_sleep_time(9999)
  59. j1.set_attributes(a)
  60. j1 = self.server.submit(j1)
  61. j2 = Job(TEST_USER)
  62. a = {'Resource_List.select': '1:ncpus=3',
  63. 'Resource_List.walltime': 9999}
  64. j2.set_sleep_time(9999)
  65. j2.set_attributes(a)
  66. j2 = self.server.submit(j2)
  67. j3 = Job(TEST_USER)
  68. a = {'Resource_List.select': '1:ncpus=2',
  69. 'Resource_List.walltime': 9999}
  70. j3.set_sleep_time(9999)
  71. j3.set_attributes(a)
  72. j3 = self.server.submit(j3)
  73. rv = self.server.expect(
  74. JOB,
  75. {'comment': 'Not Running: Job would break strict sorted order'},
  76. id=j3,
  77. offset=2,
  78. max_attempts=2,
  79. interval=2)
  80. self.assertTrue(rv)
  81. """
  82. Test strict ordering when queue backilling is enabled and server
  83. backfilling is off
  84. """
  85. def test_t2(self):
  86. rv = self.scheduler.set_sched_config(
  87. {'by_queue': 'false prime', 'by_queue': 'false non_prime',
  88. 'strict_ordering': 'true all'})
  89. self.assertTrue(rv)
  90. a = {'backfill_depth': 2}
  91. self.server.manager(
  92. MGR_CMD_SET, QUEUE, a, id='workq', expect=True)
  93. a = {
  94. 'queue_type': 'execution',
  95. 'started': 't',
  96. 'enabled': 't',
  97. 'backfill_depth': 1}
  98. self.server.manager(MGR_CMD_CREATE, QUEUE, a, id='wq2')
  99. a = {
  100. 'queue_type': 'execution',
  101. 'started': 't',
  102. 'enabled': 't',
  103. 'backfill_depth': 0}
  104. self.server.manager(MGR_CMD_CREATE, QUEUE, a, id='wq3')
  105. a = {'backfill_depth': 0}
  106. self.server.manager(MGR_CMD_SET, SERVER, a, expect=True)
  107. a = {'resources_available.ncpus': 5}
  108. self.server.manager(
  109. MGR_CMD_SET,
  110. NODE,
  111. a,
  112. self.mom.shortname,
  113. expect=True)
  114. self.server.manager(
  115. MGR_CMD_SET, SERVER, {
  116. 'scheduling': 'False'}, expect=True)
  117. a = {'Resource_List.select': '1:ncpus=2', ATTR_queue: 'workq'}
  118. j = Job(TEST_USER, a)
  119. j.set_sleep_time(100)
  120. j1id = self.server.submit(j)
  121. j2id = self.server.submit(j)
  122. j3id = self.server.submit(j)
  123. a = {'Resource_List.select': '1:ncpus=1', ATTR_queue: 'wq2'}
  124. j = Job(TEST_USER, a)
  125. j.set_sleep_time(100)
  126. j4id = self.server.submit(j)
  127. a = {'Resource_List.select': '1:ncpus=1', ATTR_queue: 'wq3'}
  128. j = Job(TEST_USER, a)
  129. j.set_sleep_time(100)
  130. j5id = self.server.submit(j)
  131. self.server.manager(
  132. MGR_CMD_SET, SERVER, {
  133. 'scheduling': 'True'}, expect=True)
  134. self.server.expect(JOB,
  135. {'job_state': 'R'},
  136. id=j1id,
  137. max_attempts=30,
  138. interval=2)
  139. self.server.expect(JOB,
  140. {'job_state': 'R'},
  141. id=j2id,
  142. max_attempts=30,
  143. interval=2)
  144. self.server.expect(JOB,
  145. {'job_state': 'R'},
  146. id=j4id,
  147. max_attempts=30,
  148. interval=2)
  149. self.server.expect(JOB,
  150. {'job_state': 'Q'},
  151. id=j5id,
  152. max_attempts=30,
  153. interval=2)