Skip to content

Commit 7669318

Browse files
committed
fixing tests
1 parent f668527 commit 7669318

File tree

2 files changed

+60
-15
lines changed

2 files changed

+60
-15
lines changed

.github/workflows/fireworks-tracing-tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
4242
PYTHONWARNINGS: "ignore::DeprecationWarning,ignore::RuntimeWarning"
4343
run: |
44-
# Run RemoteRolloutProcessor Propagate Status Smoke Test (now uses Fireworks tracing)
44+
# Run RemoteRolloutProcessor End-to-End Test (auto server startup)
45+
uv run pytest tests/remote_server/test_remote_fireworks.py::test_remote_rollout_and_fetch_fireworks \
46+
-v --tb=short
47+
48+
# Run RemoteRolloutProcessor Propagate Status Test (auto server startup)
4549
uv run pytest tests/remote_server/test_remote_fireworks_propagate_status.py::test_remote_rollout_and_fetch_fireworks_propagate_status \
4650
-v --tb=short

tests/remote_server/test_remote_fireworks.py

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
# MANUAL SERVER STARTUP REQUIRED:
2-
#
3-
# For Python server testing, start:
4-
# python -m tests.remote_server.remote_server (runs on http://127.0.0.1:3000)
5-
#
6-
# For TypeScript server testing, start:
7-
# cd tests/remote_server/typescript-server
8-
# npm install
9-
# npm start
10-
#
11-
# The TypeScript server should be running on http://127.0.0.1:3000
12-
# You only need to start one of the servers!
1+
# AUTO SERVER STARTUP: Server is automatically started and stopped by the test
132

143
import os
4+
import subprocess
5+
import socket
6+
import time
157
from typing import List
168

179
import pytest
10+
import requests
1811

1912
from eval_protocol.data_loader.dynamic_data_loader import DynamicDataLoader
2013
from eval_protocol.models import EvaluationRow, Message
@@ -27,6 +20,54 @@
2720
ROLLOUT_IDS = set()
2821

2922

23+
def find_available_port() -> int:
24+
"""Find an available port on localhost"""
25+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
26+
s.bind(("", 0))
27+
port = s.getsockname()[1]
28+
return port
29+
30+
31+
SERVER_PORT = find_available_port()
32+
33+
34+
def wait_for_server_to_startup(timeout: int = 120):
35+
start_time = time.time()
36+
while True:
37+
try:
38+
requests.get(f"http://127.0.0.1:{SERVER_PORT}")
39+
break
40+
except requests.exceptions.RequestException:
41+
time.sleep(1)
42+
if time.time() - start_time > timeout:
43+
raise TimeoutError(f"Server did not start within {timeout} seconds")
44+
45+
46+
@pytest.fixture(autouse=True)
47+
def setup_remote_server():
48+
"""Start the remote server"""
49+
# kill all Python processes matching "python -m tests.remote_server.remote_server"
50+
subprocess.run(["pkill", "-f", "python -m tests.remote_server.remote_server"], capture_output=True)
51+
52+
host = "127.0.0.1"
53+
process = subprocess.Popen(
54+
[
55+
"python",
56+
"-m",
57+
"tests.remote_server.remote_server",
58+
"--host",
59+
host,
60+
"--port",
61+
str(SERVER_PORT),
62+
]
63+
)
64+
# wait for the server to startup by polling
65+
wait_for_server_to_startup()
66+
yield
67+
process.terminate()
68+
process.wait()
69+
70+
3071
@pytest.fixture(autouse=True)
3172
def check_rollout_coverage():
3273
"""Ensure we processed all expected rollout_ids"""
@@ -64,15 +105,15 @@ def rows() -> List[EvaluationRow]:
64105
generators=[rows],
65106
),
66107
rollout_processor=RemoteRolloutProcessor(
67-
remote_base_url="http://127.0.0.1:3000",
108+
remote_base_url=f"http://127.0.0.1:{SERVER_PORT}",
68109
timeout_seconds=180,
69110
output_data_loader=fireworks_output_data_loader,
70111
),
71112
)
72113
async def test_remote_rollout_and_fetch_fireworks(row: EvaluationRow) -> EvaluationRow:
73114
"""
74115
End-to-end test:
75-
- REQUIRES MANUAL SERVER STARTUP: python -m tests.remote_server.remote_server
116+
- AUTO SERVER STARTUP: Server is automatically started and stopped by the test
76117
- trigger remote rollout via RemoteRolloutProcessor (calls init/status)
77118
- fetch traces from Langfuse via Fireworks tracing proxy filtered by metadata via output_data_loader; FAIL if none found
78119
"""

0 commit comments

Comments
 (0)