Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions rerun_py/tests/unit/test_datafusion_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import pathlib
import platform
import socket
import subprocess
import time
from typing import TYPE_CHECKING
Expand All @@ -20,8 +21,8 @@
from rerun_bindings import DatasetEntry

HOST = "localhost"
PORT = 51234
CATALOG_URL = f"rerun+http://{HOST}:{PORT}"
PORT = None # Will be set dynamically
CATALOG_URL = None # Will be set dynamically
DATASET_NAME = "dataset"

DATASET_FILEPATH = pathlib.Path(__file__).parent.parent.parent.parent / "tests" / "assets" / "rrd" / "dataset"
Expand Down Expand Up @@ -85,8 +86,6 @@ def shutdown_process(process: subprocess.Popen[str]) -> None:


def wait_for_server_ready(timeout: int = 30) -> None:
import socket

def is_port_open() -> bool:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
Expand Down Expand Up @@ -123,7 +122,16 @@ def server_instance() -> Generator[ServerInstance, None, None]:
# Server can be noisy by default
env["RUST_LOG"] = "warning"

# TODO(#11173): pick a free port
# Find a free port dynamically
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((HOST, 0))
global PORT
PORT = sock.getsockname()[1]
sock.close()

global CATALOG_URL
CATALOG_URL = f"rerun+http://{HOST}:{PORT}"

cmd = ["python", "-m", "rerun", "server", "--dataset", str(DATASET_FILEPATH), "--table", str(TABLE_FILEPATH)]
server_process = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

Expand Down
Loading