Repository navigation
test(Database): fix state leaks and random-order test determinism for MySQLi, PostgreSQL, and OCI8 - #10581
test(Database): fix state leaks and random-order test determinism for MySQLi, PostgreSQL, and OCI8#10581gr8man wants to merge 1 commit into
Conversation
|
Hi there, @gr8man! 👋 It looks like this pull request does not follow our template:
Please update the description to follow the template. The |
7c62122 to
2bc665a
Compare
7b7132e to
36e3579
Compare
|
Hey everyone! 👋 I've finished testing and cleaning up the branch. I stripped out all the unnecessary changes (especially the OCI8 experiments and non-essential tweaks in What remains now is (hopefully!) the bare minimum strictly required to make the database test suite deterministic and green under
All checks are green across the board now. The PR is ready for review! 🚀 |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved cleanup, CI coverage, identifier quoting, assertion, and regression-test issues remain.
Review effort: Lite
Findings: 1
Open (3)
What changed in this PR
This PR improves database test isolation and random-order determinism across supported drivers, while stabilizing PostgreSQL upsert constraint selection.
Changes:
- Adds per-component database and connection cleanup.
- Improves migration, table, and metadata state handling.
- Updates PostgreSQL upsert behavior and randomized-test CI configuration.
| File | Summary |
|---|---|
tests/system/Database/Migrations/MigrationRunnerTest.php |
Cleans migration locks; lock handling must prevent leaked migration state. |
tests/system/Database/Live/UpsertTest.php |
Updates database-aware expectations; add primary-versus-unique constraint regression coverage. |
tests/system/Database/Live/Postgre/ConnectTest.php |
Uses isolated PostgreSQL connections. |
tests/system/Database/Live/MySQLi/NumberNativeTest.php |
Isolates MySQLi connection settings. |
tests/system/Database/Live/MySQLi/FoundRowsTest.php |
Isolates MySQLi connection state. |
tests/system/Database/Live/MetadataTest.php |
Resets metadata state and restores prefixes. |
tests/system/Database/Live/GetVersionTest.php |
Adjusts version validation; malformed trailing values must remain rejected. |
tests/system/Database/Live/ForgeTest.php |
Adds cleanup; dependent tables must be dropped before parent tables. |
tests/system/Database/Live/ExecuteLogMessageFormatTest.php |
Handles varied backtrace formats. |
tests/system/Database/Live/ConnectTest.php |
Resets shared connection state. |
tests/_support/Database/Migrations/20160428212500_Create_test_tables.php |
Improves migration cleanup. |
tests/_support/Config/Registrar.php |
Creates isolated databases; MySQL identifiers need safe quoting. |
system/Database/Postgre/Builder.php |
Prefers primary constraints for upserts. |
.github/workflows/test-random-execution.yml |
Updates database CI setup; OCI8 coverage needs a verification path. |
.github/scripts/random-tests-config.txt |
Enables Database random testing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| (int) $dbParams['port'], | ||
| ); | ||
| if (! $conn->connect_error) { | ||
| $conn->query('CREATE DATABASE IF NOT EXISTS ' . $conn->real_escape_string($dbParams['database'])); |
| $uniqueIndexes = array_filter($tableIndexes, static function ($index) use ($fieldNames): bool { | ||
| $hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields); | ||
|
|
||
| return ($index->type === 'UNIQUE' || $index->type === 'PRIMARY') && $hasAllFields; | ||
| return $index->type === 'PRIMARY' && $hasAllFields; |
| $version = $this->db->getVersion(); | ||
|
|
||
| $this->assertMatchesRegularExpression('/\A\d+(\.\d+)*\z/', $version); | ||
| $this->assertMatchesRegularExpression('/\A\d+(\.\d+)*/', $version); |
61079dd to
804ce9d
Compare
4fc3f9b to
af7d2b3
Compare
… MySQLi, PostgreSQL, and OCI8 Fixes database tests to be deterministic under random execution order for MySQLi, PostgreSQL, and OCI8 drivers. Ref codeigniter4#9968. - Fix random-order test execution issues and state leakage under PostgreSQL, MySQL, and OCI8 - Isolate per-component database schemas for parallel random-test runs - Prefer PRIMARY key over UNIQUE index in PostgreSQL upsert constraint selection - Drop team_members and migrations_lock tables during teardowns - Reset and isolate custom connection instances with non-shared connections - Exclude Oracle from parallel random-test matrix due to shared schema collisions - Optimize SQLSRV test database settings with RECOVERY SIMPLE and DELAYED_DURABILITY
af7d2b3 to
70e7231
Compare


Description
Fixes database tests to be deterministic under random execution order
for MySQLi, PostgreSQL, and OCI8 drivers. Ref: #9968
Ref: #9968
Checklist: