Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

ci(ui-tests): shard Puppeteer tests into 4 parallel matrix cells (#3512)

LearningCircuit079d4627530c
diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index c459b516fc..a88eba36bb 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -458,15 +458,25 @@ jobs:
fi
# Run UI tests with Puppeteer
+ #
+ # Runs as a 4-way matrix (one cell per shard). Each cell spins up its own
+ # docker container and runs only the tests tagged with its shard in
+ # tests/ui_tests/run_all_tests.js. Fresh per-cell DB bounds state leakage
+ # across tests (see #5165 flake analysis).
+ #
+ # Trigger: only in the release pipeline (workflow_call with strict-mode=true).
+ # Skipped on every PR and push for fast developer feedback. The release gate
+ # is where UI regressions actually get caught and fixed.
ui-tests:
runs-on: ubuntu-latest
- name: UI Tests (Puppeteer)
+ name: UI Tests (Puppeteer) [${{ matrix.shard }}]
needs: build-test-image
- # Advisory: skip in release pipeline — Puppeteer-in-Docker is too flaky to gate releases.
- # UI tests still run on every PR and push for visibility.
- # To make UI tests mandatory for releases again, remove the next line:
- if: ${{ inputs.strict-mode != true }}
- timeout-minutes: 120
+ if: ${{ inputs.strict-mode == true }}
+ timeout-minutes: 40
+ strategy:
+ matrix:
+ shard: [auth-core, research, settings-library, misc-mobile]
+ fail-fast: false
permissions:
contents: read
@@ -575,23 +585,23 @@ jobs:
--network host \
-w /app/tests/ui_tests \
${{ env.TEST_IMAGE }} \
- sh -c "xvfb-run -a -s '-screen 0 1920x1080x24' node run_all_tests.js"
+ sh -c "xvfb-run -a -s '-screen 0 1920x1080x24' node run_all_tests.js --shard=${{ matrix.shard }}"
- name: Capture server logs on failure
if: failure()
run: |
mkdir -p /tmp/ldr-ci-logs
- docker logs ldr-server > /tmp/ldr-ci-logs/server.log 2>&1 || true
+ docker logs ldr-server > "/tmp/ldr-ci-logs/server-${{ matrix.shard }}.log" 2>&1 || true
{
- echo "## 🪵 ldr-server logs (last 200 lines)"
+ echo "## 🪵 ldr-server logs [${{ matrix.shard }}] (last 200 lines)"
echo ""
echo '```'
- tail -n 200 /tmp/ldr-ci-logs/server.log || true
+ tail -n 200 "/tmp/ldr-ci-logs/server-${{ matrix.shard }}.log" || true
echo '```'
echo ""
echo "Grepping for SQLAlchemy pool / DB session issues:"
echo '```'
- grep -E "QueuePool|connection timed out|TimeoutError|cleanup_dead_threads|Failed to open database|DatabaseSessionError" /tmp/ldr-ci-logs/server.log | tail -n 50 || true
+ grep -E "QueuePool|connection timed out|TimeoutError|cleanup_dead_threads|Failed to open database|DatabaseSessionError" "/tmp/ldr-ci-logs/server-${{ matrix.shard }}.log" | tail -n 50 || true
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
@@ -605,7 +615,7 @@ jobs:
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
- name: ui-test-screenshots
+ name: ui-test-screenshots-${{ matrix.shard }}
path: |
tests/screenshots/
tests/ui_tests/screenshots/
@@ -614,11 +624,37 @@ jobs:
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
- name: ui-tests-server-log
- path: /tmp/ldr-ci-logs/server.log
+ name: ui-tests-server-log-${{ matrix.shard }}
+ path: /tmp/ldr-ci-logs/server-${{ matrix.shard }}.log
retention-days: 3
if-no-files-found: ignore
+ # Aggregates matrix-cell results into a single stable check name.
+ # ci-gate.yml and any branch-protection rule should depend on this job's
+ # name ("UI Tests (Puppeteer)"), not on individual shard cells.
+ ui-tests-summary:
+ runs-on: ubuntu-latest
+ name: UI Tests (Puppeteer)
+ needs: ui-tests
+ if: ${{ always() && inputs.strict-mode == true }}
+ permissions:
+ contents: read
+ steps:
+ - name: Harden the runner (Audit all outbound calls)
+ uses: step-security/harden-runner@f808768d1510423e83855289c910610ca9b43176 # v2.17.0
+ with:
+ egress-policy: audit
+
+ - name: Check all shards succeeded
+ run: |
+ result="${{ needs.ui-tests.result }}"
+ echo "Aggregated matrix result: $result"
+ if [ "$result" != "success" ]; then
+ echo "::error::One or more UI test shards did not succeed (result=$result)."
+ exit 1
+ fi
+ echo "All UI test shards passed."
+
# Run accessibility tests (Playwright a11y + Lighthouse)
accessibility-tests:
runs-on: ubuntu-latest
diff --git a/tests/ui_tests/README.md b/tests/ui_tests/README.md
index 12592dc5f7..97102ff9c0 100644
--- a/tests/ui_tests/README.md
+++ b/tests/ui_tests/README.md
@@ -17,6 +17,23 @@ cd /path/to/local-deep-research
node tests/ui_tests/run_all_tests.js
```
+### Run a Single Shard
+
+Tests are partitioned into four shards so CI can run them in parallel matrix
+cells. Each entry in `run_all_tests.js` carries a `shard:` property. Local dev
+rarely needs this, but you can reproduce a CI cell with:
+
+```bash
+node tests/ui_tests/run_all_tests.js --shard=auth-core
+node tests/ui_tests/run_all_tests.js --shard=research
+node tests/ui_tests/run_all_tests.js --shard=settings-library
+node tests/ui_tests/run_all_tests.js --shard=misc-mobile
+```
+
+Passing an unknown shard, or leaving `--shard` off while `CI=true` is set,
+fails fast with an error — this catches matrix misconfiguration before a cell
+wastes compute running the wrong slice.
+
### Run All Page Tests
```bash
cd /path/to/local-deep-research
diff --git a/tests/ui_tests/run_all_tests.js b/tests/ui_tests/run_all_tests.js
index 6af3f706e0..2811195ebc 100644
--- a/tests/ui_tests/run_all_tests.js
+++ b/tests/ui_tests/run_all_tests.js
@@ -6,9 +6,22 @@
*
* Prerequisites: Web server running on http://127.0.0.1:5000
*
- * Usage: node tests/ui_tests/run_all_tests.js
+ * Usage:
+ * node tests/ui_tests/run_all_tests.js # run all tests
+ * node tests/ui_tests/run_all_tests.js --shard=auth-core # run one shard
+ *
+ * Valid shards: auth-core, research, settings-library, misc-mobile
*/
+// Keep in sync with `strategy.matrix.shard` in .github/workflows/docker-tests.yml.
+// A mismatch would cause silent test misrouting.
+const VALID_SHARDS = ['auth-core', 'research', 'settings-library', 'misc-mobile'];
+
+// TODO(rebalance): initial shard allocation is a best-effort estimate. After
+// the first release run, grep logs for `TIMING:` to get ground-truth per-test
+// durations and reassign tests so each shard's wall time is within ~25% of
+// the mean.
+
const { spawn } = require('child_process');
const http = require('http');
const path = require('path');
@@ -57,56 +70,67 @@ const tests = [
{
name: 'Authentication Flow Test',
file: 'test_auth_flow.js',
+ shard: 'auth-core',
description: 'Tests registration, login, and logout functionality'
},
{
name: 'All Pages Browser Test',
file: 'test_pages_browser.js',
+ shard: 'auth-core',
description: 'Tests all main pages for basic functionality'
},
{
name: 'Error Recovery Test',
file: 'test_error_recovery.js',
+ shard: 'misc-mobile',
description: 'Tests how the UI handles various error conditions gracefully'
},
{
name: 'Research Workflow Test',
file: 'test_research_workflow.js',
+ shard: 'research',
description: 'Tests the complete research lifecycle from submission to results'
},
{
name: 'Metrics Charts Test',
file: 'test_metrics_charts.js',
+ shard: 'research',
description: 'Tests Chart.js rendering for token and search charts'
},
{
name: 'Research Results Test',
file: 'test_research_results.js',
+ shard: 'research',
description: 'Tests error handling for non-existent research and history page structure'
},
{
name: 'Settings Page Test',
file: 'test_settings_page.js',
+ shard: 'settings-library',
description: 'Tests settings page loading and API integration'
},
{
name: 'Settings Error Detection Test',
file: 'test_settings_errors.js',
+ shard: 'settings-library',
description: 'Tests error handling when changing settings'
},
{
name: 'Settings Save Test',
file: 'test_settings_save.js',
+ shard: 'settings-library',
description: 'Tests settings save workflow and validation'
},
{
name: 'Star Reviews Test',
file: 'test_star_reviews.js',
+ shard: 'settings-library',
description: 'Tests star reviews analytics page and visualizations'
},
{
name: 'Rate Limiting Functionality Test',
file: 'test_rate_limiting_settings.js',
+ shard: 'misc-mobile',
description: 'Tests rate limiting works on auth endpoints and static files are exempt'
},
@@ -114,76 +138,91 @@ const tests = [
{
name: 'UI Functionality CI Tests',
file: 'mobile/test_ui_functionality_ci.js',
+ shard: 'misc-mobile',
description: 'Tests forms, dropdowns, modals, navigation, buttons'
},
{
name: 'Research Workflow CI Tests',
file: 'test_research_workflow_ci.js',
+ shard: 'research',
description: 'Tests research form, progress page, results, exports'
},
{
name: 'Settings Pages CI Tests',
file: 'test_settings_pages_ci.js',
+ shard: 'settings-library',
description: 'Tests settings tabs, navigation, provider/engine settings'
},
{
name: 'Library Collections CI Tests',
file: 'test_library_collections_ci.js',
+ shard: 'settings-library',
description: 'Tests library page, collections, document details'
},
{
name: 'News Subscriptions CI Tests',
file: 'test_news_subscriptions_ci.js',
+ shard: 'settings-library',
description: 'Tests news feeds, subscription CRUD, form validation'
},
{
name: 'History Page CI Tests',
file: 'test_history_page_ci.js',
+ shard: 'settings-library',
description: 'Tests history table, actions, search/filter'
},
{
name: 'Metrics Dashboard CI Tests',
file: 'test_metrics_dashboard_ci.js',
+ shard: 'research',
description: 'Tests metrics dashboard, cost analytics, star reviews, links'
},
{
name: 'Benchmark CI Tests',
file: 'test_benchmark_ci.js',
+ shard: 'misc-mobile',
description: 'Tests benchmark dashboard and results pages'
},
{
name: 'API Endpoints CI Tests',
file: 'test_api_endpoints_ci.js',
+ shard: 'misc-mobile',
description: 'Tests all major API endpoints'
},
{
name: 'CRUD Operations CI Tests',
file: 'test_crud_operations_ci.js',
+ shard: 'settings-library',
description: 'Tests collections, subscriptions, documents CRUD'
},
{
name: 'Realtime Progress CI Tests',
file: 'test_realtime_progress_ci.js',
+ shard: 'research',
description: 'Tests progress page and real-time elements'
},
{
name: 'Error Handling CI Tests',
file: 'test_error_handling_ci.js',
+ shard: 'misc-mobile',
description: 'Tests 404, 401, 429, validation errors'
},
{
name: 'Mobile Interactions CI Tests',
file: 'test_mobile_interactions_ci.js',
+ shard: 'misc-mobile',
description: 'Tests mobile modals, navigation, forms'
},
{
name: 'Context Overflow CI Tests',
file: 'test_context_overflow_ci.js',
+ shard: 'misc-mobile',
description: 'Tests context overflow analytics page'
},
{
name: 'Follow-up Research CI Tests',
file: 'test_followup_research_ci.js',
+ shard: 'research',
description: 'Tests follow-up research flow'
},
@@ -191,42 +230,50 @@ const tests = [
{
name: 'Auth Comprehensive CI Tests',
file: 'test_auth_comprehensive_ci.js',
+ shard: 'auth-core',
description: 'Tests password strength, form validation, remember me, sessions'
},
{
name: 'Research Form CI Tests',
file: 'test_research_form_ci.js',
+ shard: 'research',
description: 'Tests advanced options, mode toggle, dropdowns, validation'
},
{
name: 'Results & Exports CI Tests',
file: 'test_results_exports_ci.js',
+ shard: 'research',
description: 'Tests star ratings, export buttons, download functionality'
},
{
name: 'Library Documents CI Tests',
file: 'test_library_documents_ci.js',
+ shard: 'settings-library',
description: 'Tests filters, views, PDF/text viewers, bulk actions'
},
{
name: 'News Feed CI Tests',
file: 'test_news_feed_ci.js',
+ shard: 'settings-library',
description: 'Tests feed, filters, templates, subscription management',
skipCI: true, // Intermittent 60s navigation timeouts; core coverage in test_news_subscriptions_ci.js
},
{
name: 'Settings Interactions CI Tests',
file: 'test_settings_interactions_ci.js',
+ shard: 'settings-library',
description: 'Tests tabs, search, toggles, save, raw config'
},
{
name: 'Keyboard & Accessibility CI Tests',
file: 'test_keyboard_accessibility_ci.js',
+ shard: 'misc-mobile',
description: 'Tests keyboard navigation, shortcuts, ARIA, focus management'
},
{
name: 'Loading & Feedback CI Tests',
file: 'test_loading_feedback_ci.js',
+ shard: 'misc-mobile',
description: 'Tests spinners, toasts, progress bars, hover states'
},
@@ -234,27 +281,32 @@ const tests = [
{
name: 'Register Validation Test',
file: 'test_register_validation.js',
+ shard: 'auth-core',
description: 'Tests registration form validation without auth'
},
{
name: 'Login Validation Test',
file: 'test_login_validation.js',
+ shard: 'auth-core',
description: 'Tests login form validation'
},
{
name: 'Research Submit Test',
file: 'test_research_submit.js',
+ shard: 'research',
description: 'Tests research submission'
},
{
name: 'Export Functionality Test',
file: 'test_export_functionality.js',
+ shard: 'research',
description: 'Tests export features',
skipCI: true, // Auth hangs with "Navigating frame was detached" in Docker
},
{
name: 'Concurrent Limit Test',
file: 'test_concurrent_limit.js',
+ shard: 'research',
description: 'Tests concurrent research limits',
skipCI: true, // Requires LLM backend — always fails without model server
},
@@ -270,52 +322,61 @@ const tests = [
{
name: 'Settings Validation Test',
file: 'test_settings_validation.js',
+ shard: 'settings-library',
description: 'Tests settings input validation',
skipCI: true, // Same frame-detachment issue as Export test in Docker
},
{
name: 'Research Form Validation Test',
file: 'test_research_form_validation.js',
+ shard: 'research',
description: 'Tests research form field validation',
skipCI: true, // Redundant with test_research_form_ci.js; auth frame-detachment in Docker
},
{
name: 'Form Validation ARIA Tests',
file: 'test_form_validation_aria_ci.js',
+ shard: 'research',
description: 'Tests inline form validation with ARIA support',
skipCI: true, // Auth frame-detachment in Docker causes intermittent 120s timeout
},
{
name: 'Research Simple Test',
file: 'test_research_simple.js',
+ shard: 'research',
description: 'Tests basic research flow',
skipCI: true, // Requires LLM backend to complete research submission
},
{
name: 'Research Form Test',
file: 'test_research_form.js',
+ shard: 'research',
description: 'Tests research form interactions',
skipCI: true, // Diagnostic test — requires LLM for form submission
},
{
name: 'Research API Test',
file: 'test_research_api.js',
+ shard: 'research',
description: 'Tests research API endpoints via UI',
skipCI: true, // Diagnostic test — requires functioning LLM API
},
{
name: 'History Page Test',
file: 'test_history_page.js',
+ shard: 'settings-library',
description: 'Tests history page functionality'
},
{
name: 'Full Navigation Test',
file: 'test_full_navigation.js',
+ shard: 'auth-core',
description: 'Tests full app navigation flow'
},
{
name: 'Queue Simple Test',
file: 'test_queue_simple.js',
+ shard: 'research',
description: 'Tests research queue functionality',
skipCI: true, // Requires LLM backend — always fails without model server
},
@@ -324,6 +385,7 @@ const tests = [
{
name: 'Mobile Navigation CI Test',
file: 'mobile/test_mobile_navigation_ci.js',
+ shard: 'misc-mobile',
description: 'Tests mobile navigation patterns'
},
@@ -331,16 +393,19 @@ const tests = [
{
name: 'Library Collections Page Test',
file: 'library/test_collections_page.js',
+ shard: 'settings-library',
description: 'Tests library collections page'
},
- // Register Full Flow runs last because it creates an encrypted SQLCipher
- // database (CPU-intensive key derivation + 58 tables + 500+ settings) which
- // can block the single-threaded CI server for 2+ minutes, causing cascade
- // failures in any tests that follow.
+ // Register Full Flow runs last in misc-mobile because it creates an encrypted
+ // SQLCipher database (CPU-intensive key derivation + 58 tables + 500+ settings)
+ // which can block the single-threaded CI server for 2+ minutes, causing cascade
+ // failures in any tests that follow. Placing it last in its shard limits the
+ // blast radius.
{
name: 'Register Full Flow Test',
file: 'test_register_full_flow.js',
+ shard: 'misc-mobile',
description: 'Tests complete registration flow'
}
];
@@ -382,6 +447,8 @@ async function runTest(test) {
const elapsed = Math.round((Date.now() - startTime) / 1000);
const success = code === 0;
console.log(`[${ts()}] ${success ? '✅' : '❌'} ${test.name}: ${success ? 'PASSED' : 'FAILED'} (${elapsed}s)`);
+ // Grep-friendly line for post-run duration analysis (used to rebalance shards).
+ console.log(`TIMING: ${test.name}: ${elapsed}`);
if (code !== 0 && code !== null) {
console.log(` Exit code: ${code}`);
}
@@ -407,18 +474,62 @@ async function runTest(test) {
});
}
+function parseShardArg() {
+ const shardArg = process.argv.find(arg => arg.startsWith('--shard='));
+ return shardArg ? shardArg.split('=')[1] : null;
+}
+
+function validateBeforeRun(requestedShard, isCI) {
+ // Every test must declare a shard so filtering can't silently skip it.
+ const untagged = tests.filter(t => !t.shard);
+ if (untagged.length > 0) {
+ console.error('FATAL: the following tests are missing a `shard:` property:');
+ untagged.forEach(t => console.error(` - ${t.name} (${t.file})`));
+ console.error(`Valid shards: ${VALID_SHARDS.join(', ')}`);
+ process.exit(1);
+ }
+
+ if (requestedShard && !VALID_SHARDS.includes(requestedShard)) {
+ console.error(`FATAL: unknown shard "${requestedShard}".`);
+ console.error(`Valid shards: ${VALID_SHARDS.join(', ')}`);
+ process.exit(1);
+ }
+
+ // Matrix misconfiguration guard: if CI forgot to pass --shard, every
+ // matrix cell would otherwise run the full suite. Fail loud.
+ if (isCI && !requestedShard) {
+ console.error('FATAL: CI=true but no --shard flag provided.');
+ console.error('Matrix is misconfigured — each cell must pass --shard=<name>.');
+ console.error(`Valid shards: ${VALID_SHARDS.join(', ')}`);
+ process.exit(1);
+ }
+}
+
async function runAllTests() {
const suiteStart = new Date();
- console.log(`[${ts(suiteStart)}] Starting UI Test Suite\n`);
+ const isCI = !!process.env.CI;
+ const requestedShard = parseShardArg();
- const results = [];
+ validateBeforeRun(requestedShard, isCI);
- const isCI = !!process.env.CI;
+ const shardLabel = requestedShard ? ` [shard: ${requestedShard}]` : '';
+ console.log(`[${ts(suiteStart)}] Starting UI Test Suite${shardLabel}\n`);
+
+ const results = [];
for (const test of tests) {
+ // skipCI takes priority: a test marked skipCI stays skipped in CI even
+ // if its shard matches. Keeps existing skip semantics intact.
if (test.skipCI && isCI) {
- console.log(`\n[${ts()}] ⏭️ Skipping: ${test.name} (not supported in CI Docker)`);
- results.push({ name: test.name, success: true, duration: 0, skipped: true });
+ // Only log the skip when this shard would have run the test.
+ if (!requestedShard || test.shard === requestedShard) {
+ console.log(`\n[${ts()}] ⏭️ Skipping: ${test.name} (not supported in CI Docker)`);
+ results.push({ name: test.name, success: true, duration: 0, skipped: true });
+ }
+ continue;
+ }
+ // Shard filter: silently drop tests that don't belong to the requested shard.
+ if (requestedShard && test.shard !== requestedShard) {
continue;
}
// Ensure server is responsive before starting each test.
@@ -448,7 +559,9 @@ async function runAllTests() {
}
});
- console.log(`Total: ${results.length} | Passed: ${passed} | Failed: ${failed} | Duration: ${totalDuration}s | Wall: ${wallTime}s | Rate: ${Math.round((passed / results.length) * 100)}%`);
+ const shardSuffix = requestedShard ? ` [shard: ${requestedShard}]` : '';
+ const rate = results.length === 0 ? 0 : Math.round((passed / results.length) * 100);
+ console.log(`Total: ${results.length} | Passed: ${passed} | Failed: ${failed} | Duration: ${totalDuration}s | Wall: ${wallTime}s | Rate: ${rate}%${shardSuffix}`);
if (failed === 0) {
console.log('All tests passed!');