pbs_default_timeout.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.selftest import *
  37. from ptl.utils.plugins.ptl_test_runner import TimeOut
  38. class TestDefaultTimeout(TestSelf):
  39. """
  40. Test suite to verify increase default testcase timeout working properly.
  41. """
  42. def test_default_timeout(self):
  43. """
  44. Verify that test not timedout after 180 sec.
  45. i.e. after previous default timeout value
  46. """
  47. try:
  48. mssg = 'sleeping for %ssec and minimum-testcase-timeout is %ssec' \
  49. % (MINIMUM_TESTCASE_TIMEOUT/2, MINIMUM_TESTCASE_TIMEOUT)
  50. self.logger.info(mssg)
  51. time.sleep(MINIMUM_TESTCASE_TIMEOUT/2)
  52. except TimeOut as e:
  53. mssg = 'Timed out after %s second' % MINIMUM_TESTCASE_TIMEOUT
  54. err_mssg = 'The test timed out for an incorrect timeout duration'
  55. self.assertEqual(mssg, e.message, err_mssg)
  56. def test_timeout_greater_default_value(self):
  57. """
  58. Verify that test timedout after 600 sec.
  59. """
  60. try:
  61. mssg = 'sleeping for %ssec and minimum-testcase-timeout is %ssec' \
  62. % (MINIMUM_TESTCASE_TIMEOUT+1, MINIMUM_TESTCASE_TIMEOUT)
  63. self.logger.info(mssg)
  64. time.sleep(MINIMUM_TESTCASE_TIMEOUT+1)
  65. except TimeOut as e:
  66. mssg = 'Timed out after %s second' % MINIMUM_TESTCASE_TIMEOUT
  67. err_mssg = 'The test timed out for an incorrect timeout duration'
  68. self.assertEqual(mssg, e.message, err_mssg)
  69. else:
  70. msg = 'Test did not timeout after the min. timeout period of %d' \
  71. % MINIMUM_TESTCASE_TIMEOUT
  72. self.fail(msg)
  73. @timeout(200)
  74. def test_timeout_decorator_less_default_value(self):
  75. """
  76. If timeout decorator value is less than 600 then
  77. default testcase timeout is considered
  78. """
  79. try:
  80. mssg = 'sleeping for %ssec and minimum-testcase-timeout is %ssec' \
  81. % (MINIMUM_TESTCASE_TIMEOUT/2, MINIMUM_TESTCASE_TIMEOUT)
  82. self.logger.info(mssg)
  83. time.sleep(MINIMUM_TESTCASE_TIMEOUT/2)
  84. except TimeOut as e:
  85. mssg = 'Timed out after %s second' % MINIMUM_TESTCASE_TIMEOUT
  86. err_mssg = 'The test timed out for an incorrect timeout duration'
  87. self.assertEqual(mssg, e.message, err_mssg)
  88. @timeout(800)
  89. def test_timeout_decorator_greater_default_value(self):
  90. """
  91. If timeout decorator value is greater than 600 then
  92. testcase timeout value consider as timeout decorator value
  93. """
  94. try:
  95. mssg = 'sleeping for %ssec and minimum-testcase-timeout is %ssec' \
  96. % (MINIMUM_TESTCASE_TIMEOUT+1, 800)
  97. self.logger.info(mssg)
  98. time.sleep(MINIMUM_TESTCASE_TIMEOUT+1)
  99. except TimeOut as e:
  100. mssg = 'Timed out after 800 second'
  101. err_mssg = 'The test timed out for an incorrect timeout duration'
  102. self.assertEqual(mssg, e.message, err_mssg)