-
Notifications
You must be signed in to change notification settings - Fork 858
Add Jetpack performance testing CI infrastructure #46287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2aec229
Add Jetpack performance testing CI infrastructure
LiamSarsfield a2d8577
Trim verbose JSDoc and remove dead code from performance scripts
LiamSarsfield e0b91db
Fix eslint import/no-unresolved for standalone dependencies
LiamSarsfield 6e1f661
Fix race condition with sequential container startup
LiamSarsfield f9dfbd5
Fix ESLint config: remove import/no-unresolved rule
LiamSarsfield 63dca30
Disable import/no-unresolved rule for performance scripts
LiamSarsfield 6595660
Add detailed calibration verification logging
LiamSarsfield bbdb6ea
Add tools/performance
LiamSarsfield c768b58
Update pnpm-lock.yaml to include dotenv and playwright dependencies f…
LiamSarsfield 2492d1e
Update docker-compose.yml to change the dependency condition for the …
LiamSarsfield e4b74d9
Enhance performance testing documentation and scripts
LiamSarsfield df0cfd2
Add baseMetrics placeholder in post-to-codevitals.js
LiamSarsfield ce3b20d
Refactor browser launch configuration in calibrate-throttling.js
LiamSarsfield 55e48ba
Merge remote-tracking branch 'origin/trunk' into add/perf-testing-ci-mvp
LiamSarsfield e2c9808
Refactor ESLint configuration for performance testing CLI scripts
LiamSarsfield d85f183
Update performance testing setup and documentation
LiamSarsfield c9dc15d
Merge remote-tracking branch 'origin/trunk' into add/perf-testing-ci-mvp
LiamSarsfield 0ed39b5
Enhance Jetpack_WPCom_Connection_Simulator to log unhandled endpoints
LiamSarsfield e3e0860
Merge remote-tracking branch 'origin/trunk' into add/perf-testing-ci-mvp
LiamSarsfield 9e2df0e
Merge branch 'trunk' into add/perf-testing-ci-mvp
LiamSarsfield File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| node_modules/ | ||
| results/*.json | ||
| results/*.log | ||
| .env | ||
| .env.local | ||
| playwright-report/ | ||
| test-results/ | ||
| build/ | ||
| calibration.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Jetpack Performance Testing | ||
|
|
||
| Measures wp-admin dashboard LCP (Largest Contentful Paint) for Jetpack with simulated WordPress.com connection. | ||
|
|
||
| ## CI Usage | ||
|
|
||
| The test suite is designed to run in TeamCity. See build configuration for setup. | ||
|
|
||
| ### Build Steps | ||
|
|
||
| 1. Build Jetpack plugin | ||
| 2. Install dependencies (`pnpm install`) | ||
| 3. Install Playwright (`pnpm exec playwright install chromium --with-deps`) | ||
| 4. Calibrate CPU throttling (`pnpm calibrate`) | ||
| 5. Run tests (`pnpm test --skip-rsync`) | ||
|
|
||
| ### Environment Variables | ||
|
|
||
| | Variable | Description | | ||
| |----------|-------------| | ||
| | `CODEVITALS_TOKEN` | API token for posting results to CodeVitals | | ||
| | `CODEVITALS_URL` | CodeVitals API URL (default: https://www.codevitals.run) | | ||
| | `COMPOSE_PROJECT_NAME` | Unique Docker project name for build isolation | | ||
| | `GIT_COMMIT` | Git commit SHA for tracking | | ||
| | `GIT_BRANCH` | Git branch for tracking (default: trunk) | | ||
| | `ITERATIONS` | Number of measurement iterations (default: 5) | | ||
| | `WP_ADMIN_USER` | WordPress admin username (default: admin) | | ||
| | `WP_ADMIN_PASS` | WordPress admin password (default: password) | | ||
|
|
||
| ## Metric | ||
|
|
||
| - `wp-admin-dashboard-connection-sim-largestContentfulPaint` - Dashboard LCP with simulated Jetpack connection | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **Docker Setup**: Spins up WordPress with Jetpack and a simulated WordPress.com connection (fake tokens + mocked API with 200ms latency) | ||
| 2. **CPU Calibration**: Normalizes CPU speed across different machines for consistent results | ||
| 3. **LCP Measurement**: Uses Playwright to log in to wp-admin and measure Largest Contentful Paint | ||
| 4. **Results**: Posts metrics to CodeVitals for tracking over time | ||
|
|
||
| ## Scripts | ||
|
|
||
| | Script | Description | | ||
| |--------|-------------| | ||
| | `pnpm test` | Run full test suite | | ||
| | `pnpm test:quick` | Quick test with 2 iterations | | ||
| | `pnpm calibrate` | Run CPU throttling calibration | | ||
| | `pnpm measure` | Run LCP measurement only | | ||
| | `pnpm report` | Post results to CodeVitals only | | ||
| | `pnpm test -- --skip-rsync` | Run tests without rebuilding Jetpack | | ||
| | `pnpm test -- --skip-codevitals` | Run tests without posting to CodeVitals | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Jetpack Performance Testing Environment | ||
| # Single WordPress instance with simulated Jetpack connection for LCP measurement. | ||
| # | ||
| # Ports are assigned dynamically by Docker. Use 'docker compose port <service> 80' to discover. | ||
|
|
||
| services: | ||
| # Shared MySQL database | ||
| db: | ||
| image: mysql:8.0 | ||
| command: --default-authentication-plugin=mysql_native_password | ||
| volumes: | ||
| - db_data:/var/lib/mysql | ||
| - ./init-databases.sql:/docker-entrypoint-initdb.d/init.sql:ro | ||
| restart: unless-stopped | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: rootpassword | ||
| networks: | ||
| - jetpack-perf | ||
| healthcheck: | ||
| test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-prootpassword"] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 20 | ||
| start_period: 30s | ||
|
|
||
| # WordPress with Jetpack simulated connection | ||
| # Uses mu-plugin to fake connection tokens and intercept WP.com API calls with artificial latency | ||
| wordpress-jetpack-connected: | ||
| image: wordpress:6.7-php8.2-apache | ||
| ports: | ||
| - "80" # Dynamic port - use 'docker compose port wordpress-jetpack-connected 80' to discover | ||
| restart: unless-stopped | ||
| environment: | ||
| WORDPRESS_DB_HOST: db | ||
| WORDPRESS_DB_USER: root | ||
| WORDPRESS_DB_PASSWORD: rootpassword | ||
| WORDPRESS_DB_NAME: wp_jetpack_connected | ||
| WORDPRESS_TABLE_PREFIX: wp_ | ||
| WORDPRESS_DEBUG: "false" | ||
| # Simulated latency in milliseconds (configurable) | ||
| WPCOM_SIMULATED_LATENCY_MS: ${WPCOM_SIMULATED_LATENCY_MS:-200} | ||
| volumes: | ||
| - wp_jetpack_connected:/var/www/html | ||
| - ../build/jetpack:/var/www/html/wp-content/plugins/jetpack:ro | ||
| # Mount the mu-plugin for connection simulation | ||
| - ./mu-plugins:/var/www/html/wp-content/mu-plugins:ro | ||
| networks: | ||
| - jetpack-perf | ||
| depends_on: | ||
| db: | ||
| condition: service_healthy | ||
|
|
||
| # WP-CLI for setup operations | ||
| wpcli: | ||
| image: wordpress:cli-2.10-php8.2 | ||
| user: "33:33" # Match www-data UID from WordPress Debian image | ||
| volumes: | ||
| - wp_jetpack_connected:/var/www/html/jetpack-connected | ||
| - ./setup-wordpress.sh:/usr/local/bin/setup-wordpress.sh:ro | ||
| - ../build/jetpack:/var/www/html/jetpack-connected/wp-content/plugins/jetpack:ro | ||
| - ./mu-plugins:/var/www/html/jetpack-connected/wp-content/mu-plugins:ro | ||
| networks: | ||
| - jetpack-perf | ||
| depends_on: | ||
| db: | ||
| condition: service_healthy | ||
| wordpress-jetpack-connected: | ||
| condition: service_started | ||
| environment: | ||
| WORDPRESS_DB_HOST: db | ||
| WORDPRESS_DB_USER: root | ||
| WORDPRESS_DB_PASSWORD: rootpassword | ||
| WP_ADMIN_USER: ${WP_ADMIN_USER:-admin} | ||
| WP_ADMIN_PASS: ${WP_ADMIN_PASS:-password} | ||
| WP_ADMIN_EMAIL: ${WP_ADMIN_EMAIL:-admin@example.com} | ||
| # Run setup and exit | ||
| command: ["sh", "/usr/local/bin/setup-wordpress.sh"] | ||
|
|
||
| networks: | ||
| jetpack-perf: | ||
| driver: bridge | ||
|
|
||
| volumes: | ||
| db_data: | ||
| wp_jetpack_connected: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| -- Initialize database for Jetpack connected WordPress instance | ||
| CREATE DATABASE IF NOT EXISTS wp_jetpack_connected; | ||
|
|
||
| -- Grant permissions | ||
| GRANT ALL PRIVILEGES ON wp_jetpack_connected.* TO 'root'@'%'; | ||
| FLUSH PRIVILEGES; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the exploration intents is to see about reusing work. With our GHE instance, TeamCity is the runner we have to use, so seeing the pros/cons of TC here.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub Actions runners can have unpredictable performance variability due to shared infrastructure. For detecting small regressions (5-10%), this noise can drown out minor regressions over time. The TeamCity build runs on a dedicated machine with no other agents interfering.
The monorep is used instead of the already-built plugin mainly so we can leverage commit level tracking, so we can have the ability to bisect when issues appear (where needed). It may not be needed for now though, but you can see within CodeVitals that a point can be clicked and we can see the commit details when clicking on the commit SHA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that every commit that changes anything in Jetpack gets mirrored to Automattic/jetpack-production, absent rare cases where something goes wrong with the mirroring. Each commit there also includes a footer like
Upstream-Ref: Automattic/jetpack@d5b54134bb471f3a54d04b12e128e6e0e2d77bdeto make it easy to find the corresponding monorepo commit.It's up to you, but it may save having to build each monorepo commit before you can test it.
It'll also either save you testing commits that don't affect Jetpack-the-plugin at all or save you having to maintain code to try to identify which ones do. I see your P2 post mentions
That would unnecessarily test changes to packages like
packages/jetpack-mu-wpcom, unless you have a list of packages to ignore. It could also miss JS-only changes that might still affect the LCP timing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually yes! I should have checked this before hand, I didn't realise
Automattic/jetpack-productionhas bissectable commits like this. It'll also help regarding the issue you mentioned for testing commits that don't affect Jetpack-the-plugin also. Thanks, I'll update the TeamCity build to use that instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use jetpack-production, the implementation now:
The monorepo VCS root is still used for the tools/performance/ scripts, but the plugin itself comes directly from the pre-built mirror.