Skip to content

Commit b3ec47c

Browse files
authored
Merge pull request #406 from kysrpex/customizable_test_file_server_port_and_files_endpoint
Customizable Pulsar test file server port and files endpoint
2 parents 7881005 + 0fc26f9 commit b3ec47c

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

test/integration_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,9 @@ def _run_in_app(test_configuration: IntegrationTestConfiguration, direct_interfa
450450
# server for Pulsar - webtest doesn't seem to like having two test
451451
# servers alive at same time.
452452
with files_server("/") as test_files_server:
453-
files_endpoint = to_infrastructure_uri(test_files_server.application_url)
453+
files_endpoint = to_infrastructure_uri(
454+
environ.get("PULSAR_TEST_INTERNAL_JOB_FILES_URL", test_files_server.application_url)
455+
)
454456
if direct_interface:
455457
_run_direct(test_configuration, files_endpoint=files_endpoint, **kwds)
456458
else:

test/test_utils.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,15 @@ def __init__(self):
251251

252252

253253
@contextmanager
254-
def server_for_test_app(test_app):
254+
def server_for_test_app(test_app, host=None, port=None):
255255
app = test_app.app
256-
create_kwds = {
257-
}
258-
if os.environ.get("PULSAR_TEST_FILE_SERVER_HOST"):
259-
create_kwds["host"] = os.environ.get("PULSAR_TEST_FILE_SERVER_HOST")
256+
257+
create_kwds = {}
258+
if host:
259+
create_kwds["host"] = host
260+
if port:
261+
create_kwds["port"] = port
262+
260263
server = StopableWSGIServer.create(app, **create_kwds)
261264
try:
262265
server.wait()
@@ -469,14 +472,16 @@ def files_server(directory=None):
469472
else:
470473
yield Bunch(application_url=external_url)
471474
else:
475+
host = os.environ.get("PULSAR_TEST_FILE_SERVER_HOST")
476+
port = os.environ.get("PULSAR_TEST_FILE_SERVER_PORT")
472477
if not directory:
473478
with temp_directory() as directory:
474479
app = TestApp(JobFilesApp(directory))
475-
with server_for_test_app(app) as server:
480+
with server_for_test_app(app, host=host, port=port) as server:
476481
yield server, directory
477482
else:
478483
app = TestApp(JobFilesApp(directory))
479-
with server_for_test_app(app) as server:
484+
with server_for_test_app(app, host=host, port=port) as server:
480485
yield server
481486

482487

0 commit comments

Comments
 (0)