Skip to content

Commit 18d0ee7

Browse files
authored
Merge pull request #222 from woocommerce/24-09/orchestration
Improve test orchestration for more powerful Compatibility Tests between plugins
2 parents efeced9 + b51dbd2 commit 18d0ee7

File tree

70 files changed

+3075
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3075
-339
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: QIT Orchestration Tests
2+
3+
on:
4+
# Every day at 11pm UTC (6pm ET)
5+
schedule:
6+
- cron: '0 23 * * *'
7+
# Manually
8+
workflow_dispatch:
9+
10+
jobs:
11+
orchestration-tests:
12+
runs-on: ubuntu-latest
13+
env:
14+
NO_COLOR: 1
15+
QIT_DISABLE_ONBOARDING: yes
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.3'
24+
25+
- name: Enable dev mode
26+
run: ./qit dev
27+
28+
- name: Connect to Staging QIT
29+
run: ./qit backend:add --environment="staging" --qit_secret="${{ secrets.QIT_STAGING_SECRET }}" --manager_url="https://stagingcompatibilitydashboard.wpcomstaging.com"
30+
31+
- name: Composer install
32+
working-directory: src
33+
run: composer install
34+
35+
- name: Run Orchestration Tests
36+
working-directory: src
37+
run: |
38+
cd _tests/orchestration
39+
php ../../qit-cli.php run:e2e woocommerce-amazon-s3-storage -v
40+
41+
- name: Get Report Path
42+
if: ${{ !cancelled() }}
43+
working-directory: src
44+
run: |
45+
echo "REPORT_PATH=$(php qit-cli.php e2e-report --dir_only)" >> $GITHUB_ENV
46+
47+
- name: Upload Test Report
48+
if: ${{ !cancelled() }}
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: orchestration-test-report
52+
path: ${{ env.REPORT_PATH }}
53+
retention-days: 14

_tests/orchestration/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Orchestration Tests
2+
3+
This directory contains compatibility test suites to test orchestration. To run it, do `qit run:e2e woocommerce-amazon-s3-storage` in this directory.
4+
5+
## Overview
6+
7+
Each test suite verifies that plugins can coexist and handle their resources properly. The test lifecycle works as follows:
8+
9+
1. **Shared Setup**: Each plugin establishes its shared state
10+
2. **DB Export**: A DB snapshot is created
11+
3. **Plugin A - Full Cycle**: Setup → Test → Teardown
12+
4. **DB Import**: The DB snapshot is restored
13+
5. **Plugin B - Full Cycle**: Setup → Test → Teardown
14+
6. **Shared Teardown**: Cleanup in reverse order

_tests/orchestration/qit.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins:
2+
woocommerce-amazon-s3-storage:
3+
source: ./woocommerce-amazon-s3-storage
4+
test_tags:
5+
- ./woocommerce-amazon-s3-storage-tests
6+
woocommerce-progressive-discounts:
7+
action: test
8+
source: ./woocommerce-progressive-discounts
9+
test_tags:
10+
- ./woocommerce-progressive-discounts-tests
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { test, expect } from '@playwright/test';
2+
import qit from '/qitHelpers';
3+
4+
test('Isolated Setup', async ({ page }) => {
5+
await page.goto('/wp-admin');
6+
console.log('[Isolated Setup JS] Amazon S3 Storage');
7+
const shared = await qit.wp('option get woocommerce-amazon-s3-storage_shared_order', true);
8+
expect(shared.output.trim()).toBe("first");
9+
const setup = await qit.wp('option get woocommerce-amazon-s3-storage_isolated_order', true);
10+
expect(setup.output.trim()).toBe("second");
11+
12+
// Check that Plugin B's isolated option does not exist
13+
try {
14+
await qit.wp('option get woocommerce-progressive-discounts_isolated_order', true);
15+
throw new Error('Expected Plugin B isolated option not to exist, but it does.');
16+
} catch (e) {
17+
expect(e.message).toContain("Does it exist?");
18+
}
19+
20+
const pluginBShared = await qit.wp('option get woocommerce-progressive-discounts_shared_order', true);
21+
expect(pluginBShared.output.trim()).toBe("first");
22+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
echo "[Isolated Setup Shell] Amazon S3 Storage"
2+
shared_order=$(wp option get woocommerce-amazon-s3-storage_shared_order)
3+
if [ "$shared_order" != "first" ]; then
4+
echo "Error: Shared setup did not run first"
5+
exit 1
6+
fi
7+
wp option update woocommerce-amazon-s3-storage_isolated_order "second"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { test, expect } from '@playwright/test';
2+
import qit from '/qitHelpers';
3+
4+
test('Shared Setup', async ({ page }) => {
5+
await page.goto('/wp-admin');
6+
console.log('[Shared Setup JS] Amazon S3 Storage');
7+
const result = await qit.wp('option get woocommerce-amazon-s3-storage_shared_order', true);
8+
console.log('Shared Setup Order:', result.output);
9+
expect(result.output.trim()).toBe("first");
10+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# shared-setup.sh
3+
echo "[Shared Setup Shell] Amazon S3 Storage"
4+
wp option update "woocommerce-amazon-s3-storage_shared_order" "first"
5+
wp option get "woocommerce-amazon-s3-storage_shared_order"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// /tmp/foo/local/bootstrap/shared-teardown.js
2+
import {test, expect} from '@playwright/test';
3+
import qit from '/qitHelpers';
4+
5+
// shared-teardown.js for Amazon S3
6+
test('Shared Teardown', async ({page}) => {
7+
await page.goto('/wp-admin');
8+
console.log('[Shared Teardown JS] Amazon S3 Storage');
9+
10+
// Verify shared setup exists
11+
const shared = await qit.wp('option get woocommerce-amazon-s3-storage_shared_order', true);
12+
expect(shared.output.trim()).toBe("first");
13+
14+
// Verify the other plugin's shared option does NOT exist (since we run last)
15+
try {
16+
await qit.wp('option get woocommerce-progressive-discounts_shared_order', true);
17+
throw new Error("Expected other plugin's shared option not to exist, but it does.");
18+
} catch (e) {
19+
expect(e.message).toContain("Does it exist?");
20+
}
21+
22+
// Verify isolated options don't exist
23+
try {
24+
await qit.wp('option get woocommerce-amazon-s3-storage_isolated_order', true);
25+
throw new Error("Expected isolated option not to exist, but it does.");
26+
} catch (e) {
27+
expect(e.message).toContain("Does it exist?");
28+
}
29+
30+
try {
31+
await qit.wp('option get woocommerce-amazon-s3-storage_teardown_order', true);
32+
throw new Error("Expected teardown option not to exist, but it does.");
33+
} catch (e) {
34+
expect(e.message).toContain("Does it exist?");
35+
}
36+
37+
// Finally delete shared option
38+
await qit.wp('option delete woocommerce-amazon-s3-storage_shared_order');
39+
});

0 commit comments

Comments
 (0)