diff --git a/geoportal/c2cgeoportal_geoportal/lib/check_collector.py b/geoportal/c2cgeoportal_geoportal/lib/check_collector.py index 907801c8379..4b458fc5ce5 100644 --- a/geoportal/c2cgeoportal_geoportal/lib/check_collector.py +++ b/geoportal/c2cgeoportal_geoportal/lib/check_collector.py @@ -54,7 +54,11 @@ def check(request): "%s/%s/health_check" % (host["url"].rstrip("/"), c2c_base.strip("/")), request ) - r = requests.get(params={"max_level": str(host.get("max_level", max_level))}, **url_headers) + r = requests.get( + params={"max_level": str(host.get("max_level", max_level))}, + timeout=120, + **url_headers + ) r.raise_for_status() return r.json() diff --git a/geoportal/c2cgeoportal_geoportal/lib/checker.py b/geoportal/c2cgeoportal_geoportal/lib/checker.py index aaaf4da2d78..f01a6384f7d 100644 --- a/geoportal/c2cgeoportal_geoportal/lib/checker.py +++ b/geoportal/c2cgeoportal_geoportal/lib/checker.py @@ -87,7 +87,11 @@ def check(request): url_headers = build_url("Check the printproxy request (create)", url, request) session = requests.session() - resp = session.post(json=print_settings["spec"], **url_headers) + resp = session.post( + json=print_settings["spec"], + timeout=30, + **url_headers + ) resp.raise_for_status() job = resp.json() @@ -97,7 +101,10 @@ def check(request): done = False while not done: sleep(1) - resp = session.get(**url_headers) + resp = session.get( + timeout=30, + **url_headers + ) resp.raise_for_status() status = resp.json() @@ -107,7 +114,10 @@ def check(request): url = request.route_url("printproxy_report_get", ref=job["ref"]) url_headers = build_url("Check the printproxy pdf retrieve", url, request) - resp = session.get(**url_headers) + resp = session.get( + timeout=30, + **url_headers + ) resp.raise_for_status() health_check.add_custom_check(name="checker_print", check_cb=check, level=print_settings["level"]) @@ -152,7 +162,11 @@ def check(request): interface_url_headers = build_url("checker_themes " + interface, url, request) - response = session.get(params=params, **interface_url_headers) + response = session.get( + params=params, + timeout=120, + **interface_url_headers + ) response.raise_for_status() result = response.json() diff --git a/travis/create-new-project.sh b/travis/create-new-project.sh index 00c72b542b5..ac6c4fd3838 100755 --- a/travis/create-new-project.sh +++ b/travis/create-new-project.sh @@ -28,5 +28,6 @@ git clean -fX # Build ./docker-run make --makefile=travis.mk build docker-build-testdb +./docker-compose-run bash -c 'wait-for-db; PGHOST=external-db; wait-for-db;' ./docker-compose-run make --makefile=travis.mk update-po ./docker-compose-run make --makefile=travis.mk theme2fts diff --git a/travis/test-new-project b/travis/test-new-project index 985df30be73..6a259372fcb 100755 --- a/travis/test-new-project +++ b/travis/test-new-project @@ -30,33 +30,20 @@ import sys import json -import subprocess +import urllib.request initial_error_length = 0 initial_access_length = 0 -curl_args = ["--connect-timeout", "1", "--max-time", "400", "--retry", "1"] - url = sys.argv[1] -try: - status_code = subprocess.check_output( - ["curl", "--write-out", "%{http_code}"] + curl_args + ["--silent", "--output", "/dev/null", url] - ).decode("utf-8") -except subprocess.CalledProcessError as e: - print("Exception on curl call: {}".format(e)) - - print("RESULT:") - sys.stdout.flush() - subprocess.call(["curl"] + curl_args + ["--verbose", url]) - exit(2) +result = urllib.request.urlopen(url, timeout=300) -if status_code == "200": +if result.status == 200: if len(sys.argv) == 3 and sys.argv[2] == "enum": - result = subprocess.check_output( - ["curl"] + curl_args + [url] - ).decode("utf-8") - if json.loads(result) == { + result = urllib.request.urlopen(url, timeout=600) + data = result.read().decode('urf-8') + if result.status == 200 and json.loads(data) == { "items": [{ "label": "car", "value": "car" @@ -68,15 +55,14 @@ if status_code == "200": print("enum OK") exit() else: - print("Incorrect result:") - print(result) + print("Incorrect result ({}):".format(result.status)) + print(data) exit(2) print("OK") exit() else: - print("Bad status code {}".format(status_code)) + print("Bad status code {}".format(result.status)) print("RESULT:") - sys.stdout.flush() - subprocess.call(["curl"] + curl_args + ["--verbose", url]) + print(result.read().decode('urf-8')) exit(2)