123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833 |
- # coding: utf-8
- # Copyright (C) 1994-2018 Altair Engineering, Inc.
- # For more information, contact Altair at www.altair.com.
- #
- # This file is part of the PBS Professional ("PBS Pro") software.
- #
- # Open Source License Information:
- #
- # PBS Pro is free software. You can redistribute it and/or modify it under the
- # terms of the GNU Affero General Public License as published by the Free
- # Software Foundation, either version 3 of the License, or (at your option) any
- # later version.
- #
- # PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- # FOR A PARTICULAR PURPOSE.
- # See the GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- # Commercial License Information:
- #
- # For a copy of the commercial license terms and conditions,
- # go to: (http://www.pbspro.com/UserArea/agreement.html)
- # or contact the Altair Legal Department.
- #
- # Altair’s dual-license business model allows companies, individuals, and
- # organizations to create proprietary derivative works of PBS Pro and
- # distribute them - whether embedded or bundled with other software -
- # under a commercial license agreement.
- #
- # Use of Altair’s trademarks, including but not limited to "PBS™",
- # "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
- # trademark licensing policies.
- from tests.functional import *
- class TestEntityLimits(TestFunctional):
- """
- This test suite tests working of queued_jobs_threshold, max_queued,
- queued_jobs_threshold_res and max_queued_res.
- PBS supports entity limits at queue and server level. And these limits
- can be applied for a user, group, project or overall.
- This test suite iterates over all the entities.
- """
- limit = 10
- def setUp(self):
- TestFunctional.setUp(self)
- a = {'resources_available.ncpus': 1}
- self.server.manager(MGR_CMD_SET, NODE, a, self.mom.shortname,
- expect=True)
- def common_limit_test(self, server, entstr, job_attr={}, queued=False,
- exp_err=''):
- if not server:
- qname = self.server.default_queue
- self.server.manager(MGR_CMD_SET, QUEUE, entstr, qname)
- else:
- self.server.manager(MGR_CMD_SET, SERVER, entstr)
- if queued:
- j = Job(TST_USR, job_attr)
- jid = self.server.submit(j)
- self.server.expect(JOB, {'job_state': 'R'}, id=jid)
- for _ in range(self.limit):
- j = Job(TST_USR, job_attr)
- self.server.submit(j)
- try:
- j = Job(TST_USR, job_attr)
- self.server.submit(j)
- except PbsSubmitError as e:
- if e.msg[0] != exp_err:
- raise self.failureException("rcvd unexpected err message: "
- + e.msg[0])
- else:
- self.assertFalse(True, "Job violating limits got submitted.")
- self.server.cleanup_jobs()
- try:
- jval = "1-" + str(self.limit + 1)
- job_attr[ATTR_J] = jval
- j = Job(TST_USR, job_attr)
- jid = self.server.submit(j)
- except PbsSubmitError as e:
- if e.msg[0] != exp_err:
- raise self.failureException("rcvd unexpected err message: "
- + e.msg[0])
- else:
- self.assertFalse(True, "Array Job violating limits got submitted.")
- jval = "1-" + str(self.limit)
- job_attr[ATTR_J] = jval
- j = Job(TST_USR, job_attr)
- jid = self.server.submit(j)
- self.server.expect(JOB, {'job_state': 'B'}, id=jid)
- del job_attr[ATTR_J]
- if queued:
- j = Job(TST_USR, job_attr)
- self.server.submit(j)
- try:
- j = Job(TST_USR, job_attr)
- self.server.submit(j)
- except PbsSubmitError:
- if e.msg[0] != exp_err:
- raise self.failureException("rcvd unexpected err message: "
- + e.msg[0])
- else:
- self.assertFalse(True, "Job violating limits got submitted.")
- self.server.restart()
- try:
- self.server.submit(j)
- except PbsSubmitError:
- if e.msg[0] != exp_err:
- raise self.failureException("rcvd unexpected err message: "
- + e.msg[0])
- else:
- self.assertFalse(True, "Job violating limits got submitted after "
- + "server restart.")
- def test_server_generic_user_limits_queued(self):
- """
- Test queued_jobs_threshold for any user at the server level.
- """
- a = {"queued_jobs_threshold":
- "[u:PBS_GENERIC=" + str(self.limit) + "]"}
- m = "qsub: would exceed complex's per-user limit of jobs in 'Q' state"
- self.common_limit_test(True, a, queued=True, exp_err=m)
- def test_server_user_limits_queued(self):
- """
- Test queued_jobs_threshold for user TST_USR at the server level.
- """
- a = {"queued_jobs_threshold":
- "[u:" + str(TST_USR) + "=" + str(self.limit) + "]"}
- errmsg = "qsub: Maximum number of jobs in 'Q' state for user " + \
- str(TST_USR) + ' already in complex'
- self.common_limit_test(True, a, queued=True, exp_err=errmsg)
- def test_server_project_limits_queued(self):
- """
- Test queued_jobs_threshold for project p1 at the server level.
- """
- a = {"queued_jobs_threshold": "[p:p1=" + str(self.limit) + "]"}
- attrs = {ATTR_project: 'p1'}
- errmsg = "qsub: Maximum number of jobs in 'Q' state for project p1 " \
- + "already in complex"
- self.common_limit_test(True, a, attrs, queued=True, exp_err=errmsg)
- def test_server_generic_project_limits_queued(self):
- """
- Test queued_jobs_threshold for any project at the server level.
- """
- a = {"queued_jobs_threshold":
- "[p:PBS_GENERIC=" + str(self.limit) + "]"}
- errmsg = "qsub: would exceed complex's per-project limit of jobs in " \
- + "'Q' state"
- self.common_limit_test(True, a, queued=True, exp_err=errmsg)
- def test_server_group_limits_queued(self):
- """
- Test queued_jobs_threshold for group TSTGRP0 at the server level.
- """
- a = {"queued_jobs_threshold":
- "[g:" + str(TSTGRP0) + "=" + str(self.limit) + "]"}
- errmsg = "qsub: Maximum number of jobs in 'Q' state for group " + \
- str(TSTGRP0) + ' already in complex'
- self.common_limit_test(True, a, queued=True, exp_err=errmsg)
- def test_server_generic_group_limits_queued(self):
- """
- Test queued_jobs_threshold for any group at the server level.
- """
- a = {"queued_jobs_threshold":
- "[g:PBS_GENERIC=" + str(self.limit) + "]"}
- m = "qsub: would exceed complex's per-group limit of jobs in 'Q' state"
- self.common_limit_test(True, a, queued=True, exp_err=m)
- def test_server_overall_limits_queued(self):
- """
- Test queued_jobs_threshold for any entity at the server level.
- """
- a = {"queued_jobs_threshold": "[o:PBS_ALL=" + str(self.limit) + "]"}
- errmsg = "qsub: Maximum number of jobs in 'Q' state already in complex"
- self.common_limit_test(True, a, queued=True, exp_err=errmsg)
- def test_queue_generic_user_limits_queued(self):
- """
- Test queued_jobs_threshold for any user for the default queue.
- """
- a = {"queued_jobs_threshold":
- "[u:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = "qsub: would exceed queue generic's per-user limit of " \
- + "jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_user_limits_queued(self):
- """
- Test queued_jobs_threshold for user pbsuser1 for the default queue.
- """
- a = {"queued_jobs_threshold":
- "[u:" + str(TST_USR) + "=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = "qsub: Maximum number of jobs in 'Q' state for user " + \
- str(TST_USR) + ' already in queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_group_limits_queued(self):
- """
- Test queued_jobs_threshold for group TSTGRP0 for the default queue.
- """
- a = {"queued_jobs_threshold":
- "[g:" + str(TSTGRP0) + "=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = "qsub: Maximum number of jobs in 'Q' state for group " + \
- str(TSTGRP0) + ' already in queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_project_limits_queued(self):
- """
- Test queued_jobs_threshold for project p1 for the default queue.
- """
- a = {"queued_jobs_threshold": "[p:p1=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue, ATTR_project: 'p1'}
- errmsg = "qsub: Maximum number of jobs in 'Q' state for project p1 " \
- 'already in queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_generic_project_limits_queued(self):
- """
- Test queued_jobs_threshold for any project for the default queue.
- """
- a = {"queued_jobs_threshold":
- "[p:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = 'qsub: would exceed queue ' + self.server.default_queue + \
- "'s per-project limit of jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_generic_group_limits_queued(self):
- """
- Test queued_jobs_threshold for any group for the default queue.
- """
- a = {"queued_jobs_threshold":
- "[g:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = 'qsub: would exceed queue ' + self.server.default_queue + \
- "'s per-group limit of jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_overall_limits_queued(self):
- """
- Test queued_jobs_threshold for all entities for the default queue.
- """
- a = {"queued_jobs_threshold": "[o:PBS_ALL=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- emsg = "qsub: Maximum number of jobs in 'Q' state already in queue " \
- + self.server.default_queue
- self.common_limit_test(False, a, attrs, queued=True, exp_err=emsg)
- def test_server_generic_user_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for any user at the server level.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[u:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed per-user limit on resource ncpus in ' \
- + "complex for jobs in 'Q' state"
- self.common_limit_test(True, a, attrs, queued=True, exp_err=errmsg)
- def test_server_user_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for user pbsuser1 at the server level.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[u:" + str(TST_USR) + "=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed user ' + str(TST_USR) + \
- "'s limit on resource ncpus in complex for jobs in 'Q' state"
- self.common_limit_test(True, a, attrs, queued=True, exp_err=errmsg)
- def test_server_generic_group_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for any group at the server level.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[g:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed per-group limit on resource ncpus in '\
- + "complex for jobs in 'Q' state"
- self.common_limit_test(True, a, attrs, queued=True, exp_err=errmsg)
- def test_server_project_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for project p1 at the server level.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[p:p1=" + str(self.limit) + "]"}
- attrs = {ATTR_project: 'p1', 'Resource_List.select': '1:ncpus=1'}
- errmsg = "qsub: would exceed project p1's limit on resource ncpus in" \
- + " complex for jobs in 'Q' state"
- self.common_limit_test(True, a, attrs, queued=True, exp_err=errmsg)
- def test_server_generic_project_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for any project at the server level.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[p:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed per-project limit on resource ncpus in ' \
- + "complex for jobs in 'Q' state"
- self.common_limit_test(True, a, attrs, queued=True, exp_err=errmsg)
- def test_server_group_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for group pbsuser1 at the server level.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[g:" + str(TSTGRP0) + "=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed group ' + str(TSTGRP0) + \
- "'s limit on resource ncpus in complex for jobs in 'Q' state"
- self.common_limit_test(True, a, attrs, queued=True, exp_err=errmsg)
- def test_server_overall_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for all entities at the server level.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[o:PBS_ALL=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed limit on resource ncpus in complex for '\
- + "jobs in 'Q' state"
- self.common_limit_test(True, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_generic_user_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for all users for the default queue.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[u:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- emsg = 'qsub: would exceed per-user limit on resource ncpus in queue '\
- + self.server.default_queue + " for jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=emsg)
- def test_queue_user_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for user pbsuser1 for the default queue.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[u:" + str(TST_USR) + "=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed user ' + str(TST_USR) + \
- "'s limit on resource ncpus in queue " + \
- self.server.default_queue + " for jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_group_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for group pbsuser1 for the default queue
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[g:" + str(TSTGRP0) + "=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed group ' + str(TSTGRP0) + \
- "'s limit on resource ncpus in queue " + \
- self.server.default_queue + " for jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_generic_group_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for any group for the default queue.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[g:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed per-group limit on resource ncpus in ' \
- + 'queue ' + self.server.default_queue + " for jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_project_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for project p1 for the default queue.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[p:p1=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- ATTR_project: 'p1', 'Resource_List.select': '1:ncpus=1'}
- errmsg = "qsub: would exceed project p1's limit on resource ncpus " + \
- 'in queue ' + self.server.default_queue + " for jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_generic_project_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for any project for the default queue.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[p:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed per-project limit on resource ncpus in' \
- + ' queue ' + self.server.default_queue + " for jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_queue_overall_limits_res_queued(self):
- """
- Test queued_jobs_threshold_res for any entity for the default queue.
- """
- a = {"queued_jobs_threshold_res.ncpus":
- "[o:PBS_ALL=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed limit on resource ncpus in queue ' + \
- self.server.default_queue + " for jobs in 'Q' state"
- self.common_limit_test(False, a, attrs, queued=True, exp_err=errmsg)
- def test_server_generic_user_limits_max(self):
- """
- Test max_queued for any user at the server level.
- """
- a = {"max_queued":
- "[u:PBS_GENERIC=" + str(self.limit) + "]"}
- errmsg = "qsub: would exceed complex's per-user limit"
- self.common_limit_test(True, a, exp_err=errmsg)
- def test_server_user_limits_max(self):
- """
- Test max_queued for user pbsuser1 at the server level.
- """
- a = {"max_queued":
- "[u:" + str(TST_USR) + "=" + str(self.limit) + "]"}
- errmsg = 'qsub: Maximum number of jobs for user ' + str(TST_USR) + \
- ' already in complex'
- self.common_limit_test(True, a, exp_err=errmsg)
- def test_server_project_limits_max(self):
- """
- Test max_queued for project p1 at the server level.
- """
- a = {"max_queued": "[p:p1=" + str(self.limit) + "]"}
- attrs = {ATTR_project: 'p1'}
- msg = 'qsub: Maximum number of jobs for project p1 already in complex'
- self.common_limit_test(True, a, attrs, exp_err=msg)
- def test_server_generic_project_limits_max(self):
- """
- Test max_queued for any project at the server level.
- """
- a = {"max_queued":
- "[p:PBS_GENERIC=" + str(self.limit) + "]"}
- errmsg = "qsub: would exceed complex's per-project limit"
- self.common_limit_test(True, a, exp_err=errmsg)
- def test_server_group_limits_max(self):
- """
- Test max_queued for group pbsuser1 at the server level.
- """
- a = {"max_queued":
- "[g:" + str(TSTGRP0) + "=" + str(self.limit) + "]"}
- errmsg = 'qsub: Maximum number of jobs for group ' + str(TSTGRP0) + \
- ' already in complex'
- self.common_limit_test(True, a, exp_err=errmsg)
- def test_server_generic_group_limits_max(self):
- """
- Test max_queued for any group at the server level.
- """
- a = {"max_queued":
- "[g:PBS_GENERIC=" + str(self.limit) + "]"}
- errmsg = "qsub: would exceed complex's per-group limit"
- self.common_limit_test(True, a, exp_err=errmsg)
- def test_server_overall_limits_max(self):
- """
- Test max_queued for any entity at the server level.
- """
- a = {"max_queued": "[o:PBS_ALL=" + str(self.limit) + "]"}
- errmsg = 'qsub: Maximum number of jobs already in complex'
- self.common_limit_test(True, a, exp_err=errmsg)
- def test_queue_generic_user_limits_max(self):
- """
- Test max_queued for any user for the default queue.
- """
- a = {"max_queued":
- "[u:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = "qsub: would exceed queue generic's per-user limit"
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_user_limits_max(self):
- """
- Test max_queued for user pbsuser1 for the default queue.
- """
- a = {"max_queued":
- "[u:" + str(TST_USR) + "=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = 'qsub: Maximum number of jobs for user ' + str(TST_USR) + \
- ' already in queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_group_limits_max(self):
- """
- Test max_queued for group pbsuser1 for the default queue.
- """
- a = {"max_queued":
- "[g:" + str(TSTGRP0) + "=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = 'qsub: Maximum number of jobs for group ' + str(TSTGRP0) + \
- ' already in queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_project_limits_max(self):
- """
- Test max_queued for project p1 for the default queue.
- """
- a = {"max_queued": "[p:p1=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue, ATTR_project: 'p1'}
- msg = 'qsub: Maximum number of jobs for project p1 already in queue '\
- + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=msg)
- def test_queue_generic_project_limits_max(self):
- """
- Test max_queued for any project for the default queue.
- """
- a = {"max_queued":
- "[p:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = 'qsub: would exceed queue ' + self.server.default_queue + \
- "'s per-project limit"
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_generic_group_limits_max(self):
- """
- Test max_queued for any group for the default queue.
- """
- a = {"max_queued":
- "[g:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = 'qsub: would exceed queue ' + self.server.default_queue + \
- "'s per-group limit"
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_overall_limits_max(self):
- """
- Test max_queued for all entities for the default queue.
- """
- a = {"max_queued": "[o:PBS_ALL=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue}
- errmsg = 'qsub: Maximum number of jobs already in queue ' + \
- self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_server_generic_user_limits_res_max(self):
- """
- Test max_queued_res for any user at the server level.
- """
- a = {"max_queued_res.ncpus":
- "[u:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- emsg = 'qsub: would exceed per-user limit on resource ncpus in complex'
- self.common_limit_test(True, a, attrs, exp_err=emsg)
- def test_server_user_limits_res_max(self):
- """
- Test max_queued_res for user pbsuser1 at the server level.
- """
- a = {"max_queued_res.ncpus":
- "[u:" + str(TST_USR) + "=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed user ' + str(TST_USR) + \
- "'s limit on resource ncpus in complex"
- self.common_limit_test(True, a, attrs, exp_err=errmsg)
- def test_server_generic_group_limits_res_max(self):
- """
- Test max_queued_res for any group at the server level.
- """
- a = {"max_queued_res.ncpus":
- "[g:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- msg = 'qsub: would exceed per-group limit on resource ncpus in complex'
- self.common_limit_test(True, a, attrs, exp_err=msg)
- def test_server_project_limits_res_max(self):
- """
- Test max_queued_res for project p1 at the server level.
- """
- a = {"max_queued_res.ncpus":
- "[p:p1=" + str(self.limit) + "]"}
- attrs = {ATTR_project: 'p1', 'Resource_List.select': '1:ncpus=1'}
- errmsg = "qsub: would exceed project p1's limit on resource ncpus in" \
- + " complex"
- self.common_limit_test(True, a, attrs, exp_err=errmsg)
- def test_server_generic_project_limits_res_max(self):
- """
- Test max_queued_res for any project at the server level.
- """
- a = {"max_queued_res.ncpus":
- "[p:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- m = 'qsub: would exceed per-project limit on resource ncpus in complex'
- self.common_limit_test(True, a, attrs, exp_err=m)
- def test_server_group_limits_res_max(self):
- """
- Test max_queued_res for group pbsuser1 at the server level.
- """
- a = {"max_queued_res.ncpus":
- "[g:" + str(TSTGRP0) + "=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed group ' + str(TSTGRP0) + \
- "'s limit on resource ncpus in complex"
- self.common_limit_test(True, a, attrs, exp_err=errmsg)
- def test_server_overall_limits_res_max(self):
- """
- Test max_queued_res for all entities at the server level.
- """
- a = {"max_queued_res.ncpus":
- "[o:PBS_ALL=" + str(self.limit) + "]"}
- attrs = {'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed limit on resource ncpus in complex'
- self.common_limit_test(True, a, attrs, exp_err=errmsg)
- def test_queue_generic_user_limits_res_max(self):
- """
- Test max_queued_res for all users for the default queue.
- """
- a = {"max_queued_res.ncpus":
- "[u:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed per-user limit on resource ncpus in' \
- + ' queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_user_limits_res_max(self):
- """
- Test max_queued_res for user pbsuser1 for the default queue.
- """
- a = {"max_queued_res.ncpus":
- "[u:" + str(TST_USR) + "=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed user ' + str(TST_USR) + \
- "'s limit on resource ncpus in queue " + \
- self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_group_limits_res_max(self):
- """
- Test max_queued_res for group pbsuser1 for the default queue
- """
- a = {"max_queued_res.ncpus":
- "[g:" + str(TSTGRP0) + "=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed group ' + str(TSTGRP0) + \
- "'s limit on resource ncpus in queue " + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_generic_group_limits_res_max(self):
- """
- Test max_queued_res for any group for the default queue.
- """
- a = {"max_queued_res.ncpus":
- "[g:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed per-group limit on resource ncpus in' \
- + ' queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_project_limits_res_max(self):
- """
- Test max_queued_res for project p1 for the default queue.
- """
- a = {"max_queued_res.ncpus":
- "[p:p1=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- ATTR_project: 'p1', 'Resource_List.select': '1:ncpus=1'}
- errmsg = "qsub: would exceed project p1's limit on resource ncpus" + \
- ' in queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_generic_project_limits_res_max(self):
- """
- Test max_queued_res for any project for the default queue.
- """
- a = {"max_queued_res.ncpus":
- "[p:PBS_GENERIC=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed per-project limit on resource ncpus in' \
- + ' queue ' + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_queue_overall_limits_res_max(self):
- """
- Test max_queued_res for any entity for the default queue.
- """
- a = {"max_queued_res.ncpus":
- "[o:PBS_ALL=" + str(self.limit) + "]"}
- attrs = {ATTR_queue: self.server.default_queue,
- 'Resource_List.select': '1:ncpus=1'}
- errmsg = 'qsub: would exceed limit on resource ncpus in queue ' \
- + self.server.default_queue
- self.common_limit_test(False, a, attrs, exp_err=errmsg)
- def test_qalter_resource(self):
- """
- Test that qaltering a job's resource list is accounted
- """
- res_name = 'res_long'
- res_attr = {ATTR_RESC_TYPE: 'long', ATTR_RESC_FLAG: 'q'}
- rc = self.server.manager(MGR_CMD_CREATE, RSC, res_attr, id=res_name)
- a = {"max_queued_res." + res_name:
- "[o:PBS_ALL=" + str(self.limit) + "]"}
- qname = self.server.default_queue
- self.server.manager(MGR_CMD_SET, QUEUE, a, qname)
- self.server.manager(MGR_CMD_SET, SERVER, {ATTR_scheduling: 'False'})
- attrs = {ATTR_queue: qname, 'Resource_List.' + res_name: 9}
- j_1 = Job(TST_USR, attrs)
- J_1_id = self.server.submit(j_1)
- try:
- attrs = {ATTR_queue: qname, 'Resource_List.' + res_name: 2}
- j_2 = Job(TST_USR, attrs)
- self.server.submit(j_2)
- except PbsSubmitError as e:
- exp_err = 'qsub: would exceed limit on resource ' + res_name + \
- ' in queue ' + qname
- if e.msg[0] != exp_err:
- raise self.failureException("rcvd unexpected err message: "
- + e.msg[0])
- attribs = {'Resource_List.' + res_name: 8}
- self.server.alterjob(J_1_id, attribs)
- self.server.expect(JOB, attribs, id=J_1_id)
- self.server.submit(j_2)
- try:
- attrs = {ATTR_queue: qname, 'Resource_List.' + res_name: 1}
- j_3 = Job(TST_USR, attrs)
- self.server.submit(j_3)
- except PbsSubmitError as e:
- exp_err = 'qsub: would exceed limit on resource ' + res_name + \
- ' in queue ' + qname
- if e.msg[0] != exp_err:
- raise self.failureException("rcvd unexpected err message: "
- + e.msg[0])
- def test_multiple_queued_limits(self):
- defqname = self.server.default_queue
- q2name = 'q2'
- a = OrderedDict()
- a['queue_type'] = 'execution'
- a['enabled'] = 'True'
- a['started'] = 'True'
- self.server.manager(MGR_CMD_CREATE, QUEUE, a, id=q2name)
- a = {"queued_jobs_threshold":
- "[u:PBS_GENERIC=10]"}
- self.server.manager(MGR_CMD_SET, SERVER, a)
- a = {"queued_jobs_threshold":
- "[u:PBS_GENERIC=5]"}
- self.server.manager(MGR_CMD_SET, QUEUE, a, defqname)
- jd = Job(TST_USR, {ATTR_queue: defqname})
- j2 = Job(TST_USR, {ATTR_queue: q2name})
- jid = self.server.submit(jd)
- self.server.expect(JOB, {'job_state': 'R'}, id=jid)
- for _ in range(5):
- jd = Job(TST_USR, {ATTR_queue: defqname})
- self.server.submit(jd)
- try:
- self.server.submit(jd)
- except PbsSubmitError as e:
- exp_err = "qsub: would exceed queue generic's per-user limit " + \
- "of jobs in 'Q' state"
- if e.msg[0] != exp_err:
- raise self.failureException("rcvd unexpected err message: "
- + e.msg[0])
- else:
- self.assertFalse(True, "Job violating limits got submitted.")
- for _ in range(5):
- self.server.submit(j2)
- try:
- self.server.submit(j2)
- except PbsSubmitError as e:
- exp_err = "qsub: would exceed complex's per-user limit of " + \
- "jobs in 'Q' state"
- if e.msg[0] != exp_err:
- raise self.failureException("rcvd unexpected err message: "
- + e.msg[0])
- else:
- self.assertFalse(True, "Job violating limits got submitted.")
|