Skip to content

Conversation

@LiamSarsfield
Copy link
Contributor

@LiamSarsfield LiamSarsfield commented Dec 12, 2025

Addresses HOG-438: Create Jetpack Performance Tooling for LCP

Proposed changes:

  • Add performance testing infrastructure under tools/performance/ to measure wp-admin dashboard LCP (Largest
    Contentful Paint) with Jetpack connected
  • Uses Docker for isolated WordPress environment with simulated WordPress.com connection (fake tokens + mocked API
    with 200ms latency)
  • Includes CPU throttling calibration for consistent results across different machines
  • Posts metrics to CodeVitals for tracking over time

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with
    a script to run)?

Jetpack product discussion

pc9hqz-3Rb-p2

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Prerequisites: Docker running, Node 18+, Jetpack built (pnpm jetpack build plugins/jetpack)

cd tools/performance
pnpm install
pnpm exec playwright install chromium
pnpm calibrate
pnpm test --skip-codevitals

Expected output: LCP measurement for wp-admin dashboard with Jetpack connected (simulated)

Introduces automated LCP (Largest Contentful Paint) measurement for the
wp-admin dashboard with simulated Jetpack WordPress.com connection.

Key components:
- Docker environment with WordPress + simulated Jetpack connection
- CPU throttling calibration for consistent results across CI agents
- Playwright-based LCP measurement
- CodeVitals integration for metric tracking

Metric posted: wp-admin-dashboard-connection-sim-largestContentfulPaint
@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Dec 12, 2025
- Remove outdated 4-scenario comment (only 1 scenario exists)
- Remove dead baseline comparison code that never executed
- Trim JSDoc to single-line descriptions across all scripts
- Update eslint config to allow minimal JSDoc
@LiamSarsfield LiamSarsfield changed the title Add Jetpack performance testing CI infrastructure [Do not merge] Add Jetpack performance testing CI infrastructure Dec 12, 2025
@LiamSarsfield LiamSarsfield added the DO NOT MERGE don't merge it! label Dec 12, 2025
Changed the Docker startup sequence to prevent race conditions where
WordPress containers interfere with WP-CLI's database operations:

1. Start only the db container
2. Wait for MySQL to be ready
3. Run WP-CLI setup (WordPress container NOT running)
4. Start WordPress containers

This ensures WP-CLI has exclusive database access during setup,
eliminating "table doesn't exist" errors caused by concurrent access.

Changes:
- run-performance-tests.js: Sequential container startup
- setup-wordpress.sh: Simplified (removed HTTP wait logic)
- docker-compose.yml: Removed wpcli depends_on wordpress
The import plugin is not available in this context, and the base config
handles import resolution. Also ensure jsdoc rules are disabled for
these utility scripts.
Dependencies (playwright, dotenv) are in tools/performance/package.json,
not the monorepo root, so the import resolver can't find them.
- Log calibration file path and existence
- Show throttle rate, target score, calibration time, and samples
- Confirm throttling is applied via CDP on first iteration
@github-actions
Copy link
Contributor

github-actions bot commented Dec 14, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/perf-testing-ci-mvp branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/perf-testing-ci-mvp
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/perf-testing-ci-mvp

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@jp-launch-control
Copy link

jp-launch-control bot commented Dec 14, 2025

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

…wordpress-jetpack-connected service, ensuring it starts only after the service is initiated, which helps prevent race conditions during container startup.
- Updated README.md to include new environment variables: CODEVITALS_URL, GIT_BRANCH, WP_ADMIN_USER, and WP_ADMIN_PASS.
- Modified post-to-codevitals.js to streamline metric extraction by removing unused baseMetrics.
- Improved run-performance-tests.js to prioritize GIT_COMMIT environment variable for git hash retrieval, ensuring accurate tracking during CI runs.
- Introduced an empty baseMetrics object in the payload to clarify that baseline normalization is not utilized in the performance metrics submission.
- Simplified browser launch to always use headless mode for consistency in performance calibration.
- Removed conditional logic for headful mode, ensuring a streamlined execution in both local and CI environments.
@LiamSarsfield LiamSarsfield added [Type] Infrastructure and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Dec 15, 2025
@LiamSarsfield
Copy link
Contributor Author

Hey @anomiex👋 would you mind taking a look at this when you get a chance?

This is the performance testing infrastructure I built during HACK week (more details here pc9hqz-3Rb-p2) it measures wp-admin dashboard LCP for Jetpack and posts results to CodeVitals.
It's a big PR, sorry about that. Most of it breaks down into:

  • scripts/ - Node.js orchestration and Playwright measurement code
  • docker/ - Docker Compose setup for WordPress + Jetpack environment
  • docker/mu-plugins/simulate-wpcom-connection.php - mu-plugin that fakes Jetpack connection and mocks WP.com API
    responses

The mu-plugin is probably the most relevant bit for review from a Jetpack perspective as it intercepts pre_http_request to return mock responses for various WP.com endpoints.

Happy to walk through any of it if that's easier.

@LiamSarsfield LiamSarsfield marked this pull request as ready for review December 15, 2025 13:46
@LiamSarsfield LiamSarsfield removed the DO NOT MERGE don't merge it! label Dec 15, 2025
@LiamSarsfield LiamSarsfield changed the title [Do not merge] Add Jetpack performance testing CI infrastructure Add Jetpack performance testing CI infrastructure Dec 15, 2025
@LiamSarsfield LiamSarsfield added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Dec 15, 2025
Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

Seems ok from a monorepo perspective. I didn't look too closely at the code.

If you're wanting a review of the faked-connection stuff in the mu-plugin, @Automattic/jetpack-vulcan would be the team to ask.


## CI Usage

The test suite is designed to run in TeamCity. See build configuration for setup.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it'd make more sense to run it in Actions rather than TeamCity, on each commit to trunk instead of backfilling weekly.

If you're running it in TeamCity, are you looking at the monorepo, or at https://github.com/Automattic/jetpack-production which has the already-built plugin?

Comment on lines +20 to +22
// Dependencies are in tools/performance/package.json, not monorepo root
// so the import resolver can't find them. Disable this rule.
'import/no-unresolved': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't matter, eslint will look in tools/performance/node_modules for files under here.

Also, when I remove this and run eslint, it doesn't seem to complain about anything.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants