From cacfde40ba600d37a8acde454e9a107c5ab675a4 Mon Sep 17 00:00:00 2001 From: Hiren Vadalia Date: Mon, 3 Apr 2017 19:11:28 +0530 Subject: [PATCH] PP-736: update log_match in PTL to report failure --- test/fw/doc/conf.py | 14 +- test/fw/ptl/lib/pbs_testlib.py | 78 ++++--- test/fw/ptl/utils/pbs_dshutils.py | 2 + test/fw/ptl/utils/pbs_logutils.py | 1 + .../functional/pbs_Rrecord_resources_used.py | 208 +++++++----------- test/tests/functional/pbs_acct_log_trunc.py | 9 +- .../functional/pbs_accumulate_resc_used.py | 184 ++++++---------- .../functional/pbs_dup_acc_log_for_resv.py | 1 - test/tests/functional/pbs_hookswig.py | 6 +- test/tests/functional/pbs_job_routing.py | 6 +- .../pbs_multiple_execjob_launch_hook.py | 3 +- .../pbs_only_small_files_over_tpp.py | 10 +- .../tests/functional/pbs_periodic_constant.py | 5 +- .../functional/pbs_python_restart_settings.py | 57 ++--- .../functional/pbs_sched_subjob_badstate.py | 7 +- .../pbs_two_mom_hooks_resources_used.py | 13 +- .../pbs_unknown_resource_hook_update.py | 3 +- test/tests/functional/pbs_unset_exectime.py | 6 +- .../tests/functional/pbs_verify_log_output.py | 21 +- test/tests/pbs_smoketest.py | 77 +++---- 20 files changed, 291 insertions(+), 420 deletions(-) diff --git a/test/fw/doc/conf.py b/test/fw/doc/conf.py index a47c32c5c63..1bc1205e0ab 100644 --- a/test/fw/doc/conf.py +++ b/test/fw/doc/conf.py @@ -17,10 +17,10 @@ HAS_RTD = False try: - import sphinx_rtd_theme - HAS_RTD = True + import sphinx_rtd_theme + HAS_RTD = True except: - HAS_RTD = False + HAS_RTD = False # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -111,10 +111,10 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. if HAS_RTD: - html_theme = 'sphinx_rtd_theme' - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + html_theme = 'sphinx_rtd_theme' + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] else: - html_theme = 'sphinxdoc' + html_theme = 'sphinxdoc' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -240,7 +240,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [('index', 'pbstestlab', u'PbsTestLab Documentation', - [u'Copyright (C) 1994-2017 Altair Engineering, Inc'], 1)] + [u'Copyright (C) 1994-2017 Altair Engineering, Inc'], 1)] # If true, show URL addresses after external links. # man_show_urls = False diff --git a/test/fw/ptl/lib/pbs_testlib.py b/test/fw/ptl/lib/pbs_testlib.py index ec889c39842..f564a6f854e 100644 --- a/test/fw/ptl/lib/pbs_testlib.py +++ b/test/fw/ptl/lib/pbs_testlib.py @@ -469,6 +469,10 @@ class PbsQtermError(PtlException): pass +class PtlLogMatchError(PtlFailureException): + pass + + class PbsTypeSize(str): """ @@ -4627,7 +4631,7 @@ def log_lines(self, logtype, id=None, n=50, tail=True, day=None, def _log_match(self, logtype, msg, id=None, n=50, tail=True, allmatch=False, regexp=False, day=None, max_attempts=1, interval=1, starttime=None, endtime=None, - level=logging.INFO): + level=logging.INFO, existence=True): """ If ``'msg'`` found in the ``'n'`` lines of the log file, returns a ``tupe (x,y)`` where x is the matching line @@ -4653,6 +4657,7 @@ def _log_match(self, logtype, msg, id=None, n=50, tail=True, Defaults to False :type regex: bool :param day: Optional day in YYYMMDD format. + :type day: str or None :param max_attempts: the number of attempts to make to find a matching entry :type max_attemps: int @@ -4660,8 +4665,14 @@ def _log_match(self, logtype, msg, id=None, n=50, tail=True, :type interval: int :param starttime: If set ignore matches that occur before specified time + :type starttime: str or None :param endtime: If set ignore matches that occur after specified time + :type endtime: str or None + :param existence: If True (default), check for existence of + given msg, else check for non-existence of + given msg. + :type existence: bool .. note:: The matching line number is relative to the record number, not the absolute line number in the file. @@ -4669,14 +4680,15 @@ def _log_match(self, logtype, msg, id=None, n=50, tail=True, try: from ptl.utils.pbs_logutils import PBSLogUtils except: - self.logger.error('error loading ptl.utils.pbs_logutils') - return None + _msg = 'error loading ptl.utils.pbs_logutils' + raise PtlLogMatchError(rc=1, rv=False, msg=_msg) if self.logutils is None: self.logutils = PBSLogUtils() rv = (None, None) attempt = 1 + lines = None name = self._instance_to_servicename(logtype) infomsg = (name + ' ' + self.shortname + ' log match: searching for "' + msg + '"') @@ -4716,12 +4728,15 @@ def _log_match(self, logtype, msg, id=None, n=50, tail=True, lines.close() except: pass + if (rv is None and existence) or (rv is not None and not existence): + _msg = infomsg + attemptmsg + raise PtlLogMatchError(rc=1, rv=False, msg=_msg) return rv def accounting_match(self, msg, id=None, n=50, tail=True, allmatch=False, regexp=False, day=None, max_attempts=1, interval=1, starttime=None, - endtime=None): + endtime=None, level=logging.INFO, existence=True): """ Find msg in accounting log. @@ -4762,16 +4777,19 @@ def accounting_match(self, msg, id=None, n=50, tail=True, """ return self._log_match('accounting', msg, id, n, tail, allmatch, regexp, day, max_attempts, interval, starttime, - endtime) + endtime, level, existence) - def tracejob_match(self, msg, id=None, n=50, tail=True, allmatch=False, - regexp=False, **kwargs): + def tracejob_match(self, msg, id=None, n=50, tail=True, + allmatch=False, regexp=False, day=None, + max_attempts=1, interval=1, starttime=None, + endtime=None, level=logging.INFO, existence=True): """ Find msg in tracejob log. See _log_match for details """ return self._log_match('tracejob', msg, id, n, tail, allmatch, - regexp, kwargs) + regexp, day, max_attempts, interval, starttime, + endtime, level, existence) def _save_config_file(self, dict_conf, fname): ret = self.du.cat(self.hostname, fname, sudo=True) @@ -4982,13 +5000,14 @@ def restart(self): def log_match(self, msg=None, id=None, n=50, tail=True, allmatch=False, regexp=False, day=None, max_attempts=1, interval=1, - starttime=None, endtime=None, level=logging.INFO): + starttime=None, endtime=None, level=logging.INFO, + existence=True): """ Match the comm logs """ return self._log_match(self, msg, id, n, tail, allmatch, regexp, day, max_attempts, interval, starttime, endtime, - level=level) + level=level, existence=existence) class Server(PBSService): @@ -5453,13 +5472,14 @@ def restart(self): def log_match(self, msg=None, id=None, n=50, tail=True, allmatch=False, regexp=False, day=None, max_attempts=1, interval=1, - starttime=None, endtime=None, level=logging.INFO): + starttime=None, endtime=None, level=logging.INFO, + existence=True): """ Match the PBS server logs """ return self._log_match(self, msg, id, n, tail, allmatch, regexp, day, max_attempts, interval, starttime, endtime, - level=level) + level=level, existence=existence) def revert_to_defaults(self, reverthooks=True, revertqueues=True, revertresources=True, delhooks=True, @@ -10799,13 +10819,14 @@ def restart(self): def log_match(self, msg=None, id=None, n=50, tail=True, allmatch=False, regexp=False, day=None, max_attempts=1, interval=1, - starttime=None, endtime=None, level=logging.INFO): + starttime=None, endtime=None, level=logging.INFO, + existence=True): """ Match the scheduler logs """ return self._log_match(self, msg, id, n, tail, allmatch, regexp, day, max_attempts, interval, starttime, endtime, - level=level) + level=level, existence=existence) def pbs_version(self): """ @@ -11020,14 +11041,13 @@ def apply_config(self, config=None, validate=True, path=None): if validate: self.signal('-HUP') - - m = self.log_match("Error reading line", n=10, - starttime=reconfig_time) - if m is None: - # no match, successful config - return True - raise PbsSchedConfigError(rc=1, rv=False, msg=str(m)) - + try: + self.log_match("Error reading line", n=10, + starttime=reconfig_time, existence=False) + except PtlLogMatchError: + _msg = 'Error in validating sched_config changes' + raise PbsSchedConfigError(rc=1, rv=False, + msg=_msg) return True def set_sched_config(self, confs={}, apply=True, validate=True): @@ -12673,12 +12693,14 @@ def restart(self): def log_match(self, msg=None, id=None, n=50, tail=True, allmatch=False, regexp=False, day=None, max_attempts=1, interval=1, - starttime=None, endtime=None): + starttime=None, endtime=None, level=logging.INFO, + existence=True): """ Match the PBS mom logs """ return self._log_match(self, msg, id, n, tail, allmatch, regexp, day, - max_attempts, interval, starttime, endtime) + max_attempts, interval, starttime, endtime, + level, existence) def pbs_version(self): """ @@ -12810,10 +12832,12 @@ def is_cray(self): """ Returns True if the version of PBS used was built for Cray platforms """ - rv = self.log_match("alps_client", tail=False, max_attempts=10) - if rv: + try: + self.log_match("alps_client", tail=False, max_attempts=1) + except PtlLogMatchError: + return False + else: return True - return False def is_cpuset_mom(self): """ diff --git a/test/fw/ptl/utils/pbs_dshutils.py b/test/fw/ptl/utils/pbs_dshutils.py index db58436899f..deda00c7dad 100644 --- a/test/fw/ptl/utils/pbs_dshutils.py +++ b/test/fw/ptl/utils/pbs_dshutils.py @@ -63,6 +63,7 @@ class PbsConfigError(Exception): """ Initialize PBS configuration error """ + def __init__(self, message=None, rv=None, rc=None, msg=None): self.message = message self.rv = rv @@ -82,6 +83,7 @@ class PtlUtilError(Exception): """ Initialize PTL Util error """ + def __init__(self, message=None, rv=None, rc=None, msg=None): self.message = message self.rv = rv diff --git a/test/fw/ptl/utils/pbs_logutils.py b/test/fw/ptl/utils/pbs_logutils.py index 83062ba78ca..3c63cdf0dc8 100644 --- a/test/fw/ptl/utils/pbs_logutils.py +++ b/test/fw/ptl/utils/pbs_logutils.py @@ -1049,6 +1049,7 @@ class JobEstimatedStartTimeInfo(object): """ Information regarding Job estimated start time """ + def __init__(self, jobid): self.jobid = jobid self.started_at = None diff --git a/test/tests/functional/pbs_Rrecord_resources_used.py b/test/tests/functional/pbs_Rrecord_resources_used.py index 5120d3c61ac..2546bd5cc6a 100644 --- a/test/tests/functional/pbs_Rrecord_resources_used.py +++ b/test/tests/functional/pbs_Rrecord_resources_used.py @@ -139,15 +139,12 @@ def common(self, is_nonrerunnable, restart_mom): self.server.expect(JOB, {ATTR_substate: '42'}, jid3s1) # Verify that accounting logs have Resource_List. value - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) # Bring both moms down using kill -9 self.momA.signal('-KILL') @@ -169,31 +166,26 @@ def common(self, is_nonrerunnable, restart_mom): self.server.expect(JOB, {ATTR_state: 'F'}, jid2, extend='x') # tracejob should show "Job requeued, execution node down" - m = self.server.tracejob_match( + self.server.tracejob_match( msg='Job requeued, execution node .* down', id=jid1, regexp=True) - self.assertNotEqual(m, None) - - m = self.server.tracejob_match( - msg='Job requeued, execution node .* down', id=jid2, regexp=True) if is_nonrerunnable is False: - self.assertNotEqual(m, None) + e = True else: - self.assertIsNone(m) + e = False + msg = 'Job requeued, execution node .* down' + self.server.tracejob_match(msg=msg, id=jid2, regexp=True, + existence=e) - m = self.server.tracejob_match( + self.server.tracejob_match( msg='Job requeued, execution node .* down', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) self.server.manager(MGR_CMD_SET, SERVER, {'scheduling': 'False'}, expect=True) @@ -210,7 +202,6 @@ def common(self, is_nonrerunnable, restart_mom): return jid1, jid2, jid3s1 def test_t1(self): - """ Scenario: The node on which the job was running goes down and node_fail_requeue time-out is hit. @@ -220,19 +211,15 @@ def test_t1(self): jid1, jid2, jid3s1 = self.common(False, False) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*resources_used.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*resources_used.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + re.escape(jid3s1) + '.*resources_used.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) def test_t2(self): - """ Scenario: The node on which the job was running goes down and node_fail_requeue time-out is hit and mom is restarted @@ -243,20 +230,17 @@ def test_t2(self): jid1, jid2, jid3s1 = self.common(False, 'r') - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*resources_used.*run_count=1', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*resources_used.*run_count=1', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + re.escape(jid3s1) + '.*resources_used.*run_count=1', id=jid3s1, regexp=True) def test_t3(self): - """ Scenario: One non-rerunnable job. The node on which the job was running goes down and node_fail_requeue time-out is hit. @@ -269,21 +253,17 @@ def test_t3(self): jid1, jid2, jid3s1 = self.common(True, 'r') - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*resources_used.*run_count=1', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*resources_used.*run_count=1', id=jid2, regexp=True) - self.assertEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + re.escape(jid3s1) + '.*resources_used.*run_count=1', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) def test_t4(self): - """ Scenario: Mom restarted without '-r' option and jobs are requeued using qrerun. @@ -293,18 +273,15 @@ def test_t4(self): jid1, jid2, jid3s1 = self.common(False, 's') - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*resources_used.*run_count=1', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*resources_used.*run_count=1', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + re.escape(jid3s1) + '.*resources_used.*run_count=1', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) # Verify that the jobs are in 'Q' state. self.server.expect(JOB, {ATTR_state: 'Q'}, jid1) @@ -324,19 +301,16 @@ def test_t4(self): self.server.rerunjob(jobid=jid3s1) # Confirm that the 'R' record is generated and the run_count is 2. - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*resources_used.*run_count=2', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*resources_used.*run_count=2', id=jid2, regexp=True) - self.assertNotEqual(m, None) self.server.manager(MGR_CMD_SET, SERVER, {'scheduling': 'True'}, expect=True) def test_t5(self): - """ Scenario: Job is rerun multiple times. Expected outcome: Server should record last known resource usage @@ -378,26 +352,21 @@ def test_t5(self): # Verify that the accounting logs have Resource_List. but no # R records. - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( - msg='.*R;' + jid1 + '.*resources_used.*', id=jid1, regexp=True) - self.assertIsNone(m) - m = self.server.accounting_match( + msg = '.*R;' + jid1 + '.*resources_used.*' + self.server.accounting_match(msg=msg, id=jid1, regexp=True, + existence=False) + self.server.accounting_match( msg='.*Resource_List.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( - msg='.*R;' + jid2 + '.*resources_used.*', id=jid2, regexp=True) - self.assertIsNone(m) - m = self.server.accounting_match( + msg = '.*R;' + jid2 + '.*resources_used.*' + self.server.accounting_match(msg=msg, id=jid2, regexp=True, + existence=False) + self.server.accounting_match( msg='.*Resource_List.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) - - m = self.server.accounting_match(msg='.*R;' + re.escape(jid3s1) + + self.server.accounting_match(msg='.*R;' + re.escape(jid3s1) + '.*resources_used.*', id=jid3s1, - regexp=True) - self.assertIsNone(m) + regexp=True, existence=False) # sleep for 5 seconds so the jobs use some resources. time.sleep(5) @@ -408,20 +377,18 @@ def test_t5(self): # Verify that the accounting logs have R logs with last known resource # usage. No R logs for J2. - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*Exit_status=-11.*.*resources_used.*.*run_count=1.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( - msg='.*R;' + jid2 + '.*resources_used.*', id=jid2, regexp=True) - self.assertIsNone(m) + msg = '.*R;' + jid2 + '.*resources_used.*' + self.server.accounting_match(msg=msg, id=jid2, regexp=True, + existence=False) - m = self.server.accounting_match(msg='.*R;' + re.escape( + self.server.accounting_match(msg='.*R;' + re.escape( jid3s1) + '.*Exit_status=-11.*.*resources_used.*.*run_count=1.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) # sleep for 5 seconds so the jobs use some resources. time.sleep(5) @@ -432,22 +399,19 @@ def test_t5(self): # Verify that the accounting logs should R logs with last known # resource usage Resource_used and run_count should be 3 for J1. # No R logs in accounting for J2. - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*Exit_status=-11.*.*resources_used.*.*run_count=2.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( - msg='.*R;' + jid2 + '.*resources_used.*', id=jid2, regexp=True) - self.assertIsNone(m) - m = self.server.accounting_match( + msg = '.*R;' + jid2 + '.*resources_used.*' + self.server.accounting_match(msg=msg, id=jid2, regexp=True, + existence=False) + self.server.accounting_match( msg='.*R;' + re.escape(jid3s1) + '.*Exit_status=-11.*.*resources_used.*.*run_count=1.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) def test_t6(self): - """ Scenario: Jobs submitted with select cput and ncpus. Job is rerun multiple times. @@ -480,18 +444,16 @@ def test_t6(self): # Verify that the accounting logs have Resource_List. but no # R records. - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( - msg='.*R;' + jid1 + '.*resources_used.*', id=jid1, regexp=True) - self.assertIsNone(m) - m = self.server.accounting_match( + msg = '.*R;' + jid1 + '.*resources_used.*' + self.server.accounting_match(msg=msg, id=jid1, regexp=True, + existence=False) + self.server.accounting_match( msg='.*Resource_List.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( - msg='.*R;' + jid2 + '.*resources_used.*', id=jid2, regexp=True) - self.assertIsNone(m) + msg = '.*R;' + jid2 + '.*resources_used.*' + self.server.accounting_match(msg=msg, id=jid2, regexp=True, + existence=False) time.sleep(5) @@ -501,35 +463,30 @@ def test_t6(self): # Verify that the accounting logs have R record with last known # resource usage and run_count should be 2 for J1 and J2. - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*.*resources_used.cput=[0-9]*:[0-9]*:[0-9]*.*.*run_count=1.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*.*resources_used.cput=[0-9]*:[0-9]*:[0-9]*.*.*run_count=1.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) time.sleep(5) jids = self.server.select() self.server.rerunjob(jids) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*.*resources_used.cput=[0-9]*:[0-9]*:[0-9]*.*.*run_count=2.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*.*resources_used.cput=[0-9]*:[0-9]*:[0-9]*.*.*run_count=2.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) def test_t7(self): - """ Scenario: Job is forcefully rerun. Expected outcome: server should record last known resource usage in @@ -569,26 +526,23 @@ def test_t7(self): # Verify that the accounting logs have Resource_List. but no # R records. - m = self.server.accounting_match( + self.server.accounting_match( msg='.*Resource_List.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( - msg='.*R;' + jid1 + '.*resources_used.*', id=jid1, regexp=True) - self.assertIsNone(m) - m = self.server.accounting_match( + msg = '.*R;' + jid1 + '.*resources_used.*' + self.server.accounting_match(msg=msg, id=jid1, regexp=True, + existence=False) + self.server.accounting_match( msg='.*Resource_List.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( - msg='.*R;' + jid2 + '.*resources_used.*', id=jid2, regexp=True) - self.assertIsNone(m) - m = self.server.accounting_match( + msg = '.*R;' + jid2 + '.*resources_used.*' + self.server.accounting_match(msg=msg, id=jid2, regexp=True, + existence=False) + self.server.accounting_match( msg='.*Resource_List.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match(msg='.*R;' + + self.server.accounting_match(msg='.*R;' + re.escape(jid3s1) + '.*resources_used.*', - id=jid3s1, regexp=True) - self.assertIsNone(m) + id=jid3s1, regexp=True, + existence=False) time.sleep(5) @@ -598,20 +552,17 @@ def test_t7(self): # Verify that the accounting logs have R record with last known # resource usage and run_count should be 2 for J1 and J2 - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*Exit_status=0.*.*resources_used.*.*run_count=1.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*Exit_status=0.*.*resources_used.*.*run_count=1.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match(msg='.*R;' + re.escape( + self.server.accounting_match(msg='.*R;' + re.escape( jid3s1) + '.*Exit_status=0.*.*resources_used.*.*run_count=1.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) time.sleep(5) jids = self.server.select(extend='T') @@ -619,21 +570,18 @@ def test_t7(self): # Verify that the accounting logs have R record with last known # usage and run_count should be 3 for J1 and J2. - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid1 + '.*Exit_status=0.*.*resources_used.*.*run_count=2.*', id=jid1, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match( + self.server.accounting_match( msg='.*R;' + jid2 + '.*Exit_status=0.*.*resources_used.*.*run_count=2.*', id=jid2, regexp=True) - self.assertNotEqual(m, None) - m = self.server.accounting_match(msg='.*R;' + re.escape( + self.server.accounting_match(msg='.*R;' + re.escape( jid3s1) + '.*Exit_status=0.*.*resources_used.*.*run_count=1.*', id=jid3s1, regexp=True) - self.assertNotEqual(m, None) def tearDown(self): TestFunctional.tearDown(self) diff --git a/test/tests/functional/pbs_acct_log_trunc.py b/test/tests/functional/pbs_acct_log_trunc.py index 337b305f67b..d6a1817a611 100644 --- a/test/tests/functional/pbs_acct_log_trunc.py +++ b/test/tests/functional/pbs_acct_log_trunc.py @@ -84,14 +84,12 @@ def test_long_resource_end(self): # Make sure the accounting log hasn't been truncated log_match = 'resources_used.foo_str=' + hstr - m = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, log_match), regexp=True) - self.assertTrue(m) # Make sure the server log hasn't been truncated log_match = 'resources_used.foo_str=' + hstr - m = self.server.log_match("%s;.*%s.*" % (jid, log_match), regexp=True) - self.assertTrue(m) + self.server.log_match("%s;.*%s.*" % (jid, log_match), regexp=True) # Make sure emails are not truncated mailfile = os.environ['MAIL'] @@ -142,6 +140,5 @@ def test_long_resource_reque(self): # Make sure the accounting log hasn't been truncated acctlog_match = 'resources_used.foo_str=' + hstr - m = self.server.accounting_match( + self.server.accounting_match( "R;%s;.*%s.*" % (jid, acctlog_match), regexp=True) - self.assertTrue(m) diff --git a/test/tests/functional/pbs_accumulate_resc_used.py b/test/tests/functional/pbs_accumulate_resc_used.py index 53e045ae890..27d2787429b 100644 --- a/test/tests/functional/pbs_accumulate_resc_used.py +++ b/test/tests/functional/pbs_accumulate_resc_used.py @@ -135,15 +135,12 @@ def setUp(self): self.assertEqual(rc, 0) # Ensure the new resource is seen by all moms. - m = self.momA.log_match( + self.momA.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) - m = self.momB.log_match( + self.momB.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) - m = self.momC.log_match( + self.momC.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) attr['type'] = 'string' attr['flag'] = 'h' @@ -153,12 +150,9 @@ def setUp(self): self.assertEqual(rc, 0) # Ensure the new resource is seen by all moms. - m = self.momA.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) - m = self.momB.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) - m = self.momC.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) + self.momA.log_match("resourcedef;copy hook-related file") + self.momB.log_match("resourcedef;copy hook-related file") + self.momC.log_match("resourcedef;copy hook-related file") attr['type'] = 'string' attr['flag'] = 'h' @@ -168,12 +162,9 @@ def setUp(self): self.assertEqual(rc, 0) # Ensure the new resource is seen by all moms. - m = self.momA.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) - m = self.momB.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) - m = self.momC.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) + self.momA.log_match("resourcedef;copy hook-related file") + self.momB.log_match("resourcedef;copy hook-related file") + self.momC.log_match("resourcedef;copy hook-related file") attr['type'] = 'string_array' attr['flag'] = 'h' @@ -184,12 +175,9 @@ def setUp(self): # Give the moms a chance to receive the updated resource. # Ensure the new resource is seen by all moms. - m = self.momA.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) - m = self.momB.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) - m = self.momC.log_match("resourcedef;copy hook-related file") - self.assertTrue(m) + self.momA.log_match("resourcedef;copy hook-related file") + self.momB.log_match("resourcedef;copy hook-related file") + self.momC.log_match("resourcedef;copy hook-related file") def test_epilogue(self): """ @@ -279,74 +267,62 @@ def test_epilogue(self): self.server.expect(JOB, 'resources_used.foo_str3', op=UNSET, extend='x', id=jid) - m = self.momA.log_match( + self.momA.log_match( "Job %s resources_used.foo_str3 cannot be " % (jid,) + "accumulated: value '\"vn1\":4,\"vn2\":5,\"vn3\":6' " + "from mom %s not JSON-format" % (self.hostB,)) - self.assertTrue(m) # resources_used.foo_str2 must not be set. self.server.expect(JOB, 'resources_used.foo_str2', op=UNSET, id=jid) - m = self.momA.log_match( + self.momA.log_match( "Job %s resources_used.foo_str2 cannot be " % (jid,) + "accumulated: value 'seven' from mom %s " % (self.hostA,) + "not JSON-format") - self.assertTrue(m) # Match accounting_logs entry acctlog_match = 'resources_used.foo_f=0.29' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.foo_i=29' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = "resources_used.foo_str='%s'" % (foo_str_dict_out_str,) - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.vmem=29gb' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.cput=00:00:50' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) - acctlog_match = 'resources_used.foo_str2=' - s = self.server.accounting_match( - "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) # ensure resources_foo_str2 is not reported in accounting_logs since # it's unset due to non-JSON-format value. - self.assertFalse(s) + acctlog_match = 'resources_used.foo_str2=' + self.server.accounting_match("E;%s;.*%s.*" % (jid, acctlog_match), + regexp=True, n=100, existence=False) acctlog_match = 'resources_used.foo_str4=eight' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.ncpus=3' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) - acctlog_match = 'resources_used.foo_str3=', - s = self.server.accounting_match( - "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) # resources_used.foo_str3 must not show up in accounting_logs - self.assertFalse(s) + acctlog_match = 'resources_used.foo_str3=', + self.server.accounting_match("E;%s;.*%s.*" % (jid, acctlog_match), + regexp=True, n=100, existence=False) acctlog_match = 'resources_used.stra=\"glad\,elated\"\,\"happy\"' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) def test_prologue(self): """ @@ -441,15 +417,14 @@ def test_prologue(self): self.server.expect(JOB, 'resources_used.foo_str3', op=UNSET, extend='x', id=jid) - m1 = self.momA.log_match( + self.momA.log_match( "Job %s resources_used.foo_str3 cannot be " % (jid,) + "accumulated: value '\"vn1\":4,\"vn2\":5,\"vn3\":6' " + "from mom %s not JSON-format" % (self.hostB,)) - m2 = self.momA.log_match( + self.momA.log_match( "Job %s resources_used.foo_str3 cannot be " % (jid,) + "accumulated: value '\"vn1\":4,\"vn2\":5,\"vn3\":6' " + "from mom %s not JSON-format" % (self.hostC,)) - self.assertTrue(m1 or m2) # Ensure resources_used.foo_str3 is not set since it has a # non-JSON format value. @@ -458,65 +433,54 @@ def test_prologue(self): # resources_used.foo_str2 must not be set. self.server.expect(JOB, 'resources_used.foo_str2', op=UNSET, id=jid) - m = self.momA.log_match( + self.momA.log_match( "Job %s resources_used.foo_str2 cannot be " % (jid,) + "accumulated: value 'seven' from " + "mom %s not JSON-format" % (self.hostA,)) - self.assertTrue(m) # Match accounting_logs entry acctlog_match = 'resources_used.foo_f=0.35' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.foo_i=35' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = "resources_used.foo_str='%s'" % (foo_str_dict_out_str,) - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.vmem=35gb' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.cput=00:00:35' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) - acctlog_match = 'resources_used.foo_str2=' - s = self.server.accounting_match( - "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) # resources_used.foo_str2 should not be reported in accounting_logs. - self.assertFalse(s) + acctlog_match = 'resources_used.foo_str2=' + self.server.accounting_match("E;%s;.*%s.*" % (jid, acctlog_match), + regexp=True, n=100, existence=False) acctlog_match = 'resources_used.ncpus=3' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) - acctlog_match = 'resources_used.foo_str3=' - s = self.server.accounting_match( - "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) # resources_used.foo_str3 must not show up in accounting_logs - self.assertFalse(s) + acctlog_match = 'resources_used.foo_str3=' + self.server.accounting_match("E;%s;.*%s.*" % (jid, acctlog_match), + regexp=True, n=100, existence=False) acctlog_match = 'resources_used.foo_str4=eight' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.stra=\"glad\,elated\"\,\"happy\"' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) def test_periodic(self): """ @@ -643,52 +607,43 @@ def test_periodic(self): # Match accounting_logs entry acctlog_match = 'resources_used.foo_f=0.36' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.foo_i=36' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = "resources_used.foo_str='%s'" % ( foo_str_dict_out_str,) - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.vmem=36gb' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.cput=00:00:36' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) - acctlog_match = 'resources_used.foo_str2=', - s = self.server.accounting_match( - "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) # resources_used.foo_str2 must not show in accounting_logs - self.assertFalse(s) + acctlog_match = 'resources_used.foo_str2=', + self.server.accounting_match("E;%s;.*%s.*" % (jid, acctlog_match), + regexp=True, n=100, existence=False) acctlog_match = 'resources_used.ncpus=3' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = "resources_used.foo_str3='%s'" % ( foo_str3_dict_out_str.replace('.', '\.'). replace("#$%^&*@", "\#\$\%\^\&\*\@")) - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) acctlog_match = 'resources_used.stra=\"glad\,elated\"\,\"happy\"' - s = self.server.accounting_match( + self.server.accounting_match( "E;%s;.*%s.*" % (jid, acctlog_match), regexp=True, n=100) - self.assertTrue(s) def test_resource_bool(self): """ @@ -796,43 +751,34 @@ def test_reservation(self): self.server.manager( MGR_CMD_CREATE, RSC, attr, id='foo_i2', runas=ROOT_USER) # Ensure the new resource is seen by all moms. - m = self.momA.log_match( + self.momA.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) - m = self.momB.log_match( + self.momB.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) - m = self.momC.log_match( + self.momC.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) attr['type'] = 'float' self.server.manager( MGR_CMD_CREATE, RSC, attr, id='foo_f2', runas=ROOT_USER) # Ensure the new resource is seen by all moms. - m = self.momA.log_match( + self.momA.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) - m = self.momB.log_match( + self.momB.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) - m = self.momC.log_match( + self.momC.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) attr['type'] = 'string_array' self.server.manager( MGR_CMD_CREATE, RSC, attr, id='stra2', runas=ROOT_USER) # Ensure the new resource is seen by all moms. - m = self.momA.log_match( + self.momA.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) - m = self.momB.log_match( + self.momB.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) - m = self.momC.log_match( + self.momC.log_match( "resourcedef;copy hook-related file", max_attempts=3) - self.assertTrue(m) # Create an epilogue hook hook_body = """ diff --git a/test/tests/functional/pbs_dup_acc_log_for_resv.py b/test/tests/functional/pbs_dup_acc_log_for_resv.py index 11450e7eeef..9bf88ed0bf2 100644 --- a/test/tests/functional/pbs_dup_acc_log_for_resv.py +++ b/test/tests/functional/pbs_dup_acc_log_for_resv.py @@ -58,5 +58,4 @@ def test_accounting_logs(self): self.server.restart() m = self.server.accounting_match( msg='.*B;' + r1id, id=r1id, n='ALL', allmatch=True, regexp=True) - self.assertNotEqual(m, None) self.assertEqual(len(m), 1) diff --git a/test/tests/functional/pbs_hookswig.py b/test/tests/functional/pbs_hookswig.py index 81830479aa9..1e45501c544 100644 --- a/test/tests/functional/pbs_hookswig.py +++ b/test/tests/functional/pbs_hookswig.py @@ -74,10 +74,8 @@ def test_hook(self): jid = self.server.submit(j) except PbsSubmitError: pass - rv = self.server.log_match("Job;%s;server is %s" % ( + self.server.log_match("Job;%s;server is %s" % ( "newjob", self.server.shortname), max_attempts=3) - self.assertTrue(rv) - rv = self.mom.log_match("Job;%s;server is %s" % ( + self.mom.log_match("Job;%s;server is %s" % ( jid, self.server.shortname), max_attempts=3) - self.assertTrue(rv) diff --git a/test/tests/functional/pbs_job_routing.py b/test/tests/functional/pbs_job_routing.py index eec9f34be0c..dbf66b93bd4 100644 --- a/test/tests/functional/pbs_job_routing.py +++ b/test/tests/functional/pbs_job_routing.py @@ -111,10 +111,8 @@ def test_t1(self): id=jid, extend='t') # No errors should be in server logs - m = self.server.log_match( - msg='(job_route) Request invalid for state of job, state=7', - id=jid) - self.assertEqual(m, None) + msg = '(job_route) Request invalid for state of job, state=7' + self.server.log_match(msg, id=jid, existence=False) # Start routing queue and verify job array queue set to default queue a = {ATTR_start: 'True'} diff --git a/test/tests/functional/pbs_multiple_execjob_launch_hook.py b/test/tests/functional/pbs_multiple_execjob_launch_hook.py index a9ead6b7ba2..f3a65bfc680 100644 --- a/test/tests/functional/pbs_multiple_execjob_launch_hook.py +++ b/test/tests/functional/pbs_multiple_execjob_launch_hook.py @@ -92,7 +92,6 @@ def test_multi_execjob_hook(self): ATTR_o: '/tmp/'}) job.set_sleep_time(1) jid = self.server.submit(job) - retval = self.mom.log_match( + self.mom.log_match( "Modified progname value got updated from launch1", max_attempts=3, interval=3) - self.assertTrue(retval) diff --git a/test/tests/functional/pbs_only_small_files_over_tpp.py b/test/tests/functional/pbs_only_small_files_over_tpp.py index 4f3f98d8fa0..9633058d020 100644 --- a/test/tests/functional/pbs_only_small_files_over_tpp.py +++ b/test/tests/functional/pbs_only_small_files_over_tpp.py @@ -109,8 +109,8 @@ def test_small_job_file(self): 'still in progress for' in e.msg[0]) msg = jid + ";big job files, sending via subprocess" - rv = self.server.log_match(msg, max_attempts=10, interval=2) - self.assertFalse(rv) + self.server.log_match(msg, max_attempts=10, interval=2, + existence=False) def test_big_job_file(self): """ @@ -136,8 +136,7 @@ def test_big_job_file(self): 'still in progress for' in e.msg[0]) msg = jid + ";big job files, sending via subprocess" - rv = self.server.log_match(msg, max_attempts=30, interval=2) - self.assertTrue(rv) + self.server.log_match(msg, max_attempts=30, interval=2) def test_big_job_script(self): """ @@ -159,6 +158,5 @@ def test_big_job_script(self): id=jid, max_attempts=30, interval=2) msg = jid + ";big job files, sending via subprocess" - rv = self.server.log_match( + self.server.log_match( msg, max_attempts=30, interval=2) - self.assertTrue(rv) diff --git a/test/tests/functional/pbs_periodic_constant.py b/test/tests/functional/pbs_periodic_constant.py index d301a9bbac9..feb2f97dbfd 100644 --- a/test/tests/functional/pbs_periodic_constant.py +++ b/test/tests/functional/pbs_periodic_constant.py @@ -64,6 +64,5 @@ def test_periodic_constant_via_server_log(self): overwrite=True) self.assertTrue(retval) - retval = self.server.log_match("This hook is using pbs.PERIODIC", - max_attempts=10) - self.assertTrue(retval) + self.server.log_match("This hook is using pbs.PERIODIC", + max_attempts=10) diff --git a/test/tests/functional/pbs_python_restart_settings.py b/test/tests/functional/pbs_python_restart_settings.py index 2ab22bfc39f..d98214cedce 100644 --- a/test/tests/functional/pbs_python_restart_settings.py +++ b/test/tests/functional/pbs_python_restart_settings.py @@ -171,21 +171,18 @@ def test_log_message(self): self.server.manager(MGR_CMD_SET, SERVER, {'python_restart_max_hooks': 200}, runas=ROOT_USER, logerr=True) - rv = self.server.log_match("python_restart_max_hooks = 200", - max_attempts=5) - self.assertTrue(rv) + self.server.log_match("python_restart_max_hooks = 200", + max_attempts=5) self.server.manager(MGR_CMD_SET, SERVER, {'python_restart_max_objects': 2000}, runas=ROOT_USER, logerr=True) - rv = self.server.log_match("python_restart_max_objects = 2000", - max_attempts=5) - self.assertTrue(rv) + self.server.log_match("python_restart_max_objects = 2000", + max_attempts=5) self.server.manager(MGR_CMD_SET, SERVER, {'python_restart_min_interval': "00:01:00"}, runas=ROOT_USER, logerr=True) - rv = self.server.log_match("python_restart_min_interval = 00:01:00", - max_attempts=5) - self.assertTrue(rv) + self.server.log_match("python_restart_min_interval = 00:01:00", + max_attempts=5) def test_long_values(self): """ @@ -322,20 +319,16 @@ def test_max_hooks(self): self.assertTrue(diff >= 3 and diff <= 5) # This message only gets printed if /proc/self/statm is present if os.path.isfile("/proc/self/statm"): - rv = self.server.log_match("Current memory usage:", - starttime=self.server.ctime, - max_attempts=5) - self.assertTrue(rv) + self.server.log_match("Current memory usage:", + starttime=self.server.ctime, + max_attempts=5) else: - rv = self.server.log_match("unknown", max_attempts=5) - self.assertTrue(rv) + self.server.log_match("unknown", max_attempts=5) # Verify other log messages - rv = self.server.log_match("python_restart_max_hooks is now 1", - starttime=stime, max_attempts=5) - self.assertTrue(rv) - rv = self.server.log_match("python_restart_min_interval is now 3", - starttime=stime, max_attempts=5) - self.assertTrue(rv) + self.server.log_match("python_restart_max_hooks is now 1", + starttime=stime, max_attempts=5) + self.server.log_match("python_restart_min_interval is now 3", + starttime=stime, max_attempts=5) def test_max_objects(self): """ @@ -380,29 +373,24 @@ def test_max_objects(self): self.server.expect(JOB, {'job_state': "H"}, id=jid) self.server.alterjob(jid, {ATTR_N: "yaya"}) # Verify that python is restarted - rv = self.server.log_match( + self.server.log_match( "Restarting Python interpreter to reduce mem usage", starttime=self.server.ctime, max_attempts=5) - self.assertTrue(rv) # This message only gets printed if # /proc/self/statm presents if os.path.isfile("/proc/self/statm"): - rv = self.server.log_match( + self.server.log_match( "Current memory usage:", starttime=self.server.ctime, max_attempts=5) - self.assertTrue(rv) else: - rv = self.server.log_match("unknown", max_attempts=5) - self.assertTrue(rv) + self.server.log_match("unknown", max_attempts=5) # Verify other log messages - rv = self.server.log_match( + self.server.log_match( "python_restart_max_objects is now 1", starttime=stime, max_attempts=5) - self.assertTrue(rv) - rv = self.server.log_match( + self.server.log_match( "python_restart_min_interval is now 1", starttime=stime, max_attempts=5) - self.assertTrue(rv) def test_no_restart(self): """ @@ -433,7 +421,6 @@ def test_no_restart(self): j.set_sleep_time(1) jid = self.server.submit(j) # Verify no restart message - rv = self.server.log_match( - "Restarting Python interpreter to reduce mem usage", - starttime=stime, max_attempts=8) - self.assertFalse(rv) + msg = "Restarting Python interpreter to reduce mem usage" + self.server.log_match(msg, starttime=stime, max_attempts=8, + existence=False) diff --git a/test/tests/functional/pbs_sched_subjob_badstate.py b/test/tests/functional/pbs_sched_subjob_badstate.py index 1c517df26f1..c33d060e670 100644 --- a/test/tests/functional/pbs_sched_subjob_badstate.py +++ b/test/tests/functional/pbs_sched_subjob_badstate.py @@ -72,8 +72,7 @@ def test_sched_badstate_subjob(self): attr = {'scheduling': 'True'} self.server.manager(MGR_CMD_SET, SERVER, attr, expect=True) - rv = self.scheduler.log_match("Leaving Scheduling Cycle", - starttime=now, - max_attempts=3, interval=1) + self.scheduler.log_match("Leaving Scheduling Cycle", + starttime=now, + max_attempts=3, interval=1) self.server.delete(j1id) - self.assertTrue(rv) diff --git a/test/tests/functional/pbs_two_mom_hooks_resources_used.py b/test/tests/functional/pbs_two_mom_hooks_resources_used.py index 930395bd70b..ea33aa6e2f3 100644 --- a/test/tests/functional/pbs_two_mom_hooks_resources_used.py +++ b/test/tests/functional/pbs_two_mom_hooks_resources_used.py @@ -111,9 +111,7 @@ def test_Rrecord(self): # Check for resources_used value in the 'R' record. msg = '.*R;' + str(jid1) + '.*resources_used.ncpus=2.*' - m = self.server.accounting_match( - msg, tail=True, regexp=True) - self.assertNotEqual(m, None) + self.server.accounting_match(msg, tail=True, regexp=True) def test_Erecord(self): """ @@ -154,12 +152,9 @@ def test_Erecord(self): # Check for the E record to NOT have zero walltime. msg = '.*E;' + str(jid1) + '.*resources_used.walltime=\"00:00:00.*' - m = self.server.accounting_match( - msg, tail=True, regexp=True) - self.assertEqual(m, None) + self.server.accounting_match(msg, tail=True, regexp=True, + existence=False) # Check for the E record to have non-zero ncpus. msg = '.*E;' + str(jid1) + '.*resources_used.ncpus=2.*' - m = self.server.accounting_match( - msg, tail=True, regexp=True) - self.assertNotEqual(m, None) + self.server.accounting_match(msg, tail=True, regexp=True) diff --git a/test/tests/functional/pbs_unknown_resource_hook_update.py b/test/tests/functional/pbs_unknown_resource_hook_update.py index 386b851d34f..cd06fdd541a 100644 --- a/test/tests/functional/pbs_unknown_resource_hook_update.py +++ b/test/tests/functional/pbs_unknown_resource_hook_update.py @@ -75,5 +75,4 @@ def test_epilogue_update(self): # update log_match = 'unable to update attribute resources_used.foo_str ' log_match += 'in job_obit' - m = self.server.log_match("%s;.*%s.*" % (jid, log_match), regexp=True) - self.assertTrue(m) + self.server.log_match("%s;.*%s.*" % (jid, log_match), regexp=True) diff --git a/test/tests/functional/pbs_unset_exectime.py b/test/tests/functional/pbs_unset_exectime.py index 2c1642925c5..e0de1199d81 100644 --- a/test/tests/functional/pbs_unset_exectime.py +++ b/test/tests/functional/pbs_unset_exectime.py @@ -65,6 +65,6 @@ def test_unset_exectime(self): expect=True) j = Job(TEST_USER) self.server.submit(j) - msg = "Error evaluating Python script, exec_time could not be parsed" - rv = self.server.log_match(msg, max_attempts=5) - self.assertFalse(rv) + msg = "Error evaluating Python script, " + msg += "exec_time could not be parsed" + self.server.log_match(msg, max_attempts=5, existence=False) diff --git a/test/tests/functional/pbs_verify_log_output.py b/test/tests/functional/pbs_verify_log_output.py index d3c12ab854c..fb42088d038 100644 --- a/test/tests/functional/pbs_verify_log_output.py +++ b/test/tests/functional/pbs_verify_log_output.py @@ -51,6 +51,7 @@ class TestVerifyLogOutput(TestFunctional): Test that hostname and interface information is added to all logs at log open """ + def setUp(self): TestFunctional.setUp(self) @@ -77,34 +78,31 @@ def all_interfaces(self): break namestr = names.tostring() for i in range(0, outbytes, struct_size): - yield namestr[i:i+16].split('\0', 1)[0] + yield namestr[i:i + 16].split('\0', 1)[0] def test_hostname_add(self): """ Test for hostname presence in log files """ log_val = socket.gethostname() - rv = self.scheduler.log_match( + self.scheduler.log_match( log_val, regexp=False, starttime=self.server.ctime, max_attempts=5, interval=2) - self.assertTrue(rv) - rv = self.server.log_match( + self.server.log_match( log_val, regexp=False, starttime=self.server.ctime, max_attempts=5, interval=2) - self.assertTrue(rv) - rv = self.mom.log_match( + self.mom.log_match( log_val, regexp=False, starttime=self.server.ctime, max_attempts=5, interval=2) - self.assertTrue(rv) def test_if_info_add(self): """ @@ -116,24 +114,21 @@ def test_if_info_add(self): log_val = "[( interface: )]" + name # Workaround for PTL regex to match # entire word once using () inside [] - rv = self.scheduler.log_match( + self.scheduler.log_match( log_val, regexp=True, starttime=self.server.ctime, max_attempts=5, interval=2) - self.assertTrue(rv) - rv = self.server.log_match( + self.server.log_match( log_val, regexp=True, starttime=self.server.ctime, max_attempts=5, interval=2) - self.assertTrue(rv) - rv = self.mom.log_match( + self.mom.log_match( log_val, regexp=True, starttime=self.server.ctime, max_attempts=5, interval=2) - self.assertTrue(rv) diff --git a/test/tests/pbs_smoketest.py b/test/tests/pbs_smoketest.py index ff5ae913474..1b0331bc091 100644 --- a/test/tests/pbs_smoketest.py +++ b/test/tests/pbs_smoketest.py @@ -447,8 +447,7 @@ def test_server_hook(self): self.server.submit(j) except PbsSubmitError: pass - rv = self.server.log_match("my custom message") - self.assertTrue(rv) + self.server.log_match("my custom message") def test_mom_hook(self): """ @@ -460,16 +459,14 @@ def test_mom_hook(self): a = {'event': 'execjob_begin', 'enabled': 'True'} self.server.create_import_hook(hook_name, a, hook_body) # Asynchronous copy of hook content, we wait for the copy to occur - rv = self.server.log_match(".*successfully sent hook file.*" + - hook_name + ".PY" + ".*", regexp=True, - max_attempts=100, interval=5) - self.assertTrue(rv) + self.server.log_match(".*successfully sent hook file.*" + + hook_name + ".PY" + ".*", regexp=True, + max_attempts=100, interval=5) j = Job(TEST_USER) jid = self.server.submit(j) self.server.expect(JOB, {ATTR_state: 'H'}, id=jid) - rv = self.mom.log_match("my custom message", max_attempts=10, - starttime=self.server.ctime) - self.assertTrue(rv) + self.mom.log_match("my custom message", max_attempts=10, + starttime=self.server.ctime) @skipOnCpuSet def test_shrink_to_fit(self): @@ -922,42 +919,34 @@ def test_job_sort_formula_threshold(self): interval=2) self.server.expect(JOB, {'job_state': 'Q'}, id=j1id, max_attempts=30, interval=2) - rv = self.scheduler.log_match(j1id + ";Formula Evaluation = 7", - regexp=True, starttime=self.server.ctime, - max_attempts=10, interval=2) - self.assertTrue(rv) + self.scheduler.log_match(j1id + ";Formula Evaluation = 7", + regexp=True, starttime=self.server.ctime, + max_attempts=10, interval=2) m = ";Job's formula value 7 is under threshold 7" - rv = self.scheduler.log_match(j1id + m, - regexp=True, starttime=self.server.ctime, - max_attempts=10, interval=2) - self.assertTrue(rv) + self.scheduler.log_match(j1id + m, + regexp=True, starttime=self.server.ctime, + max_attempts=10, interval=2) m = ";Job is under job_sort_formula threshold value" - rv = self.scheduler.log_match(j1id + m, - regexp=True, starttime=self.server.ctime, - max_attempts=10, interval=2) - self.assertTrue(rv) - rv = self.scheduler.log_match(j2id + ";Formula Evaluation = 7", - regexp=True, starttime=self.server.ctime, - max_attempts=10, interval=2) - self.assertTrue(rv) + self.scheduler.log_match(j1id + m, + regexp=True, starttime=self.server.ctime, + max_attempts=10, interval=2) + self.scheduler.log_match(j2id + ";Formula Evaluation = 7", + regexp=True, starttime=self.server.ctime, + max_attempts=10, interval=2) m = ";Job's formula value 7 is under threshold 7" - rv = self.scheduler.log_match(j2id + m, - regexp=True, starttime=self.server.ctime, - max_attempts=10, interval=2) - self.assertTrue(rv) + self.scheduler.log_match(j2id + m, + regexp=True, starttime=self.server.ctime, + max_attempts=10, interval=2) m = ";Job is under job_sort_formula threshold value" - rv = self.scheduler.log_match(j1id + m, - regexp=True, starttime=self.server.ctime, - max_attempts=10, interval=2) - self.assertTrue(rv) - rv = self.scheduler.log_match(j3id + ";Formula Evaluation = 8", - regexp=True, starttime=self.server.ctime, - max_attempts=10, interval=2) - self.assertTrue(rv) - rv = self.scheduler.log_match(j4id + ";Formula Evaluation = 9", - regexp=True, starttime=self.server.ctime, - max_attempts=10, interval=2) - self.assertTrue(rv) + self.scheduler.log_match(j1id + m, + regexp=True, starttime=self.server.ctime, + max_attempts=10, interval=2) + self.scheduler.log_match(j3id + ";Formula Evaluation = 8", + regexp=True, starttime=self.server.ctime, + max_attempts=10, interval=2) + self.scheduler.log_match(j4id + ";Formula Evaluation = 9", + regexp=True, starttime=self.server.ctime, + max_attempts=10, interval=2) def isSuspended(self, ppid): """ @@ -1379,9 +1368,8 @@ def test_fairshare_enhanced(self): self.server.expect( JOB, {'job_state': 'R'}, id=j1id, max_attempts=30, interval=2) - rv = self.server.log_match( + self.server.log_match( j1id + ";Exit_status", max_attempts=30, interval=2) - self.assertTrue(rv) time.sleep(1) @@ -1440,9 +1428,8 @@ def test_fairshare_enhanced(self): self.server.expect( JOB, {'job_state': 'R'}, id=j2id, max_attempts=30, interval=2) - rv = self.server.log_match( + self.server.log_match( j2id + ";Exit_status", max_attempts=30, interval=2) - self.assertTrue(rv) time.sleep(1)