From 89825f6365aecec1cff60ae76d428baec43dd896 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mar 20 2018 01:17:13 +0000 Subject: Add a timeout to requests in our functional test suite. I'm having some issue where resultsdb isn't responding. Without this, my tests would hang indefinitely. With it, they still fail, but weirdly. Will address that in a different PR. --- diff --git a/functional-tests/conftest.py b/functional-tests/conftest.py index a374db3..e30a77d 100644 --- a/functional-tests/conftest.py +++ b/functional-tests/conftest.py @@ -14,6 +14,10 @@ import waiverdb.app import greenwave.app_factory +# It's all local, and so should be fast enough. +TEST_HTTP_TIMEOUT = int(os.environ.get('TEST_HTTP_TIMEOUT', 2)) + + class WSGIServerThread(threading.Thread): def __init__(self, application, init_func, port): @@ -137,6 +141,7 @@ class TestDataBuilder(object): response = self.requests_session.post( self.resultsdb_url + 'api/v2.0/results', headers={'Content-Type': 'application/json'}, + timeout=TEST_HTTP_TIMEOUT, data=json.dumps(data)) response.raise_for_status() return response.json() @@ -152,6 +157,7 @@ class TestDataBuilder(object): response = self.requests_session.post( self.resultsdb_url + 'api/v2.0/results', headers={'Content-Type': 'application/json'}, + timeout=TEST_HTTP_TIMEOUT, data=json.dumps(data)) response.raise_for_status() return response.json() @@ -169,6 +175,7 @@ class TestDataBuilder(object): self.waiverdb_url + 'api/v1.0/waivers/', auth=('dummy', 'dummy'), headers={'Content-Type': 'application/json'}, + timeout=TEST_HTTP_TIMEOUT, data=json.dumps(data)) response.raise_for_status() return response.json()