Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Check CPU after each test
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed May 3, 2021
1 parent c4abd3d commit dba341d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hawk_test_driver.py
Expand Up @@ -208,6 +208,16 @@ def check_and_click_by_xpath(self, errmsg, xpath_exps):
elem.click()
time.sleep(2 * self.timeout_scale)

# Check CPU
def check_cpu(self):
# Check ps
cmd = 'ps axo pcpu,comm | awk \'/bash/ {total += $1} END {print "cpu_usage["total"]"}\''
cpu_usage = int(self.ssh.ssh.exec_command(cmd)[1].read().decode().strip()[len("cpu_usage"):][1:-1])
print("INFO: CPU usage is %s" % cpu_usage)
if cpu_usage > 50:
return False
return True

# Generic function to perform the tests
def test(self, testname, results, *extra):
self.test_status = True # Clear internal test status before testing
Expand All @@ -219,6 +229,7 @@ def test(self, testname, results, *extra):
else:
self.set_test_status(results, testname, 'failed')
self.driver.save_screenshot('%s.png' % testname)
self.check_cpu()
self._close()

# Set STONITH/sbd in maintenance. Assumes stonith-sbd resource is the last one listed on the
Expand Down

0 comments on commit dba341d

Please sign in to comment.