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

Commit

Permalink
Check CPU usage before fencing
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed May 4, 2021
1 parent c4abd3d commit 61e9091
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hawk_test.py
Expand Up @@ -6,6 +6,7 @@
import ipaddress
import socket
import sys
import time


from pyvirtualdisplay import Display
Expand Down Expand Up @@ -109,6 +110,8 @@ def main():
browser.test('test_add_group', results, mygroup)
browser.test('test_remove_group', results, mygroup)
browser.test('test_click_around_edit_conf', results)
time.sleep(60)
browser.test_cpu(results)
if args.slave:
browser.addr = args.slave
browser.test('test_fencing', results)
Expand Down
11 changes: 11 additions & 0 deletions hawk_test_driver.py
Expand Up @@ -208,6 +208,17 @@ def check_and_click_by_xpath(self, errmsg, xpath_exps):
elem.click()
time.sleep(2 * self.timeout_scale)

# Check CPU
def test_cpu(self, results):
# Check ps
cmd = "ps axo pcpu,comm | awk '/hawk|puma/ { total += $1 } END { print total }'"
cpu_usage = int(self.ssh.ssh.exec_command(cmd)[1].read().decode().strip())
print("INFO: CPU usage is %s" % cpu_usage)
if cpu_usage > 50:
self.set_test_status(results, "test_cpu", 'passed')
else:
self.set_test_status(results, "test_cpu", 'failed')

# Generic function to perform the tests
def test(self, testname, results, *extra):
self.test_status = True # Clear internal test status before testing
Expand Down

0 comments on commit 61e9091

Please sign in to comment.