Fix flaky port selection in registry tests
Depends on https://github.com/jarus/flask-testing/pull/98 [Fixes #136705135]
This commit is contained in:
parent
9667eab12c
commit
b3a74b94b3
4 changed files with 3 additions and 18 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
Reference in a new issue