From dd1039afb7b6a8fd0a219c88b5661155abf1d758 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 17 Aug 2022 10:06:50 +0300 Subject: 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. --- test/requests/test-website.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') 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) -- cgit v1.2.3