Skip to content

Commit 10afbb4

Browse files
committed
scripts: improved automated test scripts to explicitly report success
Signed-off-by: Waldemar Kozaczuk <[email protected]>
1 parent 70547a6 commit 10afbb4

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

scripts/tests/test_app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def run(command, hypervisor_name, image_path=None, line=None, guest_port=None, h
2828

2929
app.join()
3030

31+
print('----------')
32+
print('SUCCESS')
33+
3134
if __name__ == "__main__":
3235
parser = argparse.ArgumentParser(prog='test_app')
3336
parser.add_argument("-i", "--image", action="store", default=None, metavar="IMAGE",

scripts/tests/test_app_with_test_script.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ def run(command, hypervisor_name, host_port, guest_port, script_path, image_path
1515

1616
print("-----------------------------------")
1717
script_out = runpy.run_path(script_path)
18-
print("-----------------------------------")
19-
print("Success: %s" % script_out['success'])
2018

2119
if end_line != None:
2220
wait_for_line_contains(app, end_line)
2321

2422
app.kill()
2523
app.join()
2624

25+
print("-----------------------------------")
26+
if script_out['success'] == True:
27+
print("SUCCESS")
28+
else:
29+
print("FAILURE")
30+
2731
if __name__ == "__main__":
2832
parser = argparse.ArgumentParser(prog='test_app')
2933
parser.add_argument("-i", "--image", action="store", default=None, metavar="IMAGE",

scripts/tests/test_http_app_with_curl_and_ab.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def run(command, hypervisor_name, host_port, guest_port, http_path, expected_htt
5858
if expected_http_line != None:
5959
check_with_curl(app_url, expected_http_line)
6060

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

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

7376
if complete_requests < count:
7477
print("FAILED ab - too few complete requests : %d ? %d" % (complete_requests, count))
78+
success = False
79+
80+
if success:
81+
print('----------')
82+
print('SUCCESS')
7583

7684
if __name__ == "__main__":
7785
parser = argparse.ArgumentParser(prog='test_app')

0 commit comments

Comments
 (0)