pbs_conf_resv_stale_vnode.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 TestResvStaleVnode(TestFunctional):
  38. """
  39. Test that the scheduler won't confirm a reservation on stale vnode and
  40. make sure reservations that have nodes that have gone stale get degreaded
  41. """
  42. def setUp(self):
  43. TestFunctional.setUp(self)
  44. # Create 3 vnodes named different things in different vnodedef files
  45. # This allows us to delete a vnodedef file and make that node stale
  46. self.mom.add_config(conf={'$vnodedef_additive': 'False'})
  47. a = {'resources_available.ncpus': 1, 'priority': 100}
  48. self.server.create_vnodes('foo', a, 1, fname='nat', restart=False,
  49. mom=self.mom, usenatvnode=True, expect=False)
  50. a['priority'] = 10
  51. self.server.create_vnodes('vn', a, 1, fname='fname1', delall=False,
  52. restart=False, additive=True, mom=self.mom,
  53. expect=False)
  54. a['priority'] = 1
  55. self.server.create_vnodes('vnode', a, 1, fname='fname2', delall=False,
  56. additive=True, mom=self.mom, expect=False)
  57. self.scheduler.set_sched_config({'node_sort_key':
  58. '\"sort_priority HIGH\"'})
  59. def test_conf_resv_stale_vnode(self):
  60. """
  61. Test that the scheduler won't confirm a reservation on a stale node.
  62. """
  63. # Ensure the hostsets aren't used by associating a node to a queue
  64. a = {'queue_type': 'Execution', 'enabled': 'True', 'started': 'True'}
  65. self.server.manager(MGR_CMD_CREATE, QUEUE, a, id='workq2')
  66. self.server.manager(MGR_CMD_SET, NODE, {'queue': 'workq2'},
  67. id=self.mom.shortname)
  68. # Submit a job that will run on our stale vnode
  69. a = {'Resource_List.select': '1:vnode=vn[0]',
  70. 'Resource_List.walltime': 3600}
  71. J = Job(TEST_USER, attrs=a)
  72. jid = self.server.submit(J)
  73. self.server.expect(JOB, {ATTR_state: 'R'}, id=jid)
  74. self.mom.delete_vnode_defs(vdefname='fname1')
  75. self.mom.signal('-HUP')
  76. self.server.expect(NODE, {'state': (MATCH_RE, 'Stale')}, id='vn[0]')
  77. now = int(time.time())
  78. a = {'reserve_start': now + 5400, 'reserve_end': now + 7200}
  79. R = Reservation(TEST_USER, a)
  80. rid = self.server.submit(R)
  81. # Reservation should be confirmed on vnode[0] since vn[0] is Stale
  82. a = {'resv_nodes': '(vnode[0]:ncpus=1)'}
  83. a2 = {'reserve_state': (MATCH_RE, 'RESV_CONFIRMED|2')}
  84. self.server.expect(RESV, a, id=rid)
  85. self.server.expect(RESV, a2, id=rid)
  86. def test_stale_degraded(self):
  87. """
  88. Test that a reservation goes into the degraded state
  89. when one of its vnodes go stale
  90. """
  91. now = int(time.time())
  92. a = {'Resource_List.select': '3:ncpus=1',
  93. 'Resource_List.place': 'vscatter',
  94. 'reserve_start': now + 3600, 'reserve_end': now + 7200}
  95. R = Reservation(TEST_USER, attrs=a)
  96. rid = self.server.submit(R)
  97. a = {'reserve_state': (MATCH_RE, 'RESV_CONFIRMED|2')}
  98. self.server.expect(RESV, a, id=rid)
  99. self.mom.delete_vnode_defs(vdefname='fname1')
  100. self.mom.signal('-HUP')
  101. self.server.expect(NODE, {'state': (MATCH_RE, 'Stale')}, id='vn[0]')
  102. a = {'reserve_state': (MATCH_RE, 'RESV_DEGRADED|10')}
  103. self.server.expect(RESV, a, id=rid)