Engineering Notes · agent operations · test infrastructure
How I took a client's full browser test suite from over four hours to about an hour and a quarter, without trading away the one thing the suite is for, which is telling me the truth. It runs the suite across isolated copies of the whole Magento stack on one machine, and the AI agent that runs the tests asks a second agent, outside its container, to build those copies.
Ok, so the suite on this store has grown the way suites do. Every bug that bit us got a test, every checkout change got a test, and a third-party checkout, card payments and live shipping rates mean a lot of browser time per test. On 2026-11-23 a full pass measured 247 minutes. Turning off a built-in half second delay on every browser action got it to 178 minutes, which is a nice cut, but still three hours, and a flaky test means a re-run on top. I thought I had turned off always-on video recording at the same time. I had not. A shared test fixture was quietly recording every first attempt anyway, whatever the config said, and nobody noticed until the parallel runs started counting where the CPU goes.
For feature work that is annoying but survivable, the suite runs overnight and I read it in the morning. What changed is patching. The dependency scan on that store turns up new advisories most weeks, and there were a couple of real security tickets in the last month. When a fix like that is ready at 10am, "verified by 2pm, maybe" is no longer good enough, and skipping the suite is not an option either, since the suite is exactly what catches the patch that breaks checkout.
And the clock is a lot shorter than it used to be. With AI now being used to find and exploit holes constantly, and compromises moving fast once something is public, delivering a critical patch (and knowing all the functionality is still intact after it) is no longer a nice to have. If you can't deploy rapidly, you may already be too late, and you might as well go have a beer and give up. The tests are only half of it, the deploy itself has to be zero downtime as well, because a patch that needs a maintenance window is a patch that waits (that is a separate post).
Rapid deployment is a requirement. So is zero downtime deployment. Neither is a nice to have anymore.
Reliability first. Faster runs of a flaky suite are not a win, they just surface the flakes faster, so anything that cut time by lowering retries or accepting noise was off the table.
The obvious move is more Playwright workers against the one dev site. I did that months ago and it helps up to a point, then the tests start stepping on each other, because they share one database, one search index, one cache and one set of admin settings. A test that flips a config value for its own purposes changes the world for every other test running at that moment.
So instead of more workers on one site, there are now more sites. Each "slot" is a full copy of the dev store, running side by side on the same workstation:
The main site is lane zero, and slots t1 and t2 sit next to it. Then there are a few moving parts:
env.php, pin the config values tests depend on, compile, restart PHP, then a preflight that checks the slot really serves its own pages.bin/test-parallel) hands each lane its share, collects the results, and merges them into one report. If a slot goes unhealthy mid run, its share gets redistributed, and the run never silently skips specs.The first real numbers are for main plus one slot:
These are not best-case numbers, and that is on purpose. Every timing run was done on my normal workstation, during work hours, while I was busy with other things. A local LLM was working through another job (about 4.5 of the 16 CPU threads), another client's test suite was running at the same time (about 4 more), plus my desktop and editor sessions. The test lanes got roughly 3 to 4 threads between them. Timing this on a completely idle machine would be a false narrative. Nobody's dev box is idle on the day a security fix lands.
Then main plus two slots: 1h27m (1h27m27s). That is 25% faster than one slot. It is 51% off the 178-minute serial run, and 65% off the original 247. All 200 spec files ran exactly once, and the isolation self-test passed again. That run was busier still. On top of my normal work, eleven review agents were reading the test suite in the background for most of it (that is the next post). Video recording was really off by then too (more on that below).
The second two-slot run was on a normal working day, without the review agents: 1h16m (1h16m22s). That is 34% faster than one slot. It is 57% off the 178-minute serial run, and 69% off the original 247. Same suite, same slots, same code. Eleven minutes came back just from what else the machine was doing.
The third two-slot run was clean: 1h14m (1h13m58s), with no failures and no flakes. It was also the hottest of the three, at 89°C. Across all three runs the median is 1h16m. That is 57% off the 178-minute serial run, and 69% off the original 247. Going from one slot to two took another third off.
The series had three failures in total, and none came from the slots. Two were tests timing out under load. One was a click that landed on a loading overlay. The test used a forced click, which skips the check that would have caught it. Those fixes go in with the test cleanup, after the timing runs, so the numbers stay comparable.
There is no third slot. My normal work already uses about 52 GB of the 64 GB in this machine. A third slot would leave almost nothing free at peak. I could stop my other work to make room. I didn't, for the same reason I don't time on an idle machine.
Every timed run so far, oldest first. Pass, fail and flaky counts are tests, out of about 770 that run each time.
Every run from main only onwards ran every planned spec file exactly once, and every run with a live slot passed the isolation self-test.
This is the part I could not find anyone else writing about. The AI agent that owns this project runs inside the project's DDEV container. It writes the tests, runs them, reads the reports. It can NOT create slots, because a slot is a new set of containers, and the agent in the container has no docker and no DDEV (by design, I do not want a container able to start containers on my machine).
So slot creation lives with a second agent, a Claude session on the host. The two talk through Claude Code's own cross-session messaging (the session registry and sockets are mounted into the container), and a hook on the host side only lets a message through if it starts with one of a few tags, like [test-slot] or [lucas-asked]. Anything else is blocked, so this channel can't turn into general chatter between agents.
When the container agent wants a slot it sends [test-slot] GO t1. Before the host agent runs anything, it checks every file the slot scripts will execute against a baseline of hashes I approved, and reviews any difference. The container agent writes the slot code, the host agent decides whether to run it. That split is deliberate, the agent that writes the scripts is never the one that runs them with host access.
The first prepare on t1 failed its config pin check: payment/checkmo/active effective value is "1", expected "0". Looks like the slot was misconfigured.
It was not. The check read the value with bin/magento config:show, which prints what is stored in the database, and that row says 1. But that value is locked to 0 in env.php, and the lock wins, so the store (and every test) sees 0. Main had the exact same database row and the exact same lock, so main "failed" the same check, nobody had noticed because main never ran it.
The fix was to read the value the way the store does (through Magento's own config reader, in a small helper that bootstraps the app), not the way the database stores it. The specs for the check were changed first and failed (16 of 19), then the fix made them pass, then the slot prepared cleanly.
Lesson: a check has to read what the application sees, not what happens to be stored. It is the same mistake as reading a config file and assuming the running process loaded it.
Every one of these has the same shape as the checkmo one: two things that looked identical were not, and the only way to find out was to run the real thing.
A few rules came out of building this, mostly from things that already went wrong once:
A full run used to be a child of the Claude session that started it. Close that session and the run died with it. That could be /exit, ctrl+c or a closed terminal. The main lane stopped, and the slot lanes kept going with nobody listening. That is an expensive mistake an hour into a run.
So the runner can now detach. yarn test:all --detach starts the run in its own session and process group. It comes back in seconds with a run id, a status file, a log path and the command to wait on it.
--wait --run-id=<id> --timeout=540, which reads the status file and checks the process itself. There are no polling loops. A crash says crashed, with the end of the log. A live process with a stale heartbeat says stalled. Silence is never an answer. --status gives the state in one line.--cancel needs the run id. It stops the whole process group, so the slot jobs shut down cleanly.ddev restart stays blocked mid run.Detach is opt-in. The foreground mode is still there for CI.
No, and I went and checked. Running browser tests against several copies of the application at once is old, Magento's own legacy functional test framework could point parallel threads at multiple Magento instances, and its current one can group tests by time for parallel runs. A database per test worker is a well known pattern, and splitting specs by recorded duration instead of file count is what tools like Currents and Depot sell. There are also hosted services now that give each AI agent its own full-stack sandbox.
Most of what comes up when you search is isolation inside one running app (a database or schema per worker), which is not the same thing. Separate full instances do exist, mostly in CI, where each shard boots a fresh stack from scratch and throws it away after (one Magento test platform notes that boot alone takes 20 to 30 minutes per job). The closest to what I am doing is a WordPress Gutenberg experiment that gives each Playwright worker its own complete site with its own web and database containers, three per job, not merged.
And CI is where I got the idea. In my workflow CI is the final stage, it runs after the work is built and accepted to go live, so by then the functionality already exists and CI is the last check before it ships. The suite I am splitting here is the one that runs during development, over and over while a feature is being built and fixed, and that is where the hours were going. Seeing how cleanly the CI setups isolate each shard is what made me ask why my local dev setup couldn't do the same, so I moved that idea back into dev.
What I could not find written up is the dev environment itself being cloned: persistent full Magento copies (database, search, cache, Varnish) taken from the working dev site, kept warm on the workstation and re-synced between runs instead of rebuilt, with an isolation self-test as a gate, a planner that knows which specs must never share a moment, and an AI agent in a container asking a host-side AI to build them, with the host checking every script against an approved baseline before it runs it. That does not mean nobody does it, only that nobody I could find has written it up.
The simplest way I have found to think about it: a full pass cost about 600 CPU core-minutes however I split it, while video was still recording (about 570 on main alone, about 646 with one slot, the extra being the second stack's own overhead). Wall clock is roughly that work divided by the cores the tests actually get. So slots only help while there are cores free to give them, and on a working machine that is the real ceiling, not the number of copies. That is also why the laptop matters, it brings its own cores.
It also shows when a fix is real. With video recording truly off, a normal two-slot run costs about 470 core-minutes. The same suite cost about 646 with video still on. That is over a quarter of the work, gone, from one fixture.
The runner, the slot scripts and the detach code live in a private client repo, so there is nothing to link, and the commands above are excerpts. The guard on agent-to-agent messages is in my claude-skills-central repo, and the rest is the prior art I checked against.
I use my tooling predominantly on Mage-OS (Adobe Commerce / Magento) e-commerce projects, and my own AI Booking Agent. If you have not swapped to Mage-OS yet, you are falling behind ;)