pbs_unknown_resource_hook_update.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 TestUnknownResourceHookUpdate(TestFunctional):
  38. """
  39. Test that a resource that is not known to the server and is
  40. updated in an execjob_epilogue hook doesn't crash the server.
  41. """
  42. def test_epilogue_update(self):
  43. """
  44. Test setting resources_used values of resources that
  45. are unknown to the server, using an epilogue hook.
  46. """
  47. self.server.manager(MGR_CMD_SET, SERVER,
  48. {'job_history_enable': 'True'})
  49. hook_body = "import pbs\n"
  50. hook_body += "e = pbs.event()\n"
  51. hook_body += "hstr=\'" + "unkown_resource" + "\'\n"
  52. hook_body += "e.job.resources_used[\"foo_str\"] = 'unknown resource'\n"
  53. hook_body += "e.job.resources_used[\"foo_i\"] = 5\n"
  54. a = {'event': 'execjob_epilogue', 'enabled': 'True'}
  55. self.server.create_import_hook("ep", a, hook_body)
  56. J = Job()
  57. J.set_sleep_time(1)
  58. jid = self.server.submit(J)
  59. self.server.expect(JOB, {'job_state': 'F'}, id=jid, extend='x')
  60. # Make sure the server is still up
  61. self.server.isUp()
  62. # Server_logs would only show the first resource it has failed to
  63. # update
  64. log_match = 'unable to update attribute resources_used.foo_str '
  65. log_match += 'in job_obit'
  66. self.server.log_match("%s;.*%s.*" % (jid, log_match), regexp=True)