def test_correct(self):
     file_name = 'data/correct.pbs'
     nr_syntax_events = 0
     nr_semantic_events = 0
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(nr_semantic_events, len(checker.events))
Beispiel #2
0
 def test_correct(self):
     file_name = 'data/correct.pbs'
     nr_syntax_events = 0
     nr_semantic_events = 0
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(nr_semantic_events, len(checker.events))
Beispiel #3
0
 def test_pmem_violation(self):
     file_name = 'data/pmem_violation.pbs'
     event_names = ['insufficient_nodes_mem']
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(len(event_names), len(checker.events))
     for event in checker.events:
         self.assertTrue(event['id'] in event_names)
     self.assertEquals(len(event_names), checker.nr_errors)
Beispiel #4
0
 def test_mem_pmem(self):
     file_name = 'data/mem_pmem.pbs'
     event_names = ['both_mem_pmem_specs']
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(len(event_names), len(checker.events))
     for event in checker.events:
         self.assertTrue(event['id'] in event_names)
     self.assertEquals(len(event_names), checker.nr_warnings)
 def test_pmem_violation(self):
     file_name = 'data/pmem_violation.pbs'
     event_names = ['insufficient_nodes_mem']
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(len(event_names), len(checker.events))
     for event in checker.events:
         self.assertTrue(event['id'] in event_names)
     self.assertEquals(len(event_names), checker.nr_errors)
 def test_mem_pmem(self):
     file_name = 'data/mem_pmem.pbs'
     event_names = ['both_mem_pmem_specs']
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(len(event_names), len(checker.events))
     for event in checker.events:
         self.assertTrue(event['id'] in event_names)
     self.assertEquals(len(event_names), checker.nr_warnings)
Beispiel #7
0
 def test_too_large_ppn(self):
     file_name = 'data/too_large_ppn.pbs'
     nr_syntax_events = 0
     nr_semantic_events = 1
     event_name = 'insufficient_ppn_nodes'
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(nr_semantic_events, len(checker.events))
     self.assertEquals(event_name, checker.events[0]['id'])
Beispiel #8
0
 def test_unknown_feature(self):
     file_name = 'data/unknown_feature.pbs'
     nr_syntax_events = 0
     nr_semantic_events = 1
     event_name = 'unknown_feature'
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(nr_semantic_events, len(checker.events))
     self.assertEquals(event_name, checker.events[0]['id'])
 def test_too_large_ppn(self):
     file_name = 'data/too_large_ppn.pbs'
     nr_syntax_events = 0
     nr_semantic_events = 1
     event_name = 'insufficient_ppn_nodes'
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(nr_semantic_events, len(checker.events))
     self.assertEquals(event_name, checker.events[0]['id'])
 def test_unknown_feature(self):
     file_name = 'data/unknown_feature.pbs'
     nr_syntax_events = 0
     nr_semantic_events = 1
     event_name = 'unknown_feature'
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(nr_semantic_events, len(checker.events))
     self.assertEquals(event_name, checker.events[0]['id'])
Beispiel #11
0
 def test_too_many_nodes(self):
     file_name = 'data/too_many_nodes.pbs'
     nr_syntax_events = 0
     event_names = ['insufficient_nodes', 'insufficient_ppn_nodes',
                    'insufficient_nodes_mem']
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(len(event_names), len(checker.events))
     for event in checker.events:
         self.assertTrue(event['id'] in event_names)
 def test_too_many_nodes(self):
     file_name = 'data/too_many_nodes.pbs'
     nr_syntax_events = 0
     event_names = ['insufficient_nodes', 'insufficient_ppn_nodes',
                    'insufficient_nodes_mem']
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(len(event_names), len(checker.events))
     for event in checker.events:
         self.assertTrue(event['id'] in event_names)
Beispiel #13
0
 def test_working_dir_no_var(self):
     file_name = 'tests/test/data/working_dir_no_var.pbs'
     event_names = ['missspelled']
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEqual(0, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     script_checker = ScriptChecker(self._config, self._event_defs)
     script_checker.check(parser.job, parser.script_first_line_nr)
     self.assertEqual(len(event_names), len(script_checker.events))
     for event in script_checker.events:
         self.assertTrue(event['id'] in event_names)
     self.assertEqual(len(event_names), script_checker.nr_warnings)
Beispiel #14
0
 def test_walltime_no_queue(self):
     file_name = 'data/walltime_no_queue.pbs'
     nr_syntax_events = 0
     nr_semantic_events = 0
     queue_name = 'qdef'
     expected_walltime = 45*3600 + 15*60
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(nr_semantic_events, len(checker.events))
     job = parser.job
     self.assertEquals(queue_name, job.queue)
     self.assertEquals(expected_walltime, job.resource_spec('walltime'))
 def test_walltime_no_queue(self):
     file_name = 'data/walltime_no_queue.pbs'
     nr_syntax_events = 0
     nr_semantic_events = 0
     queue_name = 'qdef'
     expected_walltime = 45*3600 + 15*60
     parser = PbsScriptParser(self._config, self._event_defs)
     with open(file_name, 'r') as pbs_file:
         parser.parse_file(pbs_file)
     self.assertEquals(nr_syntax_events, len(parser.events))
     checker = JobChecker(self._config, self._event_defs)
     checker.check(parser.job)
     self.assertEquals(nr_semantic_events, len(checker.events))
     job = parser.job
     self.assertEquals(queue_name, job.queue)
     self.assertEquals(expected_walltime, job.resource_spec('walltime'))
Beispiel #16
0
         event_defs = json.load(event_file)
 except EnvironmentError as error:
     msg = "### error: can not open event file '{0}'\n"
     sys.stderr.write(msg.format(conf['event_file']))
     sys.exit(CAN_NOT_OPEN_EVENT_FILE)
 indent = ' '*conf['report_indent']
 try:
     pbs_parser = PbsScriptParser(conf, event_defs)
     try:
         with open(options.pbs_file, 'r') as pbs_file:
             pbs_parser.parse_file(pbs_file)
     except EnvironmentError as error:
         msg = "### error: can not open PBS file '{0}'\n"
         sys.stderr.write(msg.format(options.events))
         sys.exit(CAN_NOT_OPEN_PBS)
     job_checker = JobChecker(conf, event_defs)
     job_checker.check(pbs_parser.job)
     pbs_parser.context = 'semantics'
     pbs_parser.merge_events(job_checker.events)
     script_checker = ScriptChecker(conf, event_defs)
     script_checker.check(pbs_parser.job,
                          pbs_parser.script_first_line_nr)
     pbs_parser.context = 'file'
     pbs_parser.merge_events(script_checker.events)
     nr_warnings = 0
     nr_errors = 0
     for event in pbs_parser.events:
         eid = event['id']
         if eid in event_defs:
             msg_tmpl = event_defs[eid]['message']
             msg = format_msg(msg_tmpl, event['extra'],