lundi 29 mai 2017

How would you manage a test database for running tests against it?

This question is probably not Jenkins-only. However I am thinking about this concept because of we want to implement Jenkins CI into our workflow, so this would be a good place to start.

So let's start by giving some context: I'm a Jenkins newby. I work for an internet agency and work on projects from Drupal 7 and 8 to 100% custom legacy projects. All of them being websites, build on PHP and Mysql.

Some Jenkins / Testing concepts are clear to me, others still vague or even unclear. We have written tests in the past, but we didn't consider all facets as good as we are trying to right now.

I now came to the point of thinking about how you would manage a database to run tests against it.

Looking at codeception's Db subject, they explain that a mysql dump will be loaded before running each test, so that the tests always run against a clean database.

Implementing that in our workflow I would think of something like this:

1) Let's say I start developing a new feature on a new Git branch.

2) I would first make sure my repository is up-to-date and run all patches/config-exports against my database, so that also my database is up-to-date

3) I would then first make a database dump from the current state of the database and make sure that no unnecessary data like logs, etc. are in that dump.

4) I would then start developing and any structural database changes must be in patchfiles, or - in the case of Drupal 8 - in config exports.

5) Then finally when everything has been committed and a merge request is being made, the test stack will load the clean database in a test environment, run all patches/config-imports against it, and finally run the tests.

Could you guys please tell me whether this is a good scenario or give me a better one? All feedback will be greatly appreciated since I'm absolutely new to this concept.

Aucun commentaire:

Enregistrer un commentaire