Skip to content

Commit aa07e29

Browse files
rojiCopilot
andauthored
Stabilize Python streaming resume E2E test (#2597)
* Stabilize Python streaming resume E2E test Wait for the detached session lock to release before cold-resuming it from a new CLI process, avoiding a timing race in merge-queue runs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Cover both Python streaming resume paths Reuse the session-lock release wait before every cold-resume path in the streaming fidelity E2E test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent cd8cf15 commit aa07e29

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

‎python/e2e/test_streaming_fidelity_e2e.py‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,29 @@
55
import pytest
66

77
from copilot import CopilotClient, RuntimeConnection
8+
from copilot.rpc import SessionsCheckInUseRequest
89
from copilot.session import PermissionHandler
910

10-
from .testharness import E2ETestContext
11+
from .testharness import E2ETestContext, wait_for_condition
1112

1213
pytestmark = pytest.mark.asyncio(loop_scope="module")
1314

15+
RESUME_LOCK_TIMEOUT = 60.0
16+
17+
18+
async def _wait_for_session_lock_release(ctx: E2ETestContext, session_id: str) -> None:
19+
async def session_lock_is_released() -> bool:
20+
result = await ctx.client.rpc.sessions.check_in_use(
21+
SessionsCheckInUseRequest(session_ids=[session_id])
22+
)
23+
return session_id not in result.in_use
24+
25+
await wait_for_condition(
26+
session_lock_is_released,
27+
timeout=RESUME_LOCK_TIMEOUT,
28+
timeout_message=f"Timed out waiting for session '{session_id}' to release its lock.",
29+
)
30+
1431

1532
class TestStreamingFidelity:
1633
async def test_should_produce_delta_events_when_streaming_is_enabled(self, ctx: E2ETestContext):
@@ -70,9 +87,12 @@ async def test_should_produce_deltas_after_session_resume(self, ctx: E2ETestCont
7087
session = await ctx.client.create_session(
7188
on_permission_request=PermissionHandler.approve_all, streaming=False
7289
)
90+
session_id = session.session_id
7391
await session.send_and_wait("What is 3 + 6?")
7492
await session.disconnect()
7593

94+
await _wait_for_session_lock_release(ctx, session_id)
95+
7696
# Resume using a new client
7797
github_token = (
7898
"fake-token-for-e2e-tests" if os.environ.get("GITHUB_ACTIONS") == "true" else None
@@ -86,7 +106,7 @@ async def test_should_produce_deltas_after_session_resume(self, ctx: E2ETestCont
86106

87107
try:
88108
session2 = await new_client.resume_session(
89-
session.session_id,
109+
session_id,
90110
on_permission_request=PermissionHandler.approve_all,
91111
streaming=True,
92112
)
@@ -126,6 +146,8 @@ async def test_should_not_produce_deltas_after_session_resume_with_streaming_dis
126146
session_id = session.session_id
127147
await session.disconnect()
128148

149+
await _wait_for_session_lock_release(ctx, session_id)
150+
129151
# Resume with streaming disabled
130152
new_client = CopilotClient(
131153
connection=RuntimeConnection.for_stdio(path=ctx.cli_path),

0 commit comments

Comments
 (0)