Welcome Guest, Not a member yet? Register   Sign In
Running test on existing database?
#1

Hi,
need some input on testing database-related code. Every night we mirror the production database to a local database server. I know that this may not be 100% kosher, but we would like to run CI4 tests using this database and not having to go through the hassle of setting up migrations and seeds for a pure testing database. Our CI/CO systems also have connectivity to the database mirror.
Setting up the testing database as described on https://codeigniter.com/user_guide/testi...abase.html nukes the database after one run, not good.
We have tried defining migrations and seeds, but with 100+ tables and relations, this is getting complex very quickly. We have also tried adding mysql restore commands but the database is 18 GB in size and it gets pretty slow.
Any input Greatly Appreciated!
/Mattias
Reply
#2

You can turn off migrations and seeders.
https://codeigniter.com/user_guide/testi...-and-seeds
$migrate
$seed

But if you changes the database data in your testing, you have to restore all the changed data after test executions.
If not, next time you run the test, it may fail.
Reply
#3

If this were me I would generate a SQLite3 database from the data to test (since it is a flat file) and then copy it in or `git restore` (depending on your CI\CD) the database between classes or tests (again, depends on what your tests modify). If your database is on another platform there are some slick conversion tools like https://github.com/dumblob/mysql2sqlite to get it into SQLite3 format quickly.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB