diff options
author | Frederick Muriuki Muriithi | 2022-08-17 10:06:50 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-08-17 10:09:09 +0300 |
commit | dd1039afb7b6a8fd0a219c88b5661155abf1d758 (patch) | |
tree | 158e31ba236d6daf2c007a8f7f652943e1867582 | |
parent | bc589b21d21f157ceaa4b35ca511ff2df8fbc85f (diff) | |
download | genenetwork2-dd1039afb7b6a8fd0a219c88b5661155abf1d758.tar.gz |
Do incremental backoff for mechanical rob tests
Sometimes the tests might be run before the service has began
running. This commit delays the running of the tests for a while.
-rwxr-xr-x | test/requests/test-website.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/requests/test-website.py b/test/requests/test-website.py index 8062bff1..36d85e98 100755 --- a/test/requests/test-website.py +++ b/test/requests/test-website.py @@ -19,11 +19,24 @@ from unittest import TestSuite, TextTestRunner, TestLoader print("Mechanical Rob firing up...") +def host_is_online(host): + import time + import requests + for count in range(1, 11): + try: + time.sleep(count) + requests.get(host) + return True + except Exception as cre: + print(f"Retrying in {count + 1} seconds ...") + + return False def run_all(args_obj, parser): print("") print("Running all tests.") print(args_obj) + assert host_is_online(args_obj.host), f"Could not connect to {host}" link_checker.DO_FAIL = args_obj.fail check_main_web_functionality(args_obj, parser) check_links(args_obj, parser) |