How to copy a production database to circle_test database?

mysql
circle.yml

#1

How to copy a production database to circle_test database ? I want this to be an automatic process.
What will be your approach to this problem ?
Maybe the best would be if I have during every call to circleCI through circle.yml some command which copies and paste the production database every week. And every week because I don’t want to mess around with production database performance.
We are using mySql, latest version if it makes any difference.


#2

Hello!

I don’t know much about your use case, but I would urge you not to use production data in your unit tests. Primarily, this could have major privacy and security risks.

Moreover, it may be slow and unclear what you’re really testing if your tests rely on real-world data.

I’d recommend instead building a mock data set that you test against. For example, you might write simple JSON/CSV files with data and write a script to ingest those into your test database at the beginning of the test run.


#3

OK, thanks for clearing that up.
I have another question though. So we are altering our production database once in a week with this kind of commands: alter table <TABLE_NAME> add column;
Could I somehow automatically adjust the process so that our circle_test is automatically adjusted ?
Then what do you think will be the best approach to this problem ?


#4

Hi,

You may find helpful http://www.liquibase.org/.
liquibase can script all the db changes, and import the test batch on every test run.

Another approach would be to use mysldump.

You can also do a combination of these things.


#5

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.


#6

Another alternative is to commit a example database dump to your project repo, and then load that into your database during CI. This allows you to setup a “real-world” scenario full of data, and not depend on giving up your production database credentials to CI.