Run the test suite against MariaDB instead of SQLite #169
Labels
No labels
bug
devops
duplicate
enhancement
good first issue
layout
next major release
next minor release
question
research
testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Depends on
#170 Give routes a surrogate primary key}
lvl0/fedi-feed-router
#148 Build the base and CI images from a workflow instead of by hand
lvl0/fedi-feed-router
Reference: lvl0/fedi-feed-router#169
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
phpunit.xmlforcesDB_CONNECTION=sqlite/DB_DATABASE=:memory:, while dev and production run MariaDB. SQLite silently tolerates schema operations and constraints MariaDB rejects, so the suite produces false positives: a migration can be green in CI and fail on deploy.This project has already shipped a broken migration chain once (#150), and
.claude/PLATFORM.mddocuments MariaDB-specific constraints (feeds.urlUNIQUE vs non-uniquefeeds.provider) that no test can currently exercise.It also blocks the
routes.idticket — that migration alters a composite primary key with a dependent foreign key, which is exactly the class of operation SQLite would accept and MariaDB might refuse.Approach
Point
phpunit.xmlat a MariaDB test database.RefreshDatabasemigrates once and wraps each test in a rolled-back transaction against a real transactional database, rather than re-running migrations per test as it does for an in-memory database — so the suite may not get slower. One published benchmark found MySQL faster than in-memory SQLite for this reason. Measure before and after rather than assuming either direction.CI needs a MariaDB service container in
.forgejo/workflows/ci.yml, with steps health-gated on it. Sequenced after #148 so the CI image build path is automated first.Blocked on
The dev MariaDB credentials currently fail —
container_db_read(asroot) andcontainer_tinker(asffr) both returnAccess denied. The dev database was recreated from a freshmariadb:11pull during #164 and may no longer match the compose file's expected credentials. This must be resolved first.Acceptance criteria
.claude/PLATFORM.mdupdated — the SQLite note under Dev Environment is now wrongRelated
Blocker resolved. The dev MariaDB is reachable again.
Cause: the
db_datavolume predated the current credentials. MariaDB's entrypoint only createsMYSQL_USER/MYSQL_PASSWORDwhen it initialises an empty data directory — the log showedMariaDB upgrade not requiredwith noInitializing database files, so the compose file's credentials were never applied to that volume.rootfailed too, so the volume's actual credentials were unrecoverable.Fixed by recreating the volume (dev data was seeded fixtures only):
Verified: MariaDB 11.8.8, database
ffr_dev, 27 migrations applied,ffr@%present. Bothcontainer_tinkerandcontainer_db_readwork again.Worth knowing for this ticket: a test database created the same way will have the same property — changing credentials in compose does nothing to an existing volume. If the MariaDB test database is provisioned as a separate volume, that is a trap to document rather than rediscover.
Obstacle to solve before starting: the CI image has no
pdo_mysqlyet#148 added
pdo_mysqltodocker/build/Dockerfile.ciand bumped the image version tophp8.3-4, butci.ymlstill pinsphp8.3-3, which lacks the driver. That was deliberate — pinning CI to an image that does not exist yet would have failed #148's own PR.php8.3-4gets built only whenimages.ymlruns, andimages.ymltriggers on push tomain, which happens whenrelease/v1.5.0merges at release time. So the image this ticket needs will not exist until the end of the milestone.Consequence: the moment
phpunit.xmlpoints at MariaDB, CI fails with a missing-driver error, and the fix is not available yet. Local work against the dev database is unaffected.Options, none yet chosen:
fedi-feed-router-ci:php8.3-4by hand, once. Gets CI working immediately. Ironic given #148 exists to stop hand-building images, but defensible as a one-off to break the cycle.images.ymlruns on themainmerge. Honest but leaves the branch red for a while, and CI cannot be trusted as a gate for #170 either.images.ymlonmainearly — e.g. merge #148's image changes tomainahead of the rest of the milestone. Deviates from the release flow.images.ymlmanually if Forgejo exposes theworkflow_dispatchbutton. Cleanest if available; unverified whether it is.Also note
ci.ymlneeds a MariaDB service container regardless — that is separate from the image and part of this ticket's own work.Related
pdo_mysqland thephp8.3-4tag; its own verification is also waiting onimages.ymlrunning onmain