wakapi icon indicating copy to clipboard operation
wakapi copied to clipboard

Multi-database tests

Open YC opened this issue 3 years ago • 3 comments

An issue that has occurred in the past is the failure of migrations given different target dbs (sqlite, postgres, mysql). Most of these should be detectable by doing some automated testing. i.e. Download and launch previous version of wakapi (and somehow exit), run new version of wakapi.

Databases:

  • postgres
  • mysql/mariadb
  • sqlite

Tasks:

  • [x] Execution of migrations
  • [ ] Execution of tests

YC avatar Sep 08 '22 08:09 YC

Thanks for bringing this up. The question is what exactly to test here.

We currently have (a few) unit tests and (a bit more) API tests. But they are only run on Linux and only with SQLite database. I think primary goal would be to extend testing in a way that especially the cross-database compatibility is verified with every CI run. Running the API test suite on MySQL and Postgres as well would probably suffice.

However, I don't know about good practices to automate testing with a fully-fledged database server. CI would have to:

  • Start a temporary MySQL / Postgres server
  • Import initial test data / fixtures (from an SQL file)
  • Start Wakapi
  • Run the newman tests
  • Tear everything down

Has anyone got any experiences about automating this in CI (specifically GH Actions)?

muety avatar Sep 08 '22 12:09 muety

Just randomly came across https://github.com/dolthub/go-mysql-server. Might actually be interesting, at least for testing the MySQL part.

muety avatar Sep 08 '22 12:09 muety

It's possible to use service containers when it comes to spawning dbs. https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers There wouldn't be any teardown required if test data is imported/populated on each execution.

YC avatar Sep 08 '22 12:09 YC