pbs_init_script.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 TestPbsInitScript(TestFunctional):
  38. """
  39. Testing PBS Pro init script
  40. """
  41. def test_env_vars_precede_pbs_conf_file(self):
  42. """
  43. Test PBS_START environment variables overrides values in pbs.conf file
  44. """
  45. conf = {'PBS_START_SERVER': '1', 'PBS_START_SCHED': '1',
  46. 'PBS_START_COMM': '1', 'PBS_START_MOM': '1'}
  47. self.du.set_pbs_config(confs=conf)
  48. conf_path = self.du.parse_pbs_config()
  49. pbs_init = os.path.join(os.sep, conf_path['PBS_EXEC'],
  50. 'libexec', 'pbs_init.d')
  51. self.du.run_cmd(cmd=[pbs_init, 'stop'], sudo=True)
  52. conf['PBS_START_MOM'] = '0'
  53. self.du.set_pbs_config(confs=conf)
  54. cmd = ['sudo', 'PBS_START_SERVER=0', 'PBS_START_SCHED=0',
  55. 'PBS_START_COMM=0', 'PBS_START_MOM=1',
  56. pbs_init, 'start']
  57. rc = self.du.run_cmd(cmd=cmd, as_script=True)
  58. output = rc['out']
  59. self.assertNotIn("PBS server", output)
  60. self.assertNotIn("PBS sched", output)
  61. self.assertNotIn("PBS comm", output)
  62. self.assertIn("PBS mom", output)
  63. def tearDown(self):
  64. TestFunctional.tearDown(self)
  65. # Above test leaves system in unusable state for PTL and PBS.
  66. # Hence restarting PBS explicitly
  67. PBSInitServices().restart()