A couple of weeks ago, we updated Tracker to load its configuration using GSettings instead of its own old-fashioned .cfg files. GSettings is an API to manipulate key=value pairs that abstracts the backend (keyfiles, gconf, dconf…) where they are actually stored.

This was a good change in a lot of senses, but it was breaking our functional tests. We have a suite of tests that we like to run once Tracker is installed in the system. They check if the basic functionality is working fine: the store starts, the miner starts, basic Sparql is processed fine, crawling/monitoring a directory is ok… Some of those tests rely on booting tracker with an specific configuration and with gsettings that isn’t as easy as defining a new XDG_CONFIG_DIR anymore. Well, lets fix the tests then.

My first idea was to hack our GSettings object to load data from the system or from a keyfile, depending on an environment variable: very portable, but is an ugly hack and the code paths start to differ a lot. Then i discovered the DConf profiles. Only works when gsettings is using dconf and needs to install a system-wide profile, but otherwise (in code and test setup) is nice.

It took me more time than expected due some stupid mistakes here and there using dconf:

  • Profile names can only use alphanumeric and underscore characters. A profile like “tracker-test” won’t work (because is not a valid dbus name), but “trackertest” is fine. (Wiki updated now)
  • Do NOT set XDG_CONFIG_DIR in the environment (Bug reported). I guess that the client is using the variable to look for the DB but the writing daemon is not, so the results are not the expected
  • If at the same time you are changing the dconf schemas, make sure to remove old files from /usr/share/glib-2.0/schemas, run /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas and remove any old dconf database (in ~/.config/dconf) including “user”. Otherwise if some code is using the old schema, it won’t complain but the values will be wrong.
  • DConf uses the GVariant serialization, so be careful when setting lists.

I hope this saves some time to the next person trying to test something that uses dconf for its settings.

About these ads