Skip to content

Commit 7d6bc92

Browse files
stephentoubCopilot
andauthored
Fix flaky SessionFs workspace metadata E2E test (#1599)
The Should_Write_Workspace_Metadata_Via_SessionFs test waited only for workspace.yaml to exist before reading it, but the runtime creates the file (truncating to 0 bytes) before the content write completes. This let the test read an empty file and fail the session-id assertion. Wait for the expected content (not just existence) before asserting in both the .NET workspace.yaml and plan.md tests, and drop the now-redundant trailing asserts. Apply the same content-aware wait to the Python suite via its existing wait_for_content helper. Go already waits for content and Node uses an in-memory provider with atomic writes, so neither was affected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7de72a6 commit 7d6bc92

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

dotnet/test/E2E/SessionFsE2ETests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,10 @@ public async Task Should_Write_Workspace_Metadata_Via_SessionFs()
410410
Assert.Contains("56", msg?.Data.Content ?? string.Empty);
411411

412412
var workspaceYamlPath = GetStoredPath(providerRoot, session.SessionId, $"{SessionFsConfig.SessionStatePath}/workspace.yaml");
413-
await WaitForConditionAsync(() => File.Exists(workspaceYamlPath), TimeSpan.FromSeconds(30));
414-
Assert.Contains(session.SessionId, await ReadAllTextSharedAsync(workspaceYamlPath));
413+
await WaitForConditionAsync(
414+
async () => File.Exists(workspaceYamlPath)
415+
&& (await ReadAllTextSharedAsync(workspaceYamlPath)).Contains(session.SessionId),
416+
TimeSpan.FromSeconds(30));
415417

416418
var indexPath = GetStoredPath(providerRoot, session.SessionId, $"{SessionFsConfig.SessionStatePath}/checkpoints/index.md");
417419
await WaitForConditionAsync(() => File.Exists(indexPath), TimeSpan.FromSeconds(30));
@@ -442,8 +444,10 @@ public async Task Should_Persist_Plan_Md_Via_SessionFs()
442444
await session.Rpc.Plan.UpdateAsync("# Test Plan\n\nThis is a test.");
443445

444446
var planPath = GetStoredPath(providerRoot, session.SessionId, $"{SessionFsConfig.SessionStatePath}/plan.md");
445-
await WaitForConditionAsync(() => File.Exists(planPath), TimeSpan.FromSeconds(30));
446-
Assert.Contains("This is a test.", await ReadAllTextSharedAsync(planPath));
447+
await WaitForConditionAsync(
448+
async () => File.Exists(planPath)
449+
&& (await ReadAllTextSharedAsync(planPath)).Contains("This is a test."),
450+
TimeSpan.FromSeconds(30));
447451

448452
await session.DisposeAsync();
449453
}

python/e2e/test_session_fs_e2e.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ async def test_should_write_workspace_metadata_via_sessionfs(
235235
workspace_yaml_path = provider_path(
236236
provider_root, session.session_id, f"{SESSION_STATE_PATH}/workspace.yaml"
237237
)
238-
await wait_for_path(workspace_yaml_path)
239-
yaml_content = workspace_yaml_path.read_text(encoding="utf-8")
240-
assert "id:" in yaml_content
238+
await wait_for_content(workspace_yaml_path, "id:")
241239

242240
# Checkpoint index should also exist
243241
index_path = provider_path(
@@ -265,9 +263,7 @@ async def test_should_persist_plan_md_via_sessionfs(
265263
plan_path = provider_path(
266264
provider_root, session.session_id, f"{SESSION_STATE_PATH}/plan.md"
267265
)
268-
await wait_for_path(plan_path)
269-
content = plan_path.read_text(encoding="utf-8")
270-
assert "# Test Plan" in content
266+
await wait_for_content(plan_path, "# Test Plan")
271267

272268
await session.disconnect()
273269

0 commit comments

Comments
 (0)