pbs_only_small_files_over_tpp.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 TestOnlySmallFilesOverTPP(TestFunctional):
  38. """
  39. This test suite is for testing that only smaller job files (.OU/.ER/.CK)
  40. and scripts (size < 2MB) are sent over TPP and larger files are sent by
  41. forking.
  42. """
  43. def setUp(self):
  44. TestFunctional.setUp(self)
  45. if len(self.moms) != 2:
  46. self.skip_test(reason="need 2 mom hosts: -p moms=<m1>:<m2>")
  47. self.server.set_op_mode(PTL_CLI)
  48. # PBSTestSuite returns the moms passed in as parameters as dictionary
  49. # of hostname and MoM object
  50. self.momA = self.moms.values()[0]
  51. self.momB = self.moms.values()[1]
  52. self.momA.delete_vnode_defs()
  53. self.momB.delete_vnode_defs()
  54. self.hostA = self.momA.shortname
  55. self.hostB = self.momB.shortname
  56. self.server.manager(MGR_CMD_DELETE, NODE, None, "")
  57. islocal = self.du.is_localhost(self.hostA)
  58. if islocal is False:
  59. self.server.manager(MGR_CMD_CREATE, NODE, id=self.hostA)
  60. else:
  61. self.server.manager(MGR_CMD_CREATE, NODE, id=self.hostB)
  62. self.server.manager(MGR_CMD_SET, SERVER,
  63. {'job_requeue_timeout': 175}, expect=True)
  64. self.server.manager(MGR_CMD_SET, SERVER,
  65. {'log_events': 4095}, expect=True)
  66. def test_small_job_file(self):
  67. """
  68. This test case tests that small output files are sent over TPP.
  69. """
  70. j = Job(TEST_USER, attrs={ATTR_N: 'small_job_file'})
  71. test = []
  72. test += ['dd if=/dev/zero of=file bs=1024 count=0 seek=1024\n']
  73. test += ['cat file\n']
  74. test += ['sleep 30\n']
  75. j.create_script(test, hostname=self.server.client)
  76. jid = self.server.submit(j)
  77. self.server.expect(JOB, {'job_state': 'R', 'substate': 42},
  78. id=jid, max_attempts=30, interval=2)
  79. time.sleep(5)
  80. try:
  81. self.server.rerunjob(jid)
  82. except PbsRerunError as e:
  83. self.assertTrue('qrerun: Response timed out. Job rerun request ' +
  84. 'still in progress for' in e.msg[0])
  85. msg = jid + ";big job files, sending via subprocess"
  86. self.server.log_match(msg, max_attempts=10, interval=2,
  87. existence=False)
  88. def test_big_job_file(self):
  89. """
  90. This test case tests that large output files are not sent over TPP.
  91. """
  92. j = Job(TEST_USER, attrs={ATTR_N: 'big_job_file'})
  93. test = []
  94. test += ['dd if=/dev/zero of=file bs=1024 count=0 seek=3072\n']
  95. test += ['cat file\n']
  96. test += ['sleep 30\n']
  97. j.create_script(test, hostname=self.server.client)
  98. jid = self.server.submit(j)
  99. self.server.expect(JOB, {'job_state': 'R', 'substate': 42},
  100. id=jid, max_attempts=30, interval=2)
  101. time.sleep(5)
  102. try:
  103. self.server.rerunjob(jid)
  104. except PbsRerunError as e:
  105. self.assertTrue('qrerun: Response timed out. Job rerun request ' +
  106. 'still in progress for' in e.msg[0])
  107. msg = jid + ";big job files, sending via subprocess"
  108. self.server.log_match(msg, max_attempts=30, interval=2)
  109. def test_big_job_script(self):
  110. """
  111. This test case tests that large job scripts are not sent over TPP.
  112. """
  113. j = Job(TEST_USER, attrs={
  114. ATTR_N: 'big_job_script'})
  115. # Create a big job script.
  116. test = []
  117. for i in range(105000):
  118. test += ['echo hey > /dev/null']
  119. test += ['sleep 5']
  120. j.create_script(test, hostname=self.server.client)
  121. jid = self.server.submit(j)
  122. self.server.expect(JOB, {'job_state': 'R', 'substate': 42},
  123. id=jid, max_attempts=30, interval=2)
  124. msg = jid + ";big job files, sending via subprocess"
  125. self.server.log_match(
  126. msg, max_attempts=30, interval=2)