Skip to content

test(site-type-wp): add a Behat suite and CI workflow - #245

Open
mrrobot47 wants to merge 29 commits into
EasyEngine:developfrom
mrrobot47:test/behat-suite-r3
Open

mrrobot47 wants to merge 29 commits into
EasyEngine:developfrom
mrrobot47:test/behat-suite-r3

Conversation

@mrrobot47

Copy link
Copy Markdown
Member

Extends the three old feature files into a Behat suite for site-type-wp (features/: 116 scenarios, outline rows counted) and replaces test_and_build.yml with a Behat workflow that runs it on every pull request, on pushes to develop and master, and on demand.

It covers the WordPress site lifecycle, labels and www redirects, install options, VIP, multisite, redis and proxy caches, PHP versions (current and legacy images), local, global and external databases, SSL (self-signed, custom, inherited, one Let's Encrypt issuance) and alias domains. features/COVERAGE.md maps each command, flag and behaviour to its scenarios.

  • The workflow runs the suite inside a fresh core checkout: core develop is cloned, every easyengine/* package is set to dev-develop, and this package is installed from the pull request's checkout through a Composer path repository, so the code under test is the PR's. The old job tested the Packagist dev-develop package instead.
  • Lanes: main (107 scenarios), slow (7, legacy PHP images) and le (2), each on PHP 7.4 and 8.0 to 8.5. The main lane's jobs are named Behat Tests - PHP <version>, so the required checks keep matching. The main lane also builds the phar without dev autoloading, as the old job did. @destructive scenarios run there too, since the runner is thrown away.
  • @le runs against a local Pebble ACME server (.github/behat/pebble-setup.sh). Every other lane points the Let's Encrypt host at a blackhole and checks that the real service can't be reached, and on CI the suite refuses to start unless one of the two is in place, so no run can reach the real Let's Encrypt.
  • Scenarios written for open bugs (12) are left out for now: they assert the fixed behaviour, so each comes back with its fix. Every scenario in this PR gates, and COVERAGE.md lists the bugs that aren't covered yet.

Merge after EasyEngine/easyengine#1950, which stops core's test job from running this suite unfiltered.

To run it locally (as root, on a test machine, since the suite creates and deletes *.test sites): copy features/ over a core checkout's features/ and run sudo -E vendor/bin/behat --tags='~@le' from the core root; add ~@destructive to skip the scenarios that change global services or config, and ~@slow to skip the legacy PHP images.

Green run on my fork (PHP 7.4 and 8.0 to 8.5, every lane): https://github.com/mrrobot47/site-type-wp/actions/runs/39380700993

Fix upstream steps that could never fail (unanchored I run pattern, inverted label count, compose v1 container names, swapped subsite arguments) and replace the delete-all cleanup with prefix-scoped cleanup of sites, docker objects, global DB objects, redis keys and hosts entries. Add generic steps for command results, site info, EE database, files, containers, networks, volumes, global DB/redis, HTTP and hosts.
…e context

Add a step that matches a deleted site's random DB user by prefix, and a guard so a scenario that inspects an earlier scenario's leftovers fails when run alone instead of passing vacuously. The feature cleanup now also removes this suite's nginx-proxy certs and ACME state, which `--ssl=off` and LE deletes leave in the global proxy.
…en assertions

Add known-bug scenarios for the level-0 rollback dropping another site's database (custom SSL typo), the user-visible HTTPS redirect after an alias change on a site whose SSL was turned off, and self-signed sites that can't turn SSL off. The nohttps scenario was mislabelled as a #488 regression: the flag was already false for sites without SSL. Reference the WPT issue IDs, match DB_CHARSET and MULTISITE exactly, check that delete and the leak scenarios remove the random DB user, assert the w3tc error, and stop the missing-site delete from depending on the previous scenario. Update COVERAGE.md (126 scenarios, 27 known-bug, 86 in the default run).
… group

Under a TTY, `timeout` puts ee in a background process group; the `docker exec -it` of the global redis purge then stops on SIGTTOU together with timeout, so the AfterFeature delete of a --cache site never returns. -k 30 because ee catches SIGTERM without dispatching it (MIG-9).
Match the site list JSON pretty-printed or compact, accept lang="de" (the translation picks the html lang attribute), use full installs for the redirect checks (WPT-17 race with --skip-install), and look for the SEC-1 marker in $HOME, which sudo -E keeps as the caller home on CI.
…gine#239)

AUTH-1, AUTH-5 and the blank-alias scenario pass on develop now, so they are regular regression scenarios. The WPT-2 + WPT-12 alias-change scenario passed there only because the update returns before docker-gen has the recreated container; it waits for the new alias to be served before it checks the main domain.
Right after create the proxy reload is still in flight (PRX-5): on the PHP 7.4 runner the first HTTPS request failed with curl error 55. Wait until a verified HTTPS request succeeds, then check the status and verify result.
The database name/user collision, failed custom-SSL create, existing webroot and inherit + subdom scenarios pass with the fix/site-name-collisions branches of site-command and site-type-wp: the name collision is now refused by the docker volume check and --dbuser of another site up front, so both assert the new error.
…enarios regular

They pass with site-command fix/proxy-cache-rollback-and-le-alias and fail on develop until it merges.
…lias

CACHE-1, WP-1 and SEC-1 scenarios are regular; the weak password message no longer echoes the password (EasyEngine#244); the wildcard refusal runs on a site that never had SSL, since one that had --ssl=self keeps site_ssl_wildcard=1 and goes on to request a certificate; the new alias is polled until the proxy serves it (PRX-7).
…line output

compareContents() compared list elements by position, so [1,3,5] wasn't found in [1,2,3,4,5], and a missing key or property raised a notice. Both something-like steps only used the first line of the expected text.
EE's hardcoded Let's Encrypt endpoint is redirected to a local Pebble on the runner (hosts entry, throwaway CA, resolved routing for the test domain). No product code changes.
Runs the package features/ inside a fresh core develop checkout, with this checkout installed as the package through a Composer path repository, so the PR code is under test. @le runs in behat-le.yml against Pebble. @slow (legacy PHP images) is its own job; @known-bug scenarios run in a separate non-gating job.
Run PHP 7.4 and 8.5, strip control characters from the junit files before building failures.txt, and cap the Behat step at 75 minutes so a hung run still uploads its logs. The @le lanes against Pebble move into behat.yml (lanes named le*), replacing behat-le.yml. Diagnostics: the host addresses and routes, and the docker-compose version after the first run (MIG-20).
EE's first run downloads docker-compose 2.27.0 without --fail (MIG-10); on a GitHub error it moves the HTML error page over the binary, as on an admin-tools-command runner. Fetch 2.27.0 again with --fail and retries in that case.
Runs every lane on PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5 instead of only the floor and ceiling; the jobs run in parallel.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

HTTP and cache-purge checks can pass on underlying failures, weakening regression protection.

2 open issues
What changed in this PR

Adds a Behat suite for WordPress site behavior and CI that tests the package checkout inside EasyEngine core.

Changes:

  • Expands coverage to 116 scenarios across site lifecycle and configuration.
  • Adds main, legacy-PHP, and local ACME test lanes.
  • Improves shared assertions, fixture cleanup, and coverage documentation.
File Description
features/​vip.feature Tests VIP setup and repository rejection.
features/​ssl.feature Tests SSL creation, updates, and cleanup.
features/​site.feature Expands lifecycle and configuration checks.
features/​redirect.feature Tests www redirects and removal.
features/​proxy-cache.feature Tests proxy-cache configuration and purging.
features/​php-version.feature Covers current and legacy PHP images.
features/​multisite.feature Tests multisite setup and validation.
features/​labels.feature Checks Docker resource labels.
features/​install-options.feature Tests WordPress installation options.
features/​external-db.feature Tests remote databases and rollback.
features/​database.feature Covers database lifecycle and collisions.
features/​COVERAGE.md Documents coverage, gaps, and execution.
features/​cache.feature Tests Redis caching and purging.
features/​bootstrap/​support.php Updates recursive content comparisons.
features/​bootstrap/​FeatureContext.php Adds assertions, fixtures, cleanup, and ACME guards.
features/​alias-domains.feature Tests alias lifecycle and regressions.
.github/​workflows/​test_and_build.yml Removes the previous workflow.
.github/​workflows/​behat.yml Adds matrix testing and result collection.
.github/​behat/​pebble-setup.sh Provides local ACME infrastructure and isolation.

Review effort: Balanced

Comment thread features/bootstrap/FeatureContext.php Outdated
Comment thread features/proxy-cache.feature Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Root-level cleanup and system-wide DNS, certificate trust, and firewall changes require final human integration review.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants