pbs_history_cleanup_quasihang.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.performance import *
  37. class HistoryCleanupQuasihang(TestPerformance):
  38. """
  39. This test suite aims at testing the quasihang caused by a lot of jobs
  40. in the history.
  41. Without the fix, the server takes a lot of time to respond to a client.
  42. With the fix, the amount of time is significantly reduced.
  43. """
  44. def setUp(self):
  45. TestPerformance.setUp(self)
  46. a = {'job_history_enable': 'True', "job_history_duration": "10:00:00"}
  47. self.server.manager(MGR_CMD_SET, SERVER, a)
  48. a = {ATTR_rescavail + '.ncpus': 100}
  49. self.server.manager(MGR_CMD_SET, NODE, a, self.mom.shortname)
  50. @timeout(18000)
  51. def test_time_for_stat_during_history_cleanup(self):
  52. """
  53. This test case submits 50k very short jobs so that the job history
  54. has a lot of jobs in it.
  55. After submitting the jobs, the job_history_duration is reduced so
  56. that the server could start purging the job history.
  57. Another job is submitted and stat-ed. The test case then finds the
  58. amount of time the server takes to respond.
  59. The test case is not designed to pass/fail on builds with/without
  60. the fix.
  61. """
  62. test = ['echo test\n']
  63. # Submit a lot of jobs.
  64. for _ in range(0, 10):
  65. for _ in range(0, 10):
  66. for _ in range(0, 500):
  67. j = Job(TEST_USER, attrs={ATTR_k: 'oe'})
  68. j.create_script(body=test)
  69. jid = self.server.submit(j)
  70. time.sleep(1)
  71. self.server.expect(JOB, {'job_state': 'F'}, id=jid, extend='x',
  72. offset=10, interval=2, max_attempts=100)
  73. a = {"job_history_duration": "00:00:05"}
  74. self.server.manager(MGR_CMD_SET, SERVER, a)
  75. j = Job(TEST_USER)
  76. j.set_sleep_time(10000)
  77. jid = self.server.submit(j)
  78. self.server.expect(JOB, {'job_state': 'R'}, id=jid)
  79. now1 = 0
  80. now2 = 0
  81. i = 0
  82. while now2 - now1 < 2 and i < 125:
  83. time.sleep(1)
  84. now1 = int(time.time())
  85. self.server.expect(JOB, {'job_state': 'R'}, id=jid)
  86. now2 = int(time.time())
  87. i += 1
  88. self.logger.info("qstat took %d seconds to return\n",
  89. (now2 - now1))