def test_on_html_snippet(self): HTML = b""" <h2 id="running_jobs">Running Jobs</h2> <table border="1" cellpadding="5" cellspacing="0" class="sortable" style="margin-top: 10px"> <thead><tr><td><b>Jobid</b></td><td><b>Started</b></td><td><b>Priority</b></td><td><b>User</b></td><td><b>Name</b></td><td><b>Map % Complete</b></td><td><b>Map Total</b></td><td><b>Maps Completed</b></td><td><b>Reduce % Complete</b></td><td><b>Reduce Total</b></td><td><b>Reduces Completed</b></td><td><b>Job Scheduling Information</b></td><td><b>Diagnostic Info </b></td></tr></thead> <tbody><tr><td id="job_0"><a href="http://localhost:40426/jobdetails.jsp?jobid=job_201508212327_0003&refresh=30">job_201508212327_0003</a></td><td id="started_0">Fri Aug 21 23:32:49 UTC 2015</td><td id="priority_0" sorttable_customkey="2">NORMAL</td><td id="user_0">hadoop</td><td id="name_0">streamjob7446105887001298606.jar</td><td>27.51%<table border="1px" width="80px"><tbody><tr><td cellspacing="0" class="perc_filled" width="50%"></td><td cellspacing="0" class="perc_nonfilled" width="50%"></td></tr></tbody></table></td><td>4</td><td>2</td><td>0.00%<table border="1px" width="80px"><tbody><tr><td cellspacing="0" class="perc_nonfilled" width="100%"></td></tr></tbody></table></td><td>1</td><td> 0</td><td>NA</td><td>NA</td></tr> </tbody><tfoot></tfoot></table> """ self.assertEqual(_parse_progress_from_job_tracker(HTML), (27.51, 0))
def test_ignore_complete_jobs(self): # regression test for #793 HTML = b""" <ul id="quicklinks-list"> <li><a href="#scheduling_info">Scheduling Info</a></li> <li><a href="#running_jobs">Running Jobs</a></li> <li><a href="#retired_jobs">Retired Jobs</a></li> <li><a href="#local_logs">Local Logs</a></li> </ul> <h2 id="running_jobs">Running Jobs</h2> <table border="1" cellpadding="5" cellspacing="0"> <tr><td align="center" colspan="8"><i>none</i></td></tr> </table> <hr> <h2 id="completed_jobs">Completed Jobs</h2><table border="1" cellpadding="5" cellspacing="0" class="sortable" style="margin-top: 10px"> <thead><tr><td><b>Jobid</b></td><td><b>Started</b></td><td><b>Priority</b></td><td><b>User</b></td><td><b>Name</b></td><td><b>Map % Complete</b></td><td><b>Map Total</b></td><td><b>Maps Completed</b></td><td><b>Reduce % Complete</b></td><td><b>Reduce Total</b></td><td><b>Reduces Completed</b></td><td><b>Job Scheduling Information</b></td><td><b>Diagnostic Info </b></td></tr></thead> <tr><td id="job_0"><a href="jobdetails.jsp?jobid=job_201611042349_0003&refresh=0">job_201611042349_0003</a></td><td id="started_0">Sat Nov 05 00:20:55 UTC 2016</td><td id="priority_0" sorttable_customkey="2">NORMAL</td><td id="user_0">hadoop</td><td id="name_0">streamjob4785184554048208079.jar</td><td>100.00%<table border="1px" width="80px"><tr><td cellspacing="0" class="perc_filled" width="100%"></td></tr></table></td><td>4</td><td>4</td><td>100.00%<table border="1px" width="80px"><tr><td cellspacing="0" class="perc_filled" width="100%"></td></tr></table></td><td>1</td><td> 1</td><td>NA</td><td>NA</td></tr> </table> """ self.assertEqual(_parse_progress_from_job_tracker(HTML), (None, None))
def test_empty(self): self.assertEqual(_parse_progress_from_job_tracker(b''), (None, None))