pbs_qsub_opts_args.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 TestQsubOptionsArguments(TestFunctional):
  38. """
  39. validate qsub submission with a script and executable.
  40. note: The no-arg test is an interactive job, which is tested in
  41. SmokeTest.test_interactive_job
  42. """
  43. fn = None
  44. def setUp(self):
  45. TestFunctional.setUp(self)
  46. script = '/bin/hostname'
  47. self.fn = self.du.create_temp_file(body=script)
  48. self.qsub_cmd = os.path.join(
  49. self.server.pbs_conf['PBS_EXEC'], 'bin', 'qsub')
  50. def test_qsub_with_script_executable(self):
  51. """
  52. submit a job with a script and executable
  53. """
  54. cmd = [self.qsub_cmd, self.fn, '--', '/bin/sleep 10']
  55. rv = self.du.run_cmd(self.server.hostname, cmd=cmd)
  56. failed = rv['rc'] == 2 and rv['err'][0].split(' ')[0] == 'usage:'
  57. self.assertTrue(failed, 'qsub should have failed, but did not fail')
  58. def test_qsub_with_script_dashes(self):
  59. """
  60. submit a job with a script and dashes
  61. """
  62. cmd = [self.qsub_cmd, self.fn, '--']
  63. rv = self.du.run_cmd(self.server.hostname, cmd=cmd)
  64. failed = rv['rc'] == 2 and rv['err'][0].split(' ')[0] == 'usage:'
  65. self.assertTrue(failed, 'qsub should have failed, but did not fail')
  66. def test_qsub_with_dashes(self):
  67. """
  68. submit a job with only dashes
  69. """
  70. cmd = [self.qsub_cmd, '--']
  71. rv = self.du.run_cmd(self.server.hostname, cmd=cmd)
  72. failed = rv['rc'] == 2 and rv['err'][0].split(' ')[0] == 'usage:'
  73. self.assertTrue(failed, 'qsub should have failed, but did not fail')
  74. def test_qsub_with_script(self):
  75. """
  76. submit a job with only a script
  77. """
  78. cmd = [self.qsub_cmd, self.fn]
  79. rv = self.du.run_cmd(self.server.hostname, cmd=cmd)
  80. self.assertEquals(rv['rc'], 0, 'qsub failed')
  81. def test_qsub_with_executable(self):
  82. """
  83. submit a job with only an executable
  84. """
  85. cmd = [self.qsub_cmd, '--', '/bin/sleep 10']
  86. rv = self.du.run_cmd(self.server.hostname, cmd=cmd)
  87. self.assertEquals(rv['rc'], 0, 'qsub failed')
  88. def test_qsub_with_option_executable(self):
  89. """
  90. submit a job with an option and executable
  91. """
  92. cmd = [self.qsub_cmd, '-V', '--', '/bin/sleep', '10']
  93. rv = self.du.run_cmd(self.server.hostname, cmd=cmd)
  94. self.assertEquals(rv['rc'], 0, 'qsub failed')
  95. def test_qsub_with_option_script(self):
  96. """
  97. submit a job with an option and script
  98. """
  99. cmd = [self.qsub_cmd, '-V', self.fn]
  100. rv = self.du.run_cmd(self.server.hostname, cmd=cmd)
  101. self.assertEquals(rv['rc'], 0, 'qsub failed')