Skip to content

Commit d729b55

Browse files
Add Jetpack performance testing CI infrastructure (#46287)
1 parent b8dd513 commit d729b55

16 files changed

+2337
-0
lines changed

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ packages:
55
- tools/cli
66
- tools/e2e-commons
77
- tools/js-tools
8+
- tools/performance
89
- .github/files/coverage-munger
910

1011
engineStrict: true

tools/performance/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules/
2+
results/*.json
3+
results/*.log
4+
.env
5+
.env.local
6+
playwright-report/
7+
test-results/
8+
build/
9+
plugin/
10+
calibration.json

tools/performance/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Jetpack Performance Testing
2+
3+
Measures wp-admin dashboard LCP (Largest Contentful Paint) for Jetpack with simulated WordPress.com connection.
4+
5+
## CI Usage
6+
7+
The test suite is designed to run in TeamCity. See `TEAMCITY-SETUP.md` for detailed setup instructions.
8+
9+
### Build Steps
10+
11+
1. Clone `jetpack-production` (pre-built plugin)
12+
2. Install dependencies (`pnpm install`)
13+
3. Install Playwright (`pnpm exec playwright install chromium --with-deps`)
14+
4. Calibrate CPU throttling (`pnpm calibrate`)
15+
5. Run tests (`pnpm test`)
16+
17+
### Environment Variables
18+
19+
| Variable | Description |
20+
|----------|-------------|
21+
| `CODEVITALS_TOKEN` | API token for posting results to CodeVitals |
22+
| `CODEVITALS_URL` | CodeVitals API URL (default: https://www.codevitals.run) |
23+
| `COMPOSE_PROJECT_NAME` | Unique Docker project name for build isolation |
24+
| `GIT_COMMIT` | Git commit SHA for tracking (auto-detected from plugin) |
25+
| `GIT_BRANCH` | Git branch for tracking (default: trunk) |
26+
| `ITERATIONS` | Number of measurement iterations (default: 5) |
27+
| `WP_ADMIN_USER` | WordPress admin username (default: admin) |
28+
| `WP_ADMIN_PASS` | WordPress admin password (default: password) |
29+
30+
## Metric
31+
32+
- `wp-admin-dashboard-connection-sim-largestContentfulPaint` - Dashboard LCP with simulated Jetpack connection
33+
34+
## How It Works
35+
36+
1. **Plugin Source**: Uses pre-built plugin from [jetpack-production](https://github.com/Automattic/jetpack-production) mirror (auto-cloned for local dev)
37+
2. **Docker Setup**: Spins up WordPress with Jetpack and a simulated WordPress.com connection (fake tokens + mocked API with 200ms latency)
38+
3. **CPU Calibration**: Normalizes CPU speed across different machines for consistent results
39+
4. **LCP Measurement**: Uses Playwright to log in to wp-admin and measure Largest Contentful Paint
40+
5. **Results**: Posts metrics to CodeVitals for tracking over time
41+
42+
## Scripts
43+
44+
| Script | Description |
45+
|--------|-------------|
46+
| `pnpm test` | Run full test suite (auto-clones plugin if needed) |
47+
| `pnpm test:quick` | Quick test with 2 iterations |
48+
| `pnpm calibrate` | Run CPU throttling calibration |
49+
| `pnpm measure` | Run LCP measurement only |
50+
| `pnpm report` | Post results to CodeVitals only |
51+
| `pnpm test -- --skip-codevitals` | Run tests without posting to CodeVitals |
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Jetpack Performance Testing Environment
2+
# Single WordPress instance with simulated Jetpack connection for LCP measurement.
3+
# Plugin is mounted from ../plugin (cloned from jetpack-production mirror).
4+
#
5+
# Ports are assigned dynamically by Docker. Use 'docker compose port <service> 80' to discover.
6+
7+
services:
8+
# Shared MySQL database
9+
db:
10+
image: mysql:8.0
11+
command: --default-authentication-plugin=mysql_native_password
12+
volumes:
13+
- db_data:/var/lib/mysql
14+
- ./init-databases.sql:/docker-entrypoint-initdb.d/init.sql:ro
15+
restart: unless-stopped
16+
environment:
17+
MYSQL_ROOT_PASSWORD: rootpassword
18+
networks:
19+
- jetpack-perf
20+
healthcheck:
21+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-prootpassword"]
22+
interval: 5s
23+
timeout: 5s
24+
retries: 20
25+
start_period: 30s
26+
27+
# WordPress with Jetpack simulated connection
28+
# Uses mu-plugin to fake connection tokens and intercept WP.com API calls with artificial latency
29+
wordpress-jetpack-connected:
30+
image: wordpress:6.7-php8.2-apache
31+
ports:
32+
- "80" # Dynamic port - use 'docker compose port wordpress-jetpack-connected 80' to discover
33+
restart: unless-stopped
34+
environment:
35+
WORDPRESS_DB_HOST: db
36+
WORDPRESS_DB_USER: root
37+
WORDPRESS_DB_PASSWORD: rootpassword
38+
WORDPRESS_DB_NAME: wp_jetpack_connected
39+
WORDPRESS_TABLE_PREFIX: wp_
40+
WORDPRESS_DEBUG: "false"
41+
# Simulated latency in milliseconds (configurable)
42+
WPCOM_SIMULATED_LATENCY_MS: ${WPCOM_SIMULATED_LATENCY_MS:-200}
43+
volumes:
44+
- wp_jetpack_connected:/var/www/html
45+
- ../plugin:/var/www/html/wp-content/plugins/jetpack:ro
46+
# Mount the mu-plugin for connection simulation
47+
- ./mu-plugins:/var/www/html/wp-content/mu-plugins:ro
48+
networks:
49+
- jetpack-perf
50+
depends_on:
51+
db:
52+
condition: service_healthy
53+
54+
# WP-CLI for setup operations
55+
wpcli:
56+
image: wordpress:cli-2.10-php8.2
57+
user: "33:33" # Match www-data UID from WordPress Debian image
58+
volumes:
59+
- wp_jetpack_connected:/var/www/html/jetpack-connected
60+
- ./setup-wordpress.sh:/usr/local/bin/setup-wordpress.sh:ro
61+
- ../plugin:/var/www/html/jetpack-connected/wp-content/plugins/jetpack:ro
62+
- ./mu-plugins:/var/www/html/jetpack-connected/wp-content/mu-plugins:ro
63+
networks:
64+
- jetpack-perf
65+
depends_on:
66+
db:
67+
condition: service_healthy
68+
wordpress-jetpack-connected:
69+
condition: service_started
70+
environment:
71+
WORDPRESS_DB_HOST: db
72+
WORDPRESS_DB_USER: root
73+
WORDPRESS_DB_PASSWORD: rootpassword
74+
WP_ADMIN_USER: ${WP_ADMIN_USER:-admin}
75+
WP_ADMIN_PASS: ${WP_ADMIN_PASS:-password}
76+
WP_ADMIN_EMAIL: ${WP_ADMIN_EMAIL:[email protected]}
77+
# Run setup and exit
78+
command: ["sh", "/usr/local/bin/setup-wordpress.sh"]
79+
80+
networks:
81+
jetpack-perf:
82+
driver: bridge
83+
84+
volumes:
85+
db_data:
86+
wp_jetpack_connected:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Initialize database for Jetpack connected WordPress instance
2+
CREATE DATABASE IF NOT EXISTS wp_jetpack_connected;
3+
4+
-- Grant permissions
5+
GRANT ALL PRIVILEGES ON wp_jetpack_connected.* TO 'root'@'%';
6+
FLUSH PRIVILEGES;

0 commit comments

Comments
 (0)