Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/documentation-website.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 24
node-version-file: .nvmrc
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run docs:build
Expand Down
2 changes: 1 addition & 1 deletion e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Make helpers importable from test modules
sys.path.insert(0, str(Path(__file__).parent))

from helpers import ( # noqa: E402
from helpers import (
BINARY_PATH,
MockFCCServer,
MockHTTPUpstream,
Expand Down
2 changes: 1 addition & 1 deletion e2e/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

# Re-export everything so ``from helpers import X`` keeps working.

from .config import build_config, build_single_service_config, write_temp_file
from .constants import (
BINARY_PATH,
FIXTURES_DIR,
LOOPBACK_IF,
MCAST_ADDR,
PROJECT_ROOT,
)
from .config import build_config, build_single_service_config, write_temp_file
from .http import (
assert_etag_cache_behavior,
extract_catchup_source,
Expand Down
32 changes: 16 additions & 16 deletions e2e/helpers/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_status_payload(host: str, port: int, timeout: float = 3.0, status_path:
sock = socket.create_connection((host, port), timeout=timeout)
data = b""
try:
request = "GET %s/sse HTTP/1.0\r\nHost: %s\r\n\r\n" % (status_path.rstrip("/"), host)
request = "GET {}/sse HTTP/1.0\r\nHost: {}\r\n\r\n".format(status_path.rstrip("/"), host)
sock.sendall(request.encode())
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
Expand Down Expand Up @@ -50,7 +50,7 @@ def wait_for_status_payload(
if last_payload is not None and predicate(last_payload):
return last_payload
time.sleep(0.05)
raise AssertionError("Status predicate not satisfied; last payload: %r" % last_payload)
raise AssertionError(f"Status predicate not satisfied; last payload: {last_payload!r}")


def http_get(
Expand Down Expand Up @@ -170,12 +170,12 @@ def raw_http_request(
"""
sock = socket.create_connection((host, port), timeout=timeout)
try:
sock.sendall(("%s %s HTTP/1.1\r\nHost: %s\r\n\r\n" % (method, path, host)).encode())
sock.sendall((f"{method} {path} HTTP/1.1\r\nHost: {host}\r\n\r\n").encode())
data = b""
while True:
try:
chunk = sock.recv(4096)
except socket.timeout:
except TimeoutError:
break
if not chunk:
break
Expand All @@ -199,12 +199,12 @@ def unix_http_request(
sock.settimeout(timeout)
try:
sock.connect(socket_path)
req_lines = ["%s %s HTTP/1.0" % (method, path), "Host: localhost"]
req_lines = [f"{method} {path} HTTP/1.0", "Host: localhost"]
payload = body or b""
for k, v in (headers or {}).items():
req_lines.append("%s: %s" % (k, v))
req_lines.append(f"{k}: {v}")
if payload:
req_lines.append("Content-Length: %d" % len(payload))
req_lines.append(f"Content-Length: {len(payload)}")
req_lines.append("")
req_lines.append("")
sock.sendall("\r\n".join(req_lines).encode() + payload)
Expand All @@ -213,7 +213,7 @@ def unix_http_request(
while True:
try:
chunk = sock.recv(4096)
except socket.timeout:
except TimeoutError:
break
if not chunk:
break
Expand Down Expand Up @@ -241,9 +241,9 @@ def extract_catchup_source(playlist_text, channel_name):
for line in playlist_text.splitlines():
if channel_name in line and "catchup-source=" in line:
match = re.search(r'catchup-source="([^"]+)"', line)
assert match, "Expected catchup-source in line: %s" % line
assert match, f"Expected catchup-source in line: {line}"
return line, match.group(1)
raise AssertionError("Expected catchup-source line for channel: %s" % channel_name)
raise AssertionError(f"Expected catchup-source line for channel: {channel_name}")


def stream_get(
Expand All @@ -267,13 +267,13 @@ def stream_get(
"""
try:
sock = socket.create_connection((host, port), timeout=timeout)
except OSError, socket.timeout:
except TimeoutError, OSError:
return 0, {}, b""
try:
host_hdr = "[%s]" % host if ":" in host and not host.startswith("[") else host
req_lines = ["GET %s HTTP/1.0" % path, "Host: %s" % host_hdr]
host_hdr = f"[{host}]" if ":" in host and not host.startswith("[") else host
req_lines = [f"GET {path} HTTP/1.0", f"Host: {host_hdr}"]
for k, v in (headers or {}).items():
req_lines.append("%s: %s" % (k, v))
req_lines.append(f"{k}: {v}")
req_lines.append("")
req_lines.append("")
sock.sendall("\r\n".join(req_lines).encode())
Expand All @@ -289,14 +289,14 @@ def stream_get(
sock.settimeout(min(remaining, 1.0))
try:
chunk = sock.recv(4096)
except socket.timeout:
except TimeoutError:
continue # keep trying until deadline
if not chunk:
break
data += chunk

return _parse_raw_http_response(data, lower_header_names=True)
except socket.timeout, OSError:
except TimeoutError, OSError:
return 0, {}, b""
finally:
sock.close()
2 changes: 1 addition & 1 deletion e2e/helpers/mock_fcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def _loop(self) -> None:
while not self._stop.is_set():
try:
data, addr = self._sock.recvfrom(4096)
except socket.timeout:
except TimeoutError:
continue
except OSError:
break
Expand Down
10 changes: 4 additions & 6 deletions e2e/helpers/mock_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from __future__ import annotations

from http.server import BaseHTTPRequestHandler, HTTPServer
import socket
import threading
import time
from http.server import BaseHTTPRequestHandler, HTTPServer

from .ports import find_free_port

Expand Down Expand Up @@ -59,7 +59,7 @@ def _dispatch(self, head: bool = False) -> None:
if not head:
self.wfile.write(body)

def log_message(self, format, *args) -> None: # noqa: ARG002, A002
def log_message(self, format, *args) -> None:
pass # silence


Expand Down Expand Up @@ -134,17 +134,15 @@ def _accept(self) -> None:
assert self._server_sock is not None
while not self._stop.is_set():
try:
conn, addr = self._server_sock.accept()
conn, _addr = self._server_sock.accept()
t = threading.Thread(target=self._handle, args=(conn,), daemon=True)
t.start()
except socket.timeout, OSError:
except TimeoutError, OSError:
continue

def _handle(self, conn: socket.socket) -> None:
try:
while not self._stop.is_set():
time.sleep(0.1)
except Exception:
pass
finally:
conn.close()
Loading
Loading