Work on 2014-07-12

Tags: kallithea docker

The unit tests now run inside of containers managed by fig. I wrote two scripts to facilitate the execution:

  • integration-configs/fig-config-glue.py: reads environment variables set by fig to create a sqlalchemy URL and update an ini file with it.
  • integration-configs/execute_tests.sh: runs the above script, updating test.ini, then sleeps for 10 seconds while the database starts, then runs nosetests

I had been switching between the various databases just by using a different fig configuration file, but that is insufficient. Fig must be invoked with both of the following arguments:

fig -f fig-${DB_TYPE} -p kallithea-${DB_TYPE}

If a project name isn’t specified, fig won’t differentiate between the various database containers (all named “db” in the configs).

Of course, different numbers of tests fail in each configuration (including some sqlite tests that don’t fail when I run it directly on my machine without docker in the middle), so there’s still some testing and adjusting to complete.

Another annoyance: when the tests complete, fig shuts down both containers, but fig’s exit code is always zero even if one of the containers exited with a non-zero return code. Going to ask the team if that’s by design or if they’re open to changing it. As is, I’ll need to either parse the nose output or parse the output of fig ps to give an appropriate exit code to the build server.