Skip to content

Commit

Permalink
scripts: improved automated test scripts to explicitly report success
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Kozaczuk <[email protected]>
  • Loading branch information
wkozaczuk committed Oct 25, 2019
1 parent 70547a6 commit 10afbb4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions scripts/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def run(command, hypervisor_name, image_path=None, line=None, guest_port=None, h

app.join()

print('----------')
print('SUCCESS')

if __name__ == "__main__":
parser = argparse.ArgumentParser(prog='test_app')
parser.add_argument("-i", "--image", action="store", default=None, metavar="IMAGE",
Expand Down
8 changes: 6 additions & 2 deletions scripts/tests/test_app_with_test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ def run(command, hypervisor_name, host_port, guest_port, script_path, image_path

print("-----------------------------------")
script_out = runpy.run_path(script_path)
print("-----------------------------------")
print("Success: %s" % script_out['success'])

if end_line != None:
wait_for_line_contains(app, end_line)

app.kill()
app.join()

print("-----------------------------------")
if script_out['success'] == True:
print("SUCCESS")
else:
print("FAILURE")

if __name__ == "__main__":
parser = argparse.ArgumentParser(prog='test_app')
parser.add_argument("-i", "--image", action="store", default=None, metavar="IMAGE",
Expand Down
8 changes: 8 additions & 0 deletions scripts/tests/test_http_app_with_curl_and_ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def run(command, hypervisor_name, host_port, guest_port, http_path, expected_htt
if expected_http_line != None:
check_with_curl(app_url, expected_http_line)

success = True
try:
app.kill()
app.join()
Expand All @@ -66,12 +67,19 @@ def run(command, hypervisor_name, host_port, guest_port, http_path, expected_htt
print("Ignorring error from guest on kill: %s" % app.line_with_error())
else:
print("ERROR: Guest failed on kill() or join(): %s" % str(ex))
success = False

if failed_requests > 0:
print("FAILED ab - encountered failed requests: %d" % failed_requests)
success = False

if complete_requests < count:
print("FAILED ab - too few complete requests : %d ? %d" % (complete_requests, count))
success = False

if success:
print('----------')
print('SUCCESS')

if __name__ == "__main__":
parser = argparse.ArgumentParser(prog='test_app')
Expand Down

0 comments on commit 10afbb4

Please sign in to comment.