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
|
@ -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