Skip to content

test(playwright): run MCP Chat AUT describe serially to avoid shared-app race#29169

Open
pmbrull wants to merge 2 commits into
mainfrom
pmbrull/fix-mcp-chat-aut-parallel-race
Open

test(playwright): run MCP Chat AUT describe serially to avoid shared-app race#29169
pmbrull wants to merge 2 commits into
mainfrom
pmbrull/fix-mcp-chat-aut-parallel-race

Conversation

@pmbrull

@pmbrull pmbrull commented Jun 18, 2026

Copy link
Copy Markdown
Member

Problem

The MCP Chat - Sidebar Navigation Playwright spec (McpChat.spec.ts, added in #26343) fails deterministically in the nightly AUT runs. Two of its three tests fail every night:

  • MCP Chat nav item should appear in sidebar when app is installedexpect(getByTestId('app-bar-item-mcp-chat')).toBeVisible()element(s) not found
  • Clicking MCP Chat sidebar nav should navigate to chat page → 60s timeout waiting for the same sidebar item

The third test, Send button should enable when input has text, passes — it reaches the page via a direct page.goto('/mcp-chat') and does not depend on the sidebar item.

Root cause

The describe shares one globally-named installed app (McpChatApplication): installed in beforeAll, hard-deleted in afterAll. The project runs with fullyParallel: true (workers: 3), so:

  • The describe's tests are split across workers, and beforeAll/afterAll run once per worker.
  • The fast direct-navigation test finishes first (~4.5s); its worker's afterAll then DELETE …?hardDelete=true removes the shared app.
  • The slower sidebar-dependent tests are still running in other workers. Once the app is deleted, GET /api/v1/apps/installed no longer returns it, the UI's ApplicationsProvider builds no McpChatPlugin, and the app-bar-item-mcp-chat sidebar entry never renders.

It is deterministic (not flaky) because the direct-navigation test is always the quickest to reach its afterAll. The /mcp-chat route is registered unconditionally, which is why that test still passes.

Fix

Force the describe to run serially in a single worker:

test.describe.configure({ mode: 'serial' });

beforeAll/afterAll then run exactly once and afterAll only fires after all three tests complete, so the shared app stays installed for the whole describe. No production code change — test isolation only.

🤖 Generated with Claude Code

Greptile Summary

Fixes a deterministic nightly AUT failure in the MCP Chat - Sidebar Navigation spec by configuring the describe block to run in serial mode, preventing worker-level race conditions around the shared McpChatApplication install/teardown lifecycle.

  • Root cause fixed: Under fullyParallel: true, each worker ran its own beforeAll/afterAll — the fastest test's afterAll hard-deleted the app while slower sibling tests were still asserting the sidebar item.
  • Fix: One line — test.describe.configure({ mode: 'serial' }) — ensures beforeAll/afterAll fire exactly once and afterAll only runs after all three tests finish. No production code is touched.

Confidence Score: 5/5

Safe to merge — one-line test configuration change with no production code impact.

The change is a single test.describe.configure({ mode: 'serial' }) call that corrects a well-documented, deterministic race condition in the test suite. It does not touch any application code, only test isolation semantics. The comment accurately describes the problem, and the fix is the standard Playwright-recommended approach for describes that share global state through beforeAll/afterAll.

No files require special attention.

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/McpChat.spec.ts Adds test.describe.configure({ mode: 'serial' }) to prevent worker-level race conditions where the fast direct-navigation test's afterAll hard-deleted the shared app while sibling tests were still asserting the sidebar item.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant W1 as Worker 1
    participant W2 as Worker 2
    participant W3 as Worker 3
    participant API as OpenMetadata API

    Note over W1,W3: BEFORE (fullyParallel, no serial mode)

    W1->>API: beforeAll: POST /api/v1/apps (install McpChatApplication)
    W2->>API: beforeAll: POST /api/v1/apps (409 already installed)
    W3->>API: beforeAll: POST /api/v1/apps (409 already installed)

    W3->>W3: Test: Send button enables (page.goto, fast ~4.5s)
    W3->>API: "afterAll: DELETE McpChatApplication?hardDelete=true"

    Note over W1,W2: App deleted — sidebar item disappears
    W1--xW1: FAIL: app-bar-item-mcp-chat not found
    W2--xW2: FAIL: 60s timeout waiting for sidebar item

    Note over W1,W3: AFTER (test.describe.configure serial mode)

    W1->>API: beforeAll: POST /api/v1/apps (runs once)
    W1->>W1: Test 1: MCP Chat nav item appears in sidebar
    W1->>W1: Test 2: Clicking nav navigates to chat page
    W1->>W1: Test 3: Send button enables with text
    W1->>API: "afterAll: DELETE McpChatApplication?hardDelete=true"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant W1 as Worker 1
    participant W2 as Worker 2
    participant W3 as Worker 3
    participant API as OpenMetadata API

    Note over W1,W3: BEFORE (fullyParallel, no serial mode)

    W1->>API: beforeAll: POST /api/v1/apps (install McpChatApplication)
    W2->>API: beforeAll: POST /api/v1/apps (409 already installed)
    W3->>API: beforeAll: POST /api/v1/apps (409 already installed)

    W3->>W3: Test: Send button enables (page.goto, fast ~4.5s)
    W3->>API: "afterAll: DELETE McpChatApplication?hardDelete=true"

    Note over W1,W2: App deleted — sidebar item disappears
    W1--xW1: FAIL: app-bar-item-mcp-chat not found
    W2--xW2: FAIL: 60s timeout waiting for sidebar item

    Note over W1,W3: AFTER (test.describe.configure serial mode)

    W1->>API: beforeAll: POST /api/v1/apps (runs once)
    W1->>W1: Test 1: MCP Chat nav item appears in sidebar
    W1->>W1: Test 2: Clicking nav navigates to chat page
    W1->>W1: Test 3: Send button enables with text
    W1->>API: "afterAll: DELETE McpChatApplication?hardDelete=true"
Loading

Reviews (2): Last reviewed commit: "Merge branch 'main' into pmbrull/fix-mcp..." | Re-trigger Greptile

…app race

The MCP Chat sidebar-navigation tests share one globally-named installed
app (McpChatApplication) created in beforeAll and hard-deleted in
afterAll. The project runs `fullyParallel`, so the describe's tests are
split across workers and beforeAll/afterAll execute per worker. The fast
direct-navigation test finishes first and its afterAll hardDeletes the
app while the slower sidebar-dependent tests are still polling for
`app-bar-item-mcp-chat`, so the item never renders and they time out.

Force serial execution so the shared app stays installed for the whole
describe.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pmbrull pmbrull requested a review from a team as a code owner June 18, 2026 09:01
Copilot AI review requested due to automatic review settings June 18, 2026 09:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 62%
62.28% (66607/106947) 44.04% (37261/84607) 45.38% (11189/24653)

@gitar-bot

gitar-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Forces Playwright MCP Chat tests to run serially to prevent worker-level race conditions from deleting the shared application prematurely. The spec now maintains the required app state throughout the test suite.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants