pbs_indirect_resources.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 TestHostResources(TestFunctional):
  38. def test_set_direct_on_indirect_resc(self):
  39. """
  40. Set a direct resource on indirect resource and make sure
  41. this change is reflected on resource assigned.
  42. """
  43. # Create a consumable custom resources 'fooi'
  44. self.server.add_resource('fooi', 'long', 'nh')
  45. # Create 2 vnodes with individual hosts
  46. attr = {'resources_available.ncpus': 1}
  47. self.server.create_vnodes('vnode', attr, 2, sharednode=False,
  48. mom=self.mom)
  49. self.server.manager(MGR_CMD_SET, NODE,
  50. {'resources_available.fooi': 100}, 'vnode[0]')
  51. self.server.manager(MGR_CMD_SET, NODE, {'resources_available.fooi':
  52. '@vnode[0]'}, 'vnode[1]')
  53. self.server.manager(MGR_CMD_SET, NODE,
  54. {'resources_available.fooi': 100}, 'vnode[1]')
  55. self.server.expect(NODE, {'resources_assigned.fooi': ''},
  56. id='vnode[1]', op=UNSET, max_attempts=1)
  57. def test_set_direct_on_indirect_resc_busy(self):
  58. """
  59. Set a direct resource on indirect resource
  60. but a busy node and make sure this is failing.
  61. """
  62. # Create 2 vnodes with individual hosts
  63. attr = {'resources_available.ncpus': 1}
  64. self.server.create_vnodes('vnode', attr, 2, sharednode=False,
  65. mom=self.mom)
  66. # Create a consumable custom resources 'fooi'
  67. self.server.add_resource('fooi', 'long', 'nh')
  68. self.scheduler.add_resource("fooi")
  69. self.server.manager(MGR_CMD_SET, NODE,
  70. {'resources_available.fooi': 100}, 'vnode[0]')
  71. self.server.manager(MGR_CMD_SET, NODE, {'resources_available.fooi':
  72. '@vnode[0]'}, 'vnode[1]')
  73. # Submit jobs.
  74. a = {'Resource_List.fooi': 50}
  75. J = Job(attrs=a)
  76. self.server.submit(J)
  77. j2 = self.server.submit(J)
  78. self.server.expect(JOB, {'job_state': 'R'}, id=j2)
  79. self.server.expect(NODE, {'state': 'job-busy'}, id='vnode[1]')
  80. try:
  81. self.server.manager(MGR_CMD_SET, NODE,
  82. {'resources_available.fooi': 100},
  83. 'vnode[1]')
  84. except PbsManagerError:
  85. pass
  86. else:
  87. self.server.expect(NODE, {'resources_available.fooi': 100},
  88. id='vnode[1]', op=UNSET, max_attempts=1)
  89. def test_set_direct_on_target_node(self):
  90. """
  91. Set a direct resource on target node which should
  92. fail with error.
  93. A and B are having direct resources.
  94. C -> B
  95. B -> A should fail as it is alreay a target.
  96. """
  97. # Create 3 vnodes with individual hosts
  98. attr = {'resources_available.ncpus': 1}
  99. self.server.create_vnodes('vnode', attr, 3, sharednode=False,
  100. mom=self.mom)
  101. # Create a consumable custom resources 'fooi'
  102. self.server.add_resource('fooi', 'long', 'nh')
  103. self.server.manager(MGR_CMD_SET, NODE,
  104. {'resources_available.fooi': 100}, 'vnode[0]')
  105. self.server.manager(MGR_CMD_SET, NODE,
  106. {'resources_available.fooi': 100}, 'vnode[1]')
  107. self.server.manager(MGR_CMD_SET, NODE, {'resources_available.fooi':
  108. '@vnode[1]'}, 'vnode[2]')
  109. try:
  110. self.server.manager(MGR_CMD_SET, NODE,
  111. {'resources_available.fooi': '@vnode[0]'},
  112. 'vnode[1]')
  113. except PbsManagerError:
  114. pass
  115. else:
  116. _msg = "Setting indirect resources on a target object should fail"
  117. self.assertTrue(False, _msg)
  118. def test_create_node_without_resc_set(self):
  119. """
  120. Create a consumable resource then create a new node.
  121. The resources_assigned value should not get assigned
  122. on it without explicitely setting resource on the node.
  123. """
  124. # Create a consumable custom resources 'fooi'
  125. self.server.add_resource('fooi', 'long', 'nh')
  126. self.server.manager(MGR_CMD_DELETE, NODE, None, "")
  127. self.server.manager(MGR_CMD_CREATE, NODE, id=self.mom.shortname)
  128. self.server.expect(NODE, {'resources_assigned.fooi': ''},
  129. id=self.mom.shortname, op=UNSET, max_attempts=1)