From b3a74b94b3f44f54db5a466415aace0185bd451a Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 27 Dec 2016 17:38:31 -0500 Subject: [PATCH] Fix flaky port selection in registry tests Depends on https://github.com/jarus/flask-testing/pull/98 [Fixes #136705135] --- requirements-nover.txt | 2 +- requirements.txt | 2 +- test/registry_tests.py | 3 +-- test/testutil.py | 14 -------------- 4 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 test/testutil.py diff --git a/requirements-nover.txt b/requirements-nover.txt index 566280fb0..80a9efcb0 100644 --- a/requirements-nover.txt +++ b/requirements-nover.txt @@ -12,7 +12,7 @@ APScheduler==3.0.5 Flask-Login Flask-Mail Flask-Principal -Flask-Testing +-e git+https://github.com/jarus/flask-testing.git#egg=Flask-Testing PyGithub aiowsgi alembic diff --git a/requirements.txt b/requirements.txt index ca59eeadd..3ff9ac3fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,7 +24,7 @@ Flask-Login==0.3.2 Flask-Mail==0.9.1 Flask-Principal==0.4.0 Flask-RESTful==0.2.12 -Flask-Testing==0.6.1 +-e git+https://github.com/jarus/flask-testing.git@d60d431b3f2bc1b4b335579633e65978efa0a755#egg=Flask-Testing funcparserlib==0.3.6 funcsigs==1.0.2 functools32==3.2.3.post2 diff --git a/test/registry_tests.py b/test/registry_tests.py index cefc319c0..da2228552 100644 --- a/test/registry_tests.py +++ b/test/registry_tests.py @@ -42,7 +42,6 @@ from image.docker.schema1 import DockerSchema1ManifestBuilder from initdb import wipe_database, initialize_database, populate_database from jsonschema import validate as validate_schema from util.security.registry_jwt import decode_bearer_header -from test.testutil import get_open_port try: @@ -240,7 +239,7 @@ class RegistryTestCaseMixin(LiveServerTestCase): app.config['DEBUG'] = True app.config['TESTING'] = True - app.config['LIVESERVER_PORT'] = get_open_port() + app.config['LIVESERVER_PORT'] = 0 # LiveServerTestCase will choose the port for us. app.config['DB_URI'] = get_new_database_uri() return app diff --git a/test/testutil.py b/test/testutil.py deleted file mode 100644 index 6180cd13a..000000000 --- a/test/testutil.py +++ /dev/null @@ -1,14 +0,0 @@ -import socket - -def get_open_port(): - """ Retrieves an open port on the system. """ - - # Bind a socket to a random port. We can then ask for the port number, - # and return it. - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.bind(("", 0)) - s.listen(1) - port = s.getsockname()[1] - s.close() - - return port